Package net.orbyfied.j8.registry
Class RegistryComponent<R extends Registry<T>,T extends Identifiable,K,V>
java.lang.Object
net.orbyfied.j8.registry.RegistryComponent<R,T,K,V>
- Type Parameters:
R- The type of registry.T- The type of base item.K- The keys it stores (for mapping).V- The values it stores (mapping and linear).
public abstract class RegistryComponent<R extends Registry<T>,T extends Identifiable,K,V>
extends Object
An extension to a registry.
Allows for more complex storage of items.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the item to key factory.getKeyFromValue(V val) Utilizes the value to key factory to get the key from the provided value.Returns the value to key factory.Utilizes the item to key factory to get the key of the provided item.Gets the runtime key type of the storage.abstract VgetLinear(int index) Gets the value at the given index.abstract VGets the value mapped to the given key.Gets the value corresponding with the given item.Gets the registry this component has been assigned to.Returns the item to value factory.getValueOf(T t) Utilizes the item to value factory to get the value of the provided item.Gets the runtime value type of the storage.abstract booleanisLinear()Gets if the storage is linear, so if it is stored in an ordered list.abstract booleanisMapped()Gets if the storage is mapped, so if it is stored in a quick lookup map.Utilizes the value factory in the default implementation.abstract RegistryComponent<R,T, K, V> Registers a value to the storage.abstract RegistryComponent<R,T, K, V> unregister(K key) Unregisters a key from the storage.unregister(T item) Utilizes the key factory in the default implementation.
-
Field Details
-
registry
The registry this module is applied to. -
keyFactory
-
valFactory
-
valKeyFactory
-
-
Constructor Details
-
RegistryComponent
Constructor.
-
-
Method Details
-
getRegistry
Gets the registry this component has been assigned to.- Returns:
- The registry reference.
-
getKeyType
Gets the runtime key type of the storage.- Returns:
- The key type.
-
getValueType
Gets the runtime value type of the storage.- Returns:
- The value type.
-
isLinear
public abstract boolean isLinear()Gets if the storage is linear, so if it is stored in an ordered list.- Returns:
- If it is.
-
isMapped
public abstract boolean isMapped()Gets if the storage is mapped, so if it is stored in a quick lookup map.- Returns:
- If it is.
-
getKeyFactory
Returns the item to key factory.- Returns:
- The function.
-
getValueFactory
Returns the item to value factory.- Returns:
- The function.
-
getKeyFromValueFactory
Returns the value to key factory.- Returns:
- The function.
-
getKeyFromValue
Utilizes the value to key factory to get the key from the provided value.- Parameters:
val- The value.- Returns:
- The key.
-
getValueOf
Utilizes the item to value factory to get the value of the provided item.- Parameters:
t- The item.- Returns:
- The value.
-
getKeyOf
Utilizes the item to key factory to get the key of the provided item.- Parameters:
t- The item.- Returns:
- The key.
-
getLinear
Gets the value at the given index.- Parameters:
index- The index to use.- Returns:
- The value.
- Throws:
UnsupportedOperationException- Might be thrown by an implementation if linear storage is not supported. CheckisLinear()
-
getMapped
Gets the value mapped to the given key.- Parameters:
key- The key to look up.- Returns:
- The value or null.
- Throws:
UnsupportedOperationException- Might be thrown by an implementation if mapped storage is not supported. CheckisMapped()
-
getMapped
Gets the value corresponding with the given item.- Parameters:
key- The item.- Returns:
- The value.
- See Also:
-
register
Registers a value to the storage. Should utilize the key factory to get the key for mapping.- Parameters:
value- The value to register.- Returns:
- This.
-
register
Utilizes the value factory in the default implementation.- See Also:
-
unregister
Unregisters a key from the storage. Should utilize the key factory to get the key for mapping.- Parameters:
key- The key to unregister.- Returns:
- This.
-
unregister
Utilizes the key factory in the default implementation.- See Also:
-