Interface ToEnumNullable<T,​E extends Enum<E>>

    • Method Detail

      • of

        static <T,​E extends Enum<E>> ToEnumNullable<T,​E> of​(Class<E> enumClass,
                                                                        Function<T,​E> lambda)
        Returns a typed ToEnumNullable<T> using the provided lambda.
        Type Parameters:
        T - type to extract from
        E - enum type
        Parameters:
        lambda - to convert
        enumClass - class for the enum
        Returns:
        a typed ToEnumNullable<T> using the provided lambda
        Throws:
        NullPointerException - if the provided lambda is null
      • enumClass

        Class<E> enumClass()
        Returns the class of the enum that this expression returns.
        Returns:
        the enum class
      • expressionType

        default ExpressionType expressionType()
        Description copied from interface: Expression
        Returns the expression type of this expression. It should be safe to cast this instance into the corresponding interface.
        Specified by:
        expressionType in interface Expression<T>
        Returns:
        the expression type
      • asOrdinal

        default ToIntNullable<T> asOrdinal()
        Returns an alternative expression that represents the Enum.ordinal() of the enum that would otherwise have been returned by this expression.

        If this expression would have returned null, then the new expression will also evaluate to null.

        Returns:
        the ordinal expression
      • asName

        default ToStringNullable<T> asName()
        Returns an alternative expression that represents the Enum.name() of the enum that would otherwise have been returned by this expression.

        If this expression would have returned null, then the new expression will also evaluate to null.

        Returns:
        the name expression
      • orThrow

        default ToEnum<T,​E> orThrow()
        Description copied from interface: ToNullable
        Returns an equivalent expression as this, except that it will throw a NullPointerException if given an argument that would cause this expression to return null.
        Specified by:
        orThrow in interface ToNullable<T,​E extends Enum<E>,​ToEnum<T,​E extends Enum<E>>>
        Returns:
        the expression if present
      • orElseGet

        default ToEnum<T,​E> orElseGet​(ToEnum<T,​E> getter)
        Description copied from interface: ToNullable
        Returns an equivalent expression as this, except that it will return the getter expression if given an argument that would cause this expression to return null.
        Specified by:
        orElseGet in interface ToNullable<T,​E extends Enum<E>,​ToEnum<T,​E extends Enum<E>>>
        Parameters:
        getter - to apply if null
        Returns:
        the expression if present, otherwise return getter
      • orElse

        default ToEnum<T,​E> orElse​(E value)
        Description copied from interface: ToNullable
        Returns an equivalent expression as this, except that it will return the value if given an argument that would cause this expression to return null.
        Specified by:
        orElse in interface ToNullable<T,​E extends Enum<E>,​ToEnum<T,​E extends Enum<E>>>
        Parameters:
        value - value to use if null
        Returns:
        the expression if present, otherwise return value
      • mapToDoubleIfPresent

        default ToDoubleNullable<T> mapToDoubleIfPresent​(ToDoubleFunction<E> mapper)
        Description copied from interface: HasMapToDoubleIfPresent
        Maps the result of this expression into a double by passing it to the specified mapper, producing a new expression that implements ToDouble. If this expression would have evaluated to null, then the new expression will as well.
        Specified by:
        mapToDoubleIfPresent in interface HasMapToDoubleIfPresent<T,​E extends Enum<E>>
        Parameters:
        mapper - the mapper to use on the result of this expression
        Returns:
        the new mapped expression
      • hash

        default long hash​(T object)
        Description copied from interface: HasHash
        Hash the specified object into a 64-bit hash. If two equal objects are hashed, they must always result in the same hash. However, objects that are not equal may also result in the same hash.
        Specified by:
        hash in interface HasHash<T>
        Parameters:
        object - the object to hash
        Returns:
        the 64-bit hashcode
      • compose

        default <V> ToEnumNullable<V,​E> compose​(Function<? super V,​? extends T> before)
        Description copied from interface: HasCompose
        Returns a composed expression that first applies the before function to its input, and then applies this function to the result. If evaluation of either function throws an exception, it is relayed to the caller of the composed function.
        Specified by:
        compose in interface Function<T,​E extends Enum<E>>
        Specified by:
        compose in interface HasCompose<T>
        Type Parameters:
        V - the type of input to the before function, and to the composed expression
        Parameters:
        before - the function to apply before this function is applied
        Returns:
        a composed function that first applies the before function and then applies this function