Package ninja.leaping.configurate
Class ConfigurationOptions
java.lang.Object
ninja.leaping.configurate.ConfigurationOptions
public 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 that is located in ConfigurationLoader
s.
This class is immutable.
-
Method Summary
Modifier and Type Method Description boolean
acceptsType(@NonNull Class<?> type)
Gets whether objects of the provided type are accepted as values for nodes with this as their options object.static @NonNull ConfigurationOptions
defaults()
Get the default set of options.boolean
equals(Object o)
@Nullable String
getHeader()
Gets the header specified in these options.@NonNull MapFactory
getMapFactory()
Gets theMapFactory
specified in these options.@NonNull ObjectMapperFactory
getObjectMapperFactory()
Gets theObjectMapperFactory
specified in these options.@NonNull TypeSerializerCollection
getSerializers()
Gets theTypeSerializerCollection
specified in these options.int
hashCode()
@NonNull ConfigurationOptions
setAcceptedTypes(@Nullable Set<Class<?>> acceptedTypes)
Deprecated.@NonNull ConfigurationOptions
setHeader(@Nullable String header)
Creates a newConfigurationOptions
instance, with the specified header set, and all other settings copied from this instance.@NonNull ConfigurationOptions
setMapFactory(@NonNull MapFactory mapFactory)
Deprecated.USewithMapFactory(MapFactory)
instead@NonNull ConfigurationOptions
setObjectMapperFactory(@NonNull ObjectMapperFactory objectMapperFactory)
Deprecated.UsewithObjectMapperFactory(ObjectMapperFactory)
instead@NonNull ConfigurationOptions
setSerializers(@NonNull TypeSerializerCollection serializers)
Deprecated.UsewithSerializers(TypeSerializerCollection)
instead@NonNull ConfigurationOptions
setShouldCopyDefaults(boolean shouldCopyDefaults)
Deprecated.boolean
shouldCopyDefaults()
Gets whether or not default parameters provided toConfigurationNode
getter methods should be set to the node when used.String
toString()
@NonNull ConfigurationOptions
withHeader(@Nullable String header)
Creates a newConfigurationOptions
instance, with the specified header set, and all other settings copied from this instance.@NonNull ConfigurationOptions
withMapFactory(@NonNull MapFactory mapFactory)
Creates a newConfigurationOptions
instance, with the specifiedMapFactory
set, and all other settings copied from this instance.@NonNull ConfigurationOptions
withNativeTypes(@Nullable Set<Class<?>> acceptedTypes)
Creates a newConfigurationOptions
instance, with the specified native types set, and all other settings copied from this instance.@NonNull ConfigurationOptions
withObjectMapperFactory(@NonNull ObjectMapperFactory objectMapperFactory)
Creates a newConfigurationOptions
instance, with the specifiedObjectMapperFactory
set, and all other settings copied from this instance.@NonNull ConfigurationOptions
withSerializers(@NonNull Consumer<TypeSerializerCollection> serializerBuilder)
Creates a newConfigurationOptions
instance, with a newTypeSerializerCollection
created as a child of this options' current collection.@NonNull ConfigurationOptions
withSerializers(@NonNull TypeSerializerCollection serializers)
Creates a newConfigurationOptions
instance, with the specifiedTypeSerializerCollection
set, and all other settings copied from this instance.@NonNull ConfigurationOptions
withShouldCopyDefaults(boolean shouldCopyDefaults)
Creates a newConfigurationOptions
instance, with the specified 'copy defaults' setting set, and all other settings copied from this instance.
-
Method Details
-
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
-
getMapFactory
Gets theMapFactory
specified in these options.- Returns:
- The map factory
-
setMapFactory
Deprecated.USewithMapFactory(MapFactory)
insteadCreates 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
-
withMapFactory
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
-
getHeader
Gets the header specified in these options.- Returns:
- The current header. Lines are split by \n,
-
setHeader
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
-
withHeader
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
-
getSerializers
Gets theTypeSerializerCollection
specified in these options.- Returns:
- The type serializers
-
setSerializers
@Deprecated public @NonNull ConfigurationOptions setSerializers(@NonNull TypeSerializerCollection serializers)Deprecated.UsewithSerializers(TypeSerializerCollection)
insteadCreates 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
-
withSerializers
public @NonNull ConfigurationOptions withSerializers(@NonNull 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
-
withSerializers
public @NonNull ConfigurationOptions withSerializers(@NonNull Consumer<TypeSerializerCollection> 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
-
getObjectMapperFactory
Gets theObjectMapperFactory
specified in these options.- Returns:
- The factory used to construct ObjectMapper instances
-
setObjectMapperFactory
@Deprecated public @NonNull ConfigurationOptions setObjectMapperFactory(@NonNull ObjectMapperFactory objectMapperFactory)Deprecated.UsewithObjectMapperFactory(ObjectMapperFactory)
insteadCreates a newConfigurationOptions
instance, with the specifiedObjectMapperFactory
set, and all other settings copied from this instance.- Parameters:
objectMapperFactory
- The factory to use to produce object mapper instances. Must not be null- Returns:
- updated options object
-
withObjectMapperFactory
public @NonNull ConfigurationOptions withObjectMapperFactory(@NonNull ObjectMapperFactory objectMapperFactory)Creates a newConfigurationOptions
instance, with the specifiedObjectMapperFactory
set, and all other settings copied from this instance.- Parameters:
objectMapperFactory
- The factory to use to produce object mapper instances. Must not be null- Returns:
- updated options object
-
acceptsType
Gets whether objects of the provided type are accepted as values for nodes with this as their options object.- Parameters:
type
- The type to check- Returns:
- Whether the type is accepted
-
setAcceptedTypes
@Deprecated public @NonNull ConfigurationOptions setAcceptedTypes(@Nullable Set<Class<?>> acceptedTypes)Deprecated.UsewithNativeTypes(Set)
insteadCreates a newConfigurationOptions
instance, with the specified accepted types set, and all other settings copied from this instance.'Accepted types' are types which are accepted as native values for the configuration.
Null indicates that all types are accepted.
- Parameters:
acceptedTypes
- The types that will be accepted to a call toConfigurationNode.setValue(Object)
- Returns:
- updated options object
-
withNativeTypes
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. Setting this may result in unexpected changes to values
- Parameters:
acceptedTypes
- The types that will be accepted to a call toConfigurationNode.setValue(Object)
- Returns:
- updated options object
-
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
-
setShouldCopyDefaults
Deprecated.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
- See Also:
for information on what this method does
-
withShouldCopyDefaults
Creates a newConfigurationOptions
instance, with the specified 'copy defaults' setting set, and all other settings copied from this instance.- Parameters:
shouldCopyDefaults
- wether to copy defaults- Returns:
- updated options object
- See Also:
for information on what this method does
-
equals
-
hashCode
-
toString
-
withNativeTypes(Set)
instead