Class FileDeserializer<Data>
java.lang.Object
dev.prozilla.pine.common.property.mutable.SimpleMutableObjectProperty<Data>
dev.prozilla.pine.common.property.observable.SimpleObservableObjectProperty<Data>
dev.prozilla.pine.common.property.deserialized.FileDeserializer<Data>
- Type Parameters:
Data- The data type to deserialize the file to
- All Implemented Interfaces:
Destructible,MutableObjectProperty<Data>,MutableProperty<Data>,ObservableObjectProperty<Data>,ObservableProperty<Data>,SimpleObservableProperty<Data>,Property<Data>,Functor<Data>
- Direct Known Subclasses:
HotFileDeserializer
Deserializes data from a given JSON file.
-
Field Summary
FieldsFields inherited from class dev.prozilla.pine.common.property.observable.SimpleObservableObjectProperty
loggerFields inherited from interface dev.prozilla.pine.common.property.observable.ObservableProperty
OBSERVER_ERROR -
Constructor Summary
ConstructorsConstructorDescriptionFileDeserializer(String path, Class<Data> dataType) FileDeserializer(String path, Class<Data> dataType, boolean alwaysCreateData) -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddDeserializers(ValueDeserializer<?>... deserializers) Adds value deserializers to the object mapper using aFileDeserializerModule.createBooleanProperty(DeserializedBooleanProperty.ValueFactory<Data> valueFactory) Creates a boolean property whose value is retrieved from the deserialized data.createBooleanProperty(DeserializedBooleanProperty.ValueFactory<Data> valueFactory, boolean fallbackValue) Creates a boolean property whose value is retrieved from the deserialized data.protected DatacreateFloatProperty(DeserializedFloatProperty.ValueFactory<Data> valueFactory) Creates a float property whose value is retrieved from the deserialized data.createFloatProperty(DeserializedFloatProperty.ValueFactory<Data> valueFactory, float fallbackValue) Creates a float property whose value is retrieved from the deserialized data.protected InputStreamCreates an input stream from the file.createIntProperty(DeserializedIntProperty.ValueFactory<Data> valueFactory) Creates an int property whose value is retrieved from the deserialized data.createIntProperty(DeserializedIntProperty.ValueFactory<Data> valueFactory, int fallbackValue) Creates an int property whose value is retrieved from the deserialized data.<T> DeserializedObjectProperty<T> createProperty(DeserializedObjectProperty.ValueFactory<Data, T> valueFactory) Creates a property whose value is retrieved from the deserialized data.<T> DeserializedObjectProperty<T> createProperty(DeserializedObjectProperty.ValueFactory<Data, T> valueFactory, T fallbackValue) Creates a property whose value is retrieved from the deserialized data.createStringProperty(DeserializedObjectProperty.ValueFactory<Data, String> valueFactory) Creates a string property whose value is retrieved from the deserialized data.createStringProperty(DeserializedObjectProperty.ValueFactory<Data, String> valueFactory, String fallbackValue) Creates a string property whose value is retrieved from the deserialized data.Deserializes the data from the file and stores it as the value of this property.static voidResets the states of features of the object mapper to their default state.voidsetAlwaysCreateData(boolean alwaysCreateData) static voidsetFailOnInvalidSubtype(boolean state) Sets the state ofDeserializationFeature.FAIL_ON_INVALID_SUBTYPEfor the object mapper.static voidsetFailOnNullForPrimitives(boolean state) Sets the state ofDeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVESfor the object mapper.static voidsetFailOnUnknowProperties(boolean state) Sets the state ofDeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIESfor the object mapper.static voidsetFeatureState(com.fasterxml.jackson.databind.DeserializationFeature feature, boolean state) Enables or disables a deserialization feature of the object mapper.Methods inherited from class dev.prozilla.pine.common.property.observable.SimpleObservableObjectProperty
addObserver, destroy, getLogger, onValueChange, removeObserver, setLoggerMethods inherited from class dev.prozilla.pine.common.property.mutable.SimpleMutableObjectProperty
getValue, setValueMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.prozilla.pine.common.property.mutable.MutableObjectProperty
setNull, stealMethods inherited from interface dev.prozilla.pine.common.property.mutable.MutableProperty
modifyValue, setValue, swapValue, viewPropertyMethods inherited from interface dev.prozilla.pine.common.property.observable.ObservableProperty
readMethods inherited from interface dev.prozilla.pine.common.property.Property
getValue, getValueOr, hasValue, hasValueProperty, isNotNull, isNotNullProperty, isNull, map, replaceNull, requireValue, snapshot, toStringProperty
-
Field Details
-
path
-
alwaysCreateData
protected boolean alwaysCreateData -
ALWAYS_CREATE_DATA_DEFAULT
public static final boolean ALWAYS_CREATE_DATA_DEFAULT- See Also:
-
-
Constructor Details
-
FileDeserializer
-
FileDeserializer
-
-
Method Details
-
setAlwaysCreateData
public void setAlwaysCreateData(boolean alwaysCreateData) -
deserialize
Deserializes the data from the file and stores it as the value of this property.- Returns:
- The deserialized data.
-
createFallbackData
-
createInputStream
Creates an input stream from the file.- Returns:
- The input stream.
-
createProperty
@Contract("_ -> new") public <T> DeserializedObjectProperty<T> createProperty(DeserializedObjectProperty.ValueFactory<Data, T> valueFactory) Creates a property whose value is retrieved from the deserialized data.- Type Parameters:
T- The type of value of the property- Parameters:
valueFactory- The method used to retrieve the value from the deserialized file.- Returns:
- The new property.
-
createProperty
@Contract("_, _ -> new") public <T> DeserializedObjectProperty<T> createProperty(DeserializedObjectProperty.ValueFactory<Data, T> valueFactory, T fallbackValue) Creates a property whose value is retrieved from the deserialized data.- Type Parameters:
T- The type of value of the property- Parameters:
valueFactory- The method used to retrieve the value from the deserialized file.fallbackValue- Fallback value to use in case the deserialized data is empty or incomplete.- Returns:
- The new property.
-
createIntProperty
@Contract("_ -> new") public DeserializedIntProperty createIntProperty(DeserializedIntProperty.ValueFactory<Data> valueFactory) Creates an int property whose value is retrieved from the deserialized data.- Parameters:
valueFactory- The method used to retrieve the value from the deserialized file.- Returns:
- The new property.
-
createIntProperty
@Contract("_, _ -> new") public DeserializedIntProperty createIntProperty(DeserializedIntProperty.ValueFactory<Data> valueFactory, int fallbackValue) Creates an int property whose value is retrieved from the deserialized data.- Parameters:
valueFactory- The method used to retrieve the value from the deserialized file.fallbackValue- Fallback value to use in case the deserialized data is empty.- Returns:
- The new property.
-
createFloatProperty
@Contract("_ -> new") public DeserializedFloatProperty createFloatProperty(DeserializedFloatProperty.ValueFactory<Data> valueFactory) Creates a float property whose value is retrieved from the deserialized data.- Parameters:
valueFactory- The method used to retrieve the value from the deserialized file.- Returns:
- The new property.
-
createFloatProperty
@Contract("_, _ -> new") public DeserializedFloatProperty createFloatProperty(DeserializedFloatProperty.ValueFactory<Data> valueFactory, float fallbackValue) Creates a float property whose value is retrieved from the deserialized data.- Parameters:
valueFactory- The method used to retrieve the value from the deserialized file.fallbackValue- Fallback value to use in case the deserialized data is empty.- Returns:
- The new property.
-
createBooleanProperty
@Contract("_ -> new") public DeserializedBooleanProperty createBooleanProperty(DeserializedBooleanProperty.ValueFactory<Data> valueFactory) Creates a boolean property whose value is retrieved from the deserialized data.- Parameters:
valueFactory- The method used to retrieve the value from the deserialized file.- Returns:
- The new property.
-
createBooleanProperty
@Contract("_, _ -> new") public DeserializedBooleanProperty createBooleanProperty(DeserializedBooleanProperty.ValueFactory<Data> valueFactory, boolean fallbackValue) Creates a boolean property whose value is retrieved from the deserialized data.- Parameters:
valueFactory- The method used to retrieve the value from the deserialized file.fallbackValue- Fallback value to use in case the deserialized data is empty.- Returns:
- The new property.
-
createStringProperty
@Contract("_ -> new") public DeserializedStringProperty createStringProperty(DeserializedObjectProperty.ValueFactory<Data, String> valueFactory) Creates a string property whose value is retrieved from the deserialized data.- Parameters:
valueFactory- The method used to retrieve the value from the deserialized file.- Returns:
- The new property.
-
createStringProperty
@Contract("_, _ -> new") public DeserializedStringProperty createStringProperty(DeserializedObjectProperty.ValueFactory<Data, String> valueFactory, String fallbackValue) Creates a string property whose value is retrieved from the deserialized data.- Parameters:
valueFactory- The method used to retrieve the value from the deserialized file.fallbackValue- Fallback value to use in case the deserialized data is empty or incomplete.- Returns:
- The new property.
-
addDeserializers
Adds value deserializers to the object mapper using aFileDeserializerModule.- Parameters:
deserializers- The deserializers to add
-
resetFeatureStates
public static void resetFeatureStates()Resets the states of features of the object mapper to their default state. -
setFailOnNullForPrimitives
public static void setFailOnNullForPrimitives(boolean state) Sets the state ofDeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVESfor the object mapper.- Parameters:
state- Whether to enable or disable the feature
-
setFailOnUnknowProperties
public static void setFailOnUnknowProperties(boolean state) Sets the state ofDeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIESfor the object mapper.- Parameters:
state- Whether to enable or disable the feature
-
setFailOnInvalidSubtype
public static void setFailOnInvalidSubtype(boolean state) Sets the state ofDeserializationFeature.FAIL_ON_INVALID_SUBTYPEfor the object mapper.- Parameters:
state- Whether to enable or disable the feature
-
setFeatureState
public static void setFeatureState(com.fasterxml.jackson.databind.DeserializationFeature feature, boolean state) Enables or disables a deserialization feature of the object mapper.- Parameters:
feature- The feature to enable or disablestate- Whether to enable or disable the feature
-