Class Key<T>

  • Type Parameters:
    T - Type of the object returned by the Value identified by this Key.
    Direct Known Subclasses:
    PlaceholderKey

    public class Key<T>
    extends java.lang.Object
    Identifier used for storing and fetching data from DataContainers.
    • Constructor Summary

      Constructors 
      Constructor Description
      Key​(Type<T> type, java.lang.String keyName)  
      Key​(java.lang.Class<T> type, java.lang.String keyName)
      Create a new key.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      java.lang.String getKeyName()
      Get the name (identifier) of the Key.
      Type<T> getType()
      Get the type of the key.
      int hashCode()  
      T typeCast​(java.lang.Object object)
      Cast an object to the type of the key.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Key

        public Key​(java.lang.Class<T> type,
                   java.lang.String keyName)
        Create a new key.

        Example usage: Key<String> key = new Key(String.class, "identifier");

        (In Keys class) public static final Key<String> IDENTIFIER = new Key(String.class, "identifier"); Key<String> key = Keys.IDENTIFIER;

        Parameters:
        type - Class with type of the Object returned by the Value identified by this Key.
        keyName - Name (identifier) of the Key.
      • Key

        public Key​(Type<T> type,
                   java.lang.String keyName)
    • Method Detail

      • getType

        public Type<T> getType()
        Get the type of the key.
        Returns:
        specified in constructor.
      • getKeyName

        public java.lang.String getKeyName()
        Get the name (identifier) of the Key.
        Returns:
        For example "nickname"
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • typeCast

        public T typeCast​(java.lang.Object object)
        Cast an object to the type of the key.
        Parameters:
        object - Object to cast.
        Returns:
        The object with the type of T.