public final class PropertySaver
extends java.lang.Object
@SaveThisProperty
and properties of fields annotated
with @SavePropertyFrom
. Annotated fields from the entire superclass hierarchy are saved,
not just fields from the object being serialized.Constructor and Description |
---|
PropertySaver() |
Modifier and Type | Method and Description |
---|---|
static java.lang.reflect.Method |
getGetter(java.lang.Class<?> clazz,
java.lang.String propertyName)
Gets the getter method in the given class for a property with the given name, in the form
get<name> e.g. |
static java.util.stream.Stream<java.lang.reflect.Field> |
getPropertyFields(java.lang.Class<?> clazz)
Gets a stream of the fields in the object's class hierarchy annotated with
@SaveThisProperty . |
void |
readAllProperties(Component object,
com.google.gson.JsonDeserializationContext context,
com.google.gson.JsonObject jsonObject)
Read all properties from a component.
|
void |
readAnnotatedFields(java.lang.Object object,
com.google.gson.JsonDeserializationContext context,
com.google.gson.JsonObject jsonObject)
Deserializes property fields annotated with
@SaveThisProperty . |
void |
readNestedProperties(java.lang.Object object,
com.google.gson.JsonDeserializationContext context,
com.google.gson.JsonObject jsonObject)
Deserialized nested properties from fields annotated ith
@SavePropertyFrom in the object's
class hierarchy. |
void |
saveAllProperties(Component object,
com.google.gson.JsonSerializationContext context,
com.google.gson.JsonObject jsonObject)
Saves all properties from a component.
|
void |
saveAnnotatedFields(java.lang.Object object,
com.google.gson.JsonSerializationContext context,
com.google.gson.JsonObject jsonObject)
Saves property fields annotated with
@SaveThisProperty . |
void |
saveNestedProperties(java.lang.Object object,
com.google.gson.JsonSerializationContext context,
com.google.gson.JsonObject jsonObject)
Saves nested properties from fields annotated ith
@SavePropertyFrom in the object's class
hierarchy. |
static void |
serializeProperty(com.google.gson.JsonSerializationContext context,
com.google.gson.JsonObject object,
javafx.beans.property.Property p,
java.lang.String name) |
public void saveAllProperties(Component object, com.google.gson.JsonSerializationContext context, com.google.gson.JsonObject jsonObject)
Component.getSettings()
SaveThisProperty
in the component's class hierarchySavePropertyFrom
in the component's class hierarchyobject
- the object to serialize properties fromcontext
- the serialization contextjsonObject
- the JSON object to serialize intopublic void saveAnnotatedFields(java.lang.Object object, com.google.gson.JsonSerializationContext context, com.google.gson.JsonObject jsonObject)
@SaveThisProperty
.object
- the object to serialize properties fromcontext
- the serialization contextjsonObject
- the JSON object to serialize intopublic void saveNestedProperties(java.lang.Object object, com.google.gson.JsonSerializationContext context, com.google.gson.JsonObject jsonObject)
@SavePropertyFrom
in the object's class
hierarchy.object
- the object to serialize properties fromcontext
- the serialization contextjsonObject
- the JSON object to serialize intopublic void readAllProperties(Component object, com.google.gson.JsonDeserializationContext context, com.google.gson.JsonObject jsonObject)
Component.getSettings()
SaveThisProperty
in the component's class hierarchySavePropertyFrom
in the component's class hierarchyobject
- the object to serialize properties fromcontext
- the serialization contextjsonObject
- the JSON object to serialize intopublic void readAnnotatedFields(java.lang.Object object, com.google.gson.JsonDeserializationContext context, com.google.gson.JsonObject jsonObject)
@SaveThisProperty
.object
- the object containing the properties to deserializecontext
- the deserialization contextjsonObject
- the JSON object to deserializepublic void readNestedProperties(java.lang.Object object, com.google.gson.JsonDeserializationContext context, com.google.gson.JsonObject jsonObject)
@SavePropertyFrom
in the object's
class hierarchy.object
- the object containing the properties to deserializecontext
- the deserialization contextjsonObject
- the JSON object to deserializepublic static java.lang.reflect.Method getGetter(java.lang.Class<?> clazz, java.lang.String propertyName)
get<name>
e.g.
getFoo()
. The method must be public. Boolean properties can also be in the form is<name>
, e.g.
isFoo()
.clazz
- the class containing the propertypropertyName
- the name of the propertyjava.lang.IllegalArgumentException
- if there is not exactly ONE method matching public Foo get<property>()
or public boolean is<property>()
public static java.util.stream.Stream<java.lang.reflect.Field> getPropertyFields(java.lang.Class<?> clazz)
@SaveThisProperty
.public static void serializeProperty(com.google.gson.JsonSerializationContext context, com.google.gson.JsonObject object, javafx.beans.property.Property p, java.lang.String name)