Class ConfigObjectProperty<T>
java.lang.Object
net.darkhax.pricklemc.common.api.config.property.ObjectProperty<T>
net.darkhax.pricklemc.common.api.config.property.ConfigObjectProperty<T>
- Type Parameters:
T- The type of the config property.
- All Implemented Interfaces:
IConfigProperty<T>
A config property that contains an object of sub-properties.
-
Field Summary
Fields inherited from class net.darkhax.pricklemc.common.api.config.property.ObjectProperty
FALLBACK_ADAPTER -
Method Summary
Modifier and TypeMethodDescriptionstatic IPropertyAdapter<?> adapter(PropertyResolver resolver) Creates a new adapter using a specific property resolver.voidread(com.google.gson.stream.JsonReader reader, PropertyResolver resolver, org.slf4j.Logger logger) Reads the value from the JSON and applies it to the parent object.voidwriteValue(T value, com.google.gson.stream.JsonWriter writer, PropertyResolver resolver, org.slf4j.Logger logger) Writes a value to the JSON writer.Methods inherited from class net.darkhax.pricklemc.common.api.config.property.ObjectProperty
comment, defaultValue, readValue, validate, value, write, writeAdditionalComments, writeDefaultValue, writeDefaultValue
-
Method Details
-
writeValue
public void writeValue(T value, com.google.gson.stream.JsonWriter writer, PropertyResolver resolver, org.slf4j.Logger logger) throws IOException Description copied from class:ObjectPropertyWrites a value to the JSON writer.- Overrides:
writeValuein classObjectProperty<T>- Parameters:
value- The value to be written.writer- A writer to write JSON data to.resolver- Resolves properties with GSON or config properties.logger- A log instance used to log warnings and errors encountered when saving the value.- Throws:
IOException- A fatal exception may be thrown if the value could not be written.
-
read
public void read(com.google.gson.stream.JsonReader reader, PropertyResolver resolver, org.slf4j.Logger logger) throws IOException Description copied from interface:IConfigPropertyReads the value from the JSON and applies it to the parent object.- Specified by:
readin interfaceIConfigProperty<T>- Overrides:
readin classObjectProperty<T>- Parameters:
reader- A reader containing a stream of JSON data.resolver- Resolves properties with GSON or config properties.logger- A log instance used to log warnings and errors encountered when the value is read.- Throws:
IOException- Fatal errors should be thrown if invalid data is encountered.
-
adapter
Creates a new adapter using a specific property resolver. This ensures the GSON instance and the type adapter options are passed to the sub properties.- Parameters:
resolver- The property resolver.- Returns:
- An adapter that can handle config properties that are held as sub properties.
-