Class ConfigurateOps
- java.lang.Object
-
- org.spongepowered.configurate.extra.dfu.v2.ConfigurateOps
-
- All Implemented Interfaces:
DynamicOps<ConfigurationNode>
public final class ConfigurateOps extends Object implements DynamicOps<ConfigurationNode>
Implementation of DataFixerUpper's DynamicOps.When possible, the first node's
ConfigurationNode.copy()
method will be used to create a new node to contain results. Otherwise, the provided factory will be used. The default factory creates aCommentedConfigurationNode
with thedefault TypeSerializer collection
, but a custom factory may be provided.- Since:
- 4.0.0
-
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.mojang.datafixers.types.DynamicOps
cast, createByte, createByteList, createDouble, createFloat, createInt, createIntList, createLong, createLongList, createShort, emptyList, emptyMap, getByteBuffer, getIntStream, getLongStream, getNumberValue
-
-
-
-
Method Detail
-
instance
public static DynamicOps<ConfigurationNode> instance()
Get the shared instance of this class, which creates new nodes using the default factory.- Returns:
- the shared instance
- Since:
- 4.0.0
-
withNodeFactory
public static DynamicOps<ConfigurationNode> withNodeFactory(Supplier<? extends ConfigurationNode> factory)
Create a new instance of the ops, with a custom node factory.- Parameters:
factory
- the factory function- Returns:
- a new ops instance
- Since:
- 4.0.0
-
wrap
public static Dynamic<ConfigurationNode> wrap(ConfigurationNode node)
Wrap a ConfigurationNode in aDynamic
instance. The returned Dynamic will use the same type serializer collection as the original node for its operations.- Parameters:
node
- the node to wrap- Returns:
- a wrapped node
- Since:
- 4.0.0
-
empty
public ConfigurationNode empty()
- Specified by:
empty
in interfaceDynamicOps<ConfigurationNode>
-
getType
public Type<?> getType(ConfigurationNode input)
- Specified by:
getType
in interfaceDynamicOps<ConfigurationNode>
-
getNumberValue
public Optional<Number> getNumberValue(ConfigurationNode input)
- Specified by:
getNumberValue
in interfaceDynamicOps<ConfigurationNode>
-
createNumeric
public ConfigurationNode createNumeric(Number i)
- Specified by:
createNumeric
in interfaceDynamicOps<ConfigurationNode>
-
createBoolean
public ConfigurationNode createBoolean(boolean value)
- Specified by:
createBoolean
in interfaceDynamicOps<ConfigurationNode>
-
getStringValue
public Optional<String> getStringValue(ConfigurationNode input)
- Specified by:
getStringValue
in interfaceDynamicOps<ConfigurationNode>
-
createString
public ConfigurationNode createString(String value)
- Specified by:
createString
in interfaceDynamicOps<ConfigurationNode>
-
mergeInto
public ConfigurationNode mergeInto(ConfigurationNode input, ConfigurationNode value)
- Specified by:
mergeInto
in interfaceDynamicOps<ConfigurationNode>
-
mergeInto
public ConfigurationNode mergeInto(ConfigurationNode input, ConfigurationNode key, ConfigurationNode value)
- Specified by:
mergeInto
in interfaceDynamicOps<ConfigurationNode>
-
merge
public ConfigurationNode merge(ConfigurationNode first, ConfigurationNode second)
Merge into a newly created node.- Specified by:
merge
in interfaceDynamicOps<ConfigurationNode>
- Parameters:
first
- the primary nodesecond
- the second node, with values that will override those in the first node- Returns:
- a newly created node
-
getMapValues
public Optional<Map<ConfigurationNode,ConfigurationNode>> getMapValues(ConfigurationNode input)
- Specified by:
getMapValues
in interfaceDynamicOps<ConfigurationNode>
-
createMap
public ConfigurationNode createMap(Map<ConfigurationNode,ConfigurationNode> map)
- Specified by:
createMap
in interfaceDynamicOps<ConfigurationNode>
-
getStream
public Optional<Stream<ConfigurationNode>> getStream(ConfigurationNode input)
- Specified by:
getStream
in interfaceDynamicOps<ConfigurationNode>
-
createList
public ConfigurationNode createList(Stream<ConfigurationNode> input)
- Specified by:
createList
in interfaceDynamicOps<ConfigurationNode>
-
remove
public ConfigurationNode remove(ConfigurationNode input, String key)
- Specified by:
remove
in interfaceDynamicOps<ConfigurationNode>
-
get
public Optional<ConfigurationNode> get(ConfigurationNode input, String key)
- Specified by:
get
in interfaceDynamicOps<ConfigurationNode>
-
getGeneric
public Optional<ConfigurationNode> getGeneric(ConfigurationNode input, ConfigurationNode key)
- Specified by:
getGeneric
in interfaceDynamicOps<ConfigurationNode>
-
set
public ConfigurationNode set(ConfigurationNode input, String key, ConfigurationNode value)
- Specified by:
set
in interfaceDynamicOps<ConfigurationNode>
-
update
public ConfigurationNode update(ConfigurationNode input, String key, Function<ConfigurationNode,ConfigurationNode> function)
- Specified by:
update
in interfaceDynamicOps<ConfigurationNode>
-
updateGeneric
public ConfigurationNode updateGeneric(ConfigurationNode input, ConfigurationNode wrappedKey, Function<ConfigurationNode,ConfigurationNode> function)
- Specified by:
updateGeneric
in interfaceDynamicOps<ConfigurationNode>
-
-