Class ObjectConverter
java.lang.Object
com.electronwill.nightconfig.core.conversion.ObjectConverter
Converts Java objects to configs and vice-versa.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new ObjectConverter with the default parameters.ObjectConverter(boolean bypassTransient, boolean bypassFinal) Creates a new ObjectConverter with advanced parameters. -
Method Summary
Modifier and TypeMethodDescriptionvoid<C extends Config>
CvoidConverts an Object to a Config.<C extends Config>
CConverts an Object to a Config.voidtoObject(UnmodifiableConfig config, Object destination) Converts a Config to an Object.<O> OtoObject(UnmodifiableConfig config, Supplier<O> destinationSupplier) Converts a Config to an Object.
-
Constructor Details
-
ObjectConverter
public ObjectConverter(boolean bypassTransient, boolean bypassFinal) Creates a new ObjectConverter with advanced parameters.- Parameters:
bypassTransient-trueto use (parse or write) a field even if it's transientbypassFinal-trueto write a field even if it's final
-
ObjectConverter
public ObjectConverter()Creates a new ObjectConverter with the default parameters. This is equivalent tonew ObjectConverter(false, true).- See Also:
-
-
Method Details
-
toConfig
Converts an Object to a Config.- Parameters:
o- the object to convertdestination- the Config where to put the values into
-
toConfig
-
toConfig
Converts an Object to a Config.- Type Parameters:
C- the destination's type- Parameters:
o- the object to convertdestinationSupplier- a Supplier that provides the Config where to put the values into- Returns:
- the Config obtained from the Supplier
-
toConfig
-
toObject
Converts a Config to an Object.- Parameters:
config- the config to convertdestination- the Object where to put the values into
-
toObject
Converts a Config to an Object.- Type Parameters:
O- the destination's type- Parameters:
config- the config to convertdestinationSupplier- a Supplier that provides the Object where to put the values into- Returns:
- the object obtained from the Supplier
-