Interface KeyGetter<S,​K,​V>

  • Type Parameters:
    S - storage type
    K - key type
    V - value type
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface KeyGetter<S,​K,​V>
    Gets a possible value from storage at a specified key.
    • Method Detail

      • maybe

        static <S,​K,​V> KeyGetter<S,​K,​V> maybe​(BiFunction<S,​K,​@NullOr V> getter)
        Converts a direct key getter into an optional key getter.
        Type Parameters:
        S - storage type
        K - key type
        V - value type
        Parameters:
        getter - direct key getter
        Returns:
        the direct getter wrapped by an optional
      • get

        Optional<V> get​(S storage,
                        K key)
        Gets a possible value from storage at the specified key.
        Parameters:
        storage - storage that may contain the value
        key - the key
        Returns:
        the value if it was successfully retrieved, otherwise empty