Class StructuredDataContainer
java.lang.Object
com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer
-
Constructor Summary
ConstructorsConstructorDescriptionStructuredDataContainer
(StructuredData<?>[] dataArray) StructuredDataContainer
(Map<StructuredDataKey<?>, StructuredData<?>> data) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addEmpty
(StructuredDataKey<?> key) <T> StructuredData<T>
computeIfAbsent
(StructuredDataKey<T> key, Function<StructuredDataKey<T>, T> mappingFunction) Returns structured data by id if not empty, or creates it.boolean
contains
(StructuredDataKey<?> key) copy()
Map<StructuredDataKey<?>,
StructuredData<?>> data()
<T> @Nullable StructuredData<T>
get
(StructuredDataKey<T> key) Returns structured data by id if present.<T> @Nullable StructuredData<T>
getNonEmpty
(StructuredDataKey<T> key) Returns structured data by id if not empty.<T> @Nullable StructuredData<T>
remove
(StructuredDataKey<T> key) Removes and returns structured data by the given key.<T,
V> void replace
(StructuredDataKey<T> key, StructuredDataKey<V> toKey, Function<T, V> valueMapper) <T> void
replaceKey
(StructuredDataKey<T> key, StructuredDataKey<T> toKey) void
set
(StructuredDataKey<Unit> key) <T> void
set
(StructuredDataKey<T> key, T value) void
setIdLookup
(Protocol<?, ?, ?, ?> protocol, boolean mappedNames) Sets the lookup for serializer ids.toString()
void
<T> @Nullable StructuredData<T>
updateIfPresent
(StructuredDataKey<T> key, Function<T, T> mappingFunction) Updates and returns the structured data by id if not empty.
-
Constructor Details
-
StructuredDataContainer
-
StructuredDataContainer
-
StructuredDataContainer
public StructuredDataContainer()
-
-
Method Details
-
get
Returns structured data by id if present.- Type Parameters:
T
- data type- Parameters:
key
- serializer id- Returns:
- structured data
-
getNonEmpty
Returns structured data by id if not empty.- Type Parameters:
T
- data type- Parameters:
key
- serializer id- Returns:
- structured data if not empty
-
computeIfAbsent
public <T> StructuredData<T> computeIfAbsent(StructuredDataKey<T> key, Function<StructuredDataKey<T>, T> mappingFunction) Returns structured data by id if not empty, or creates it.- Type Parameters:
T
- data type- Parameters:
key
- serializer idmappingFunction
- function to create structured data if not present- Returns:
- structured data if not empty
-
updateIfPresent
public <T> @Nullable StructuredData<T> updateIfPresent(StructuredDataKey<T> key, Function<T, T> mappingFunction) Updates and returns the structured data by id if not empty.- Type Parameters:
T
- data type- Parameters:
key
- serializer idmappingFunction
- function to update existing data- Returns:
- updated structured data if not empty
-
set
-
replaceKey
-
replace
public <T,V> void replace(StructuredDataKey<T> key, StructuredDataKey<V> toKey, Function<T, V> valueMapper) -
set
-
addEmpty
-
remove
Removes and returns structured data by the given key.- Type Parameters:
T
- data type- Parameters:
key
- serializer key- Returns:
- removed structured data
-
contains
-
setIdLookup
Sets the lookup for serializer ids. Required to call most of the other methods.- Parameters:
protocol
- protocol to retreive the id of the serializer frommappedNames
- if the names are mapped (true if structures from the mapped version are added, false for the unmapped version)
-
updateIds
public void updateIds(Protocol<?, ?, ?, ?> protocol, it.unimi.dsi.fastutil.ints.Int2IntFunction rewriter) -
copy
-
data
-
toString
-