Modifier and Type | Method and Description |
---|---|
static <T,R extends T> |
down(Class<R> aClass)
Converts an object to a stream of object if object can be cast to aClass or an empty stream otherwise.
|
static <X,T extends X> |
downTo(Class<T> aClass) |
static <X,T extends X> |
downTo(X o,
Class<T> aClass)
Should be used for casting down the hierarchy of classes.
|
static <R> Function<Object,Optional<R>> |
reinterpret(Class<R> aClass)
Returns a Function that narrows supplied arguments.
|
static <T> Optional<T> |
reinterpret(Object o,
Class<T> aClass)
|
public static <T> Optional<T> reinterpret(@Nullable Object o, @NotNull Class<T> aClass)
Object
to the type of the Class
. Using downTo(Object, Class)
is always preferred over using this method.
If object cannot be narrowed to the given type this method returns null
This is a non-throwing form of Class.cast(Object)
T
- the type to be narrowed too
- the object to be narrowed. This object can be a null referenceaClass
- the class to narrow to@NotNull public static <R> Function<Object,Optional<R>> reinterpret(@NotNull Class<R> aClass)
@NotNull public static <X,T extends X> Function<X,Optional<T>> downTo(@NotNull Class<T> aClass)
public static <X,T extends X> Optional<T> downTo(@Nullable X o, @NotNull Class<T> aClass)
Copyright © 2020 Atlassian Software Systems Pty Ltd. All rights reserved.