Class MapHasher<Type>
java.lang.Object
com.zenith.mc.item.hashing.MapHasher<Type>
- Type Parameters:
Type- the type thisMapHasherencodes.
-
Method Summary
Modifier and TypeMethodDescriptionaccept(MapBuilder<Type> builder) Applies theMapBuilderto thisMapHasher, essentially adding all the keys it defines here.accept(MapBuilder<Value> builder, Function<Type, Value> extractor) Extracts aValuefrom aTypeusing theextractor, and applies the givenMapBuilderfor it to thisMapHasher, essentially adding the keys it defines here.accept(String key, MinecraftHasher<Value> hasher, Function<Type, Value> extractor) Extracts aValuefrom aTypeusing theextractor, then dispatches aMapBuilderfrom theValueusing thebuilderDispatcher, and applies it to thisMapHasher, essentially adding the keys it defines here.acceptConstant(String key, MinecraftHasher<Value> hasher, Value value) Adds a constantValueto 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
-
accept
-
accept
Applies theMapBuilderto thisMapHasher, essentially adding all the keys it defines here. -
accept
Extracts aValuefrom aTypeusing 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 aValue.extractor- the function that extracts aValuefrom aType.
-
accept
public <Value> MapHasher<Type> accept(Function<Type, Value> extractor, Function<Value, MapBuilder<Type>> builderDispatcher) Extracts aValuefrom aTypeusing theextractor, then dispatches aMapBuilderfrom theValueusing 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 aValuefrom aType.builderDispatcher- the function that dispatches aMapBuilderfrom aValue.
-
optionalNullable
-
optional
-
optional
-
optionalPredicate
public <Value> MapHasher<Type> optionalPredicate(String key, MinecraftHasher<Value> hasher, Function<Type, Value> extractor, Predicate<Value> predicate) Extracts aValuefrom aTypeusing theextractor, and adds it to the map only ifpredicatereturnstruefor it.- Type Parameters:
Value- the type of the value.- Parameters:
key- the key to put theValuein.hasher- the hasher used to hash aValue.extractor- the function that extracts aValuefrom aType.predicate- the predicate that checks if aValueshould be added to the map. TheValuewon't be added to the map if the predicate returnsfalsefor it.
-
acceptList
-
optionalList
-
build
public com.google.common.hash.HashCode build()
-