Modifier and Type | Method and Description |
---|---|
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)
Copyright © 2016 Atlassian Software Systems Pty Ltd. All rights reserved.