public static class LXSerializable.Utils extends Object
Constructor and Description |
---|
Utils() |
Modifier and Type | Method and Description |
---|---|
static void |
loadArray(LX lx,
List<? extends LXSerializable> serializables,
JsonObject object,
String key)
Loads an array of sub-objects from the given key, if it is found
|
static void |
loadArray(LX lx,
LXSerializable[] serializables,
JsonObject object,
String key)
Loads an array of sub-objects from the given key, if it is found
|
static void |
loadBoolean(BooleanParameter parameter,
JsonObject object,
String key)
Loads a boolean value into a parameter, if it is found.
|
static void |
loadDouble(LXParameter parameter,
JsonObject object,
String key)
Loads an double value into a parameter, if it is found.
|
static void |
loadInt(DiscreteParameter parameter,
JsonObject object,
String key)
Loads an integer value into a parameter, if it is found.
|
static void |
loadObject(LX lx,
LXSerializable serializable,
JsonObject object,
String key)
Loads a serializable object from a sub-key, if the key is found.
|
static void |
loadObject(LX lx,
LXSerializable serializable,
JsonObject object,
String key,
boolean defaultEmptyObj)
Loads a serializable object from a sub-key, if the key is found.
|
static void |
loadParameter(LXParameter parameter,
JsonObject obj,
String path) |
static void |
loadString(StringParameter parameter,
JsonObject object,
String key)
Loads an double value into a parameter, if it is found.
|
static void |
saveParameter(LXParameter parameter,
JsonObject obj) |
static void |
saveParameter(LXParameter parameter,
JsonObject obj,
String path) |
static JsonObject |
stripIds(JsonObject object)
Strips all ID values out of a JsonObject.
|
static JsonArray |
toArray(LX lx,
Collection<? extends LXSerializable> serializables)
Serialized a generic collection of sub-objects, not necessarily ordered
|
static JsonArray |
toArray(LX lx,
LXSerializable[] serializables)
Serializes an array of subobjects
|
static JsonObject |
toObject(LXComponent component)
Serializes an LXComponent to a JsonObject
|
static JsonObject |
toObject(LX lx,
LXSerializable serializable)
Serializes any LXSerializable to a JsonObject
|
static JsonObject |
toObject(LX lx,
Map<String,? extends LXSerializable> serializables)
Serializes a map of subobjects into a JsonObject
|
public static void saveParameter(LXParameter parameter, JsonObject obj)
public static void saveParameter(LXParameter parameter, JsonObject obj, String path)
public static void loadParameter(LXParameter parameter, JsonObject obj, String path)
public static void loadInt(DiscreteParameter parameter, JsonObject object, String key)
parameter
- Parameter to loadobject
- Json objectkey
- Key to check, if exists loaded as intpublic static void loadBoolean(BooleanParameter parameter, JsonObject object, String key)
parameter
- Parameter to loadobject
- Json objectkey
- Key to check, if exists loaded as booleanpublic static void loadDouble(LXParameter parameter, JsonObject object, String key)
parameter
- Parameter to loadobject
- Json objectkey
- Key to check, if exists loaded as doublepublic static void loadString(StringParameter parameter, JsonObject object, String key)
parameter
- Parameter to loadobject
- Json objectkey
- Key to check, if exists loaded as stringpublic static void loadObject(LX lx, LXSerializable serializable, JsonObject object, String key)
lx
- LX instanceserializable
- Sub-object to loadobject
- JSON object to load fromkey
- Key to check for existence ofpublic static void loadObject(LX lx, LXSerializable serializable, JsonObject object, String key, boolean defaultEmptyObj)
true
. The sub-object should handle that.lx
- LX instanceserializable
- Sub-object to loadobject
- JSON object to load fromkey
- Key to check for existence ofdefaultEmptyObj
- Whether to load an empty JsonObject if key
is not foundpublic static void loadArray(LX lx, List<? extends LXSerializable> serializables, JsonObject object, String key)
lx
- LX instanceserializables
- List of child objects to loadobject
- Object to load fromkey
- Key to check forpublic static void loadArray(LX lx, LXSerializable[] serializables, JsonObject object, String key)
lx
- LX instanceserializables
- array of child objects to loadobject
- Object to load fromkey
- Key to check forpublic static JsonObject toObject(LXComponent component)
component
- Component to serializepublic static JsonObject toObject(LX lx, LXSerializable serializable)
lx
- LX instanceserializable
- Serializable objectpublic static JsonObject toObject(LX lx, Map<String,? extends LXSerializable> serializables)
lx
- LX instanceserializables
- Map of serializable subobjectspublic static JsonArray toArray(LX lx, LXSerializable[] serializables)
lx
- LX instanceserializables
- Array of sub-objectspublic static JsonArray toArray(LX lx, Collection<? extends LXSerializable> serializables)
lx
- LX instanceserializables
- Collection of serializable objectspublic static JsonObject stripIds(JsonObject object)
object
- Object to strip all nested ID keys fromLX library by Mark C. Slee. © 2012-2020