Package org.geysermc.geyser.item.hashing
Class MapHasher<Type>
java.lang.Object
org.geysermc.geyser.item.hashing.MapHasher<Type>
- Type Parameters:
Type- the type thisMapHasherencodes.
-
Method Summary
Modifier and TypeMethodDescriptionaccept(String key, MinecraftHasher<Value> hasher, Function<Type, Value> extractor) Extracts aMapHasherfrom aMapHasherusing theextractor, then dispatches aMapBuilderfrom theMapHasherusing thebuilderDispatcher, and applies it to thisMapHasher, essentially adding the keys it defines here.accept(MapBuilder<Type> builder) Applies theMapBuilderto thisMapHasher, essentially adding all the keys it defines here.accept(MapBuilder<Value> builder, Function<Type, Value> extractor) Extracts aMapHasherfrom aMapHasherusing theextractor, and applies the givenMapBuilderfor it to thisMapHasher, essentially adding the keys it defines here.acceptConstant(String key, MinecraftHasher<Value> hasher, Value value) Adds a constantMapHasherto the map.acceptList(String key, MinecraftHasher<Value> valueHasher, Function<Type, List<Value>> extractor) com.google.common.hash.HashCodebuild()optional(String key, MinecraftHasher<Value> hasher, Function<Type, Value> extractor, Value defaultValue) optionalList(String key, MinecraftHasher<Value> valueHasher, Function<Type, List<Value>> extractor) optionalNullable(String key, MinecraftHasher<Value> hasher, Function<Type, Value> extractor) optionalPredicate(String key, MinecraftHasher<Value> hasher, Function<Type, Value> extractor, Predicate<Value> predicate)
-
Method Details
-
acceptConstant
public <Value> MapHasher<Type> acceptConstant(String key, MinecraftHasher<Value> hasher, Value value) Adds a constantMapHasherto the map. -
inlineNbt
-
accept
-
accept
Applies theMapBuilderto thisMapHasher, essentially adding all the keys it defines here. -
accept
Extracts aMapHasherfrom aMapHasherusing theextractor, and applies the givenMapBuilderfor it to thisMapHasher, essentially adding the keys it defines here.- Type Parameters:
Value- the type of the value.- Parameters:
builder- theMapBuilderthat encodes aMapHasher.extractor- the function that extracts aMapHasherfrom aMapHasher.
-
accept
public <Value> MapHasher<Type> accept(Function<Type, Value> extractor, Function<Value, MapBuilder<Type>> builderDispatcher) Extracts aMapHasherfrom aMapHasherusing theextractor, then dispatches aMapBuilderfrom theMapHasherusing thebuilderDispatcher, and applies it to thisMapHasher, essentially adding the keys it defines here.- Type Parameters:
Value- the type of the value.- Parameters:
extractor- the function that extracts aMapHasherfrom aMapHasher.builderDispatcher- the function that dispatches aMapBuilderfrom aMapHasher.
-
optionalNullable
public <Value> MapHasher<Type> optionalNullable(String key, MinecraftHasher<Value> hasher, Function<Type, Value> extractor) -
optional
public <Value> MapHasher<Type> optional(String key, MinecraftHasher<Value> hasher, Function<Type, Optional<Value>> extractor) -
optional
public <Value> MapHasher<Type> optional(String key, MinecraftHasher<Value> hasher, Function<Type, Value> extractor, Value defaultValue) Extracts aMapHasherfrom aMapHasherusing theextractor, and adds it to the map if it's not equal todefaultValue.- Type Parameters:
Value- the type of the value.- Parameters:
key- the key to put theMapHasherin.hasher- the hasher used to hash aMapHasher.extractor- the function that extracts aMapHasherfrom aMapHasher.defaultValue- the defaultMapHasher. TheMapHasherwon't be added to the map if it equals the default.
-
optionalPredicate
public <Value> MapHasher<Type> optionalPredicate(String key, MinecraftHasher<Value> hasher, Function<Type, Value> extractor, Predicate<Value> predicate) Extracts aMapHasherfrom aMapHasherusing theextractor, and adds it to the map only ifpredicatereturnstruefor it.- Type Parameters:
Value- the type of the value.- Parameters:
key- the key to put theMapHasherin.hasher- the hasher used to hash aMapHasher.extractor- the function that extracts aMapHasherfrom aMapHasher.predicate- the predicate that checks if aMapHashershould be added to the map. TheMapHasherwon't be added to the map if the predicate returnsfalsefor it.
-
acceptList
-
optionalList
-
build
public com.google.common.hash.HashCode build()
-