Package org.spongepowered.configurate
Class ConfigurationOptions
- java.lang.Object
-
- org.spongepowered.configurate.ConfigurationOptions
-
public abstract class ConfigurationOptions extends Object
This object is a holder for general configuration options.This is meant to hold options that are used in configuring how the configuration data structures are handled, rather than the serialization configuration which is located in
ConfigurationLoader
s.This class is immutable.
- Since:
- 4.0.0
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
acceptsType(Class<?> type)
Gets whether objects of the provided type are natively accepted as values for nodes with this as their options object.static ConfigurationOptions
defaults()
Get the default set of options.abstract @Nullable String
header()
Gets the header specified in these options.ConfigurationOptions
header(@Nullable String header)
Creates a newConfigurationOptions
instance, with the specified header set, and all other settings copied from this instance.abstract boolean
implicitInitialization()
Get whether values should be implicitly initialized.ConfigurationOptions
implicitInitialization(boolean implicitInitialization)
Create a newConfigurationOptions
instance with the specified implicit initialization setting.abstract MapFactory
mapFactory()
Gets theMapFactory
specified in these options.ConfigurationOptions
mapFactory(MapFactory mapFactory)
Creates a newConfigurationOptions
instance, with the specifiedMapFactory
set, and all other settings copied from this instance.ConfigurationOptions
nativeTypes(@Nullable Set<Class<?>> nativeTypes)
Creates a newConfigurationOptions
instance, with the specified native types set, and all other settings copied from this instance.abstract TypeSerializerCollection
serializers()
Gets theTypeSerializerCollection
specified in these options.ConfigurationOptions
serializers(Consumer<TypeSerializerCollection.Builder> serializerBuilder)
Creates a newConfigurationOptions
instance, with a newTypeSerializerCollection
created as a child of this options' current collection.ConfigurationOptions
serializers(TypeSerializerCollection serializers)
Creates a newConfigurationOptions
instance, with the specifiedTypeSerializerCollection
set, and all other settings copied from this instance.abstract boolean
shouldCopyDefaults()
Gets whether or not default parameters provided toConfigurationNode
getter methods should be set to the node when used.ConfigurationOptions
shouldCopyDefaults(boolean shouldCopyDefaults)
Creates a newConfigurationOptions
instance, with the specified 'copy defaults' setting set, and all other settings copied from this instance.
-
-
-
Method Detail
-
defaults
public static ConfigurationOptions defaults()
Get the default set of options. This may be overridden by your chosen configuration loader, so when building configurations it is recommended to accessAbstractConfigurationLoader.Builder#getDefaultOptions()
instead.- Returns:
- the default options
- Since:
- 4.0.0
-
mapFactory
public abstract MapFactory mapFactory()
Gets theMapFactory
specified in these options.- Returns:
- the map factory
- Since:
- 4.0.0
-
mapFactory
public ConfigurationOptions mapFactory(MapFactory mapFactory)
Creates a newConfigurationOptions
instance, with the specifiedMapFactory
set, and all other settings copied from this instance.- Parameters:
mapFactory
- the new factory to use to create a map- Returns:
- the new options object
- Since:
- 4.0.0
-
header
public abstract @Nullable String header()
Gets the header specified in these options.- Returns:
- the current header. Lines are split by \n, with no trailing newline
- Since:
- 4.0.0
-
header
public ConfigurationOptions header(@Nullable String header)
Creates a newConfigurationOptions
instance, with the specified header set, and all other settings copied from this instance.- Parameters:
header
- the new header to use- Returns:
- the new options object
- Since:
- 4.0.0
-
serializers
public abstract TypeSerializerCollection serializers()
Gets theTypeSerializerCollection
specified in these options.- Returns:
- the type serializers
- Since:
- 4.0.0
-
serializers
public ConfigurationOptions serializers(TypeSerializerCollection serializers)
Creates a newConfigurationOptions
instance, with the specifiedTypeSerializerCollection
set, and all other settings copied from this instance.- Parameters:
serializers
- the serializers to use- Returns:
- the new options object
- Since:
- 4.0.0
-
serializers
public final ConfigurationOptions serializers(Consumer<TypeSerializerCollection.Builder> serializerBuilder)
Creates a newConfigurationOptions
instance, with a newTypeSerializerCollection
created as a child of this options' current collection. The provided function will be called with the builder for this new collection to allow registering more type serializers.- Parameters:
serializerBuilder
- accepts a builder for the collection that will be used in the returned options object.- Returns:
- the new options object
- Since:
- 4.0.0
-
nativeTypes
public ConfigurationOptions nativeTypes(@Nullable Set<Class<?>> nativeTypes)
Creates a newConfigurationOptions
instance, with the specified native types set, and all other settings copied from this instance.Native types are format-dependent, and must be provided by a configuration loader's
default options
Null indicates that all types are accepted.
- Parameters:
nativeTypes
- the types that will be accepted to a call toConfigurationNode.set(Object)
- Returns:
- updated options object
- Since:
- 4.0.0
-
acceptsType
public final boolean acceptsType(Class<?> type)
Gets whether objects of the provided type are natively accepted as values for nodes with this as their options object.- Parameters:
type
- the type to check- Returns:
- whether the type is accepted
- Since:
- 4.0.0
-
shouldCopyDefaults
public abstract boolean shouldCopyDefaults()
Gets whether or not default parameters provided toConfigurationNode
getter methods should be set to the node when used.- Returns:
- whether defaults should be copied into value
- Since:
- 4.0.0
-
shouldCopyDefaults
public ConfigurationOptions shouldCopyDefaults(boolean shouldCopyDefaults)
Creates a newConfigurationOptions
instance, with the specified 'copy defaults' setting set, and all other settings copied from this instance.- Parameters:
shouldCopyDefaults
- whether to copy defaults- Returns:
- updated options object
- Since:
- 4.0.0
- See Also:
for information on what this method does
-
implicitInitialization
public abstract boolean implicitInitialization()
Get whether values should be implicitly initialized.When this is true, any value get operations will return an empty value rather than null. This extends through to fields loaded into object-mapped classes.
This option is disabled by default
- Returns:
- if implicit initialization is enabled.
- Since:
- 4.0.0
-
implicitInitialization
public ConfigurationOptions implicitInitialization(boolean implicitInitialization)
Create a newConfigurationOptions
instance with the specified implicit initialization setting.- Parameters:
implicitInitialization
- whether to initialize implicitly- Returns:
- a new options object
- Since:
- 4.0.0
- See Also:
for more details
-
-