Interface Key

    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      static <T extends Key>
      T
      checkAndGetIfValid​(T key)
      Checks if key passed as argument is not null and its value is not null as well.
      If not, throw a IllegalArgumentException, otherwise it returns the key.
      static void checkIfValid​(Key key)
      Checks if key passed as argument is not null and its value is not null as well.
      If not, throw a IllegalArgumentException.
      static int compare​(Key k1, Key k2)
      Compares the two specified key values.
      static Key create​(String key)
      Returns a key instance by its string value.
      static boolean equals​(Key k1, Key k2)
      Returns true if the keys have got the same value.
      static <T extends Key>
      T
      getKeyByValue​(T[] enumValues, String value)
      Returns a key in the an enumeration by the value.
      static <T extends Key>
      T
      getKeyByValue​(T[] enumValues, String value, T defaultKey)
      Returns a key in the an enumeration by the value, or the default key passed as argument.
      static <T extends Key>
      boolean
      hasKeyByValue​(T[] enumValues, String value)
      Returns true if a key in the an enumeration is related to the value, otherwise false.
      static boolean isValid​(Key key)
      Returns true if key passed as argument is not null and its value is not null as well.
      String value()
      Returns the name value of property
    • Method Detail

      • create

        static Key create​(String key)
        Returns a key instance by its string value.
        Parameters:
        key - string value to use
        Returns:
        a standard key instance
      • isValid

        static boolean isValid​(Key key)
        Returns true if key passed as argument is not null and its value is not null as well.
        Parameters:
        key - key to be checked
        Returns:
        true if key passed as argument is not null and its value is not null as well.
      • checkIfValid

        static void checkIfValid​(Key key)
        Checks if key passed as argument is not null and its value is not null as well.
        If not, throw a IllegalArgumentException.
        Parameters:
        key - key to be checked
      • checkAndGetIfValid

        static <T extends Key> T checkAndGetIfValid​(T key)
        Checks if key passed as argument is not null and its value is not null as well.
        If not, throw a IllegalArgumentException, otherwise it returns the key.
        Type Parameters:
        T - type of key
        Parameters:
        key - key to be checked
        Returns:
        the same key passed as argument
      • hasKeyByValue

        static <T extends Key> boolean hasKeyByValue​(T[] enumValues,
                                                     String value)
        Returns true if a key in the an enumeration is related to the value, otherwise false.
        Type Parameters:
        T - type of key
        Parameters:
        enumValues - enumeration values of keys
        value - value to search in the key
        Returns:
        true if a key in the an enumeration is related to the value, otherwise false
      • getKeyByValue

        static <T extends Key> T getKeyByValue​(T[] enumValues,
                                               String value)
        Returns a key in the an enumeration by the value.
        Type Parameters:
        T - type of key
        Parameters:
        enumValues - enumeration values of keys
        value - value to search in the key
        Returns:
        the found key by value or null
      • getKeyByValue

        static <T extends Key> T getKeyByValue​(T[] enumValues,
                                               String value,
                                               T defaultKey)
        Returns a key in the an enumeration by the value, or the default key passed as argument.
        Type Parameters:
        T - type of key
        Parameters:
        enumValues - enumeration values of keys
        value - value to search in the key
        defaultKey - default key instance if the value is not found
        Returns:
        the found key by value or the default one
      • compare

        static int compare​(Key k1,
                           Key k2)
        Compares the two specified key values.
        Parameters:
        k1 - the first key to compare
        k2 - the second key to compare
        Returns:
        the value 0 if k1 value is equal to k2; a value less than 0 if k1 value is less than k2; and a value greater than 0 if k1 value is greater than k2.
      • equals

        static boolean equals​(Key k1,
                              Key k2)
        Returns true if the keys have got the same value.
        Parameters:
        k1 - the first key to compare
        k2 - the second key to compare
        Returns:
        true if the keys have got the same value
      • value

        String value()
        Returns the name value of property
        Returns:
        the name value of property