Interface Specializable<S>

    • Method Summary

      All Methods Instance Methods Default Methods 
      Modifier and Type Method Description
      default <T extends S>
      java.util.Optional<T>
      as​(java.lang.Class<T> type)
      Get this instance as a desired subtype.
    • Method Detail

      • as

        default <T extends S> java.util.Optional<T> as​(java.lang.Class<T> type)
        Get this instance as a desired subtype.

        If the instance is not castable to the specified type, the Optional will be empty.

        Type Parameters:
        T - The desired type.
        Parameters:
        type - The type as which to obtain this instance.
        Returns:
        Returns an Optional of this instance if it could be cast, otherwise an empty result.
        Throws:
        java.lang.NullPointerException - If the type is null.