public class Narrow extends Object
Class types
See to(Object, Class)| 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 <X,T extends X> |
iterableDownTo(Iterable<X> iterable,
Class<T> aClass)
Filters given Iterable returning only these objects which could be narrowed to given type.
|
static <T> Iterable<T> |
iterableTo(Iterable<?> iterable,
Class<T> aClass)
Filters given Iterable returning only these objects which could be narrowed to given type
|
static <T> T |
reinterpret(Object o,
Class<T> aClass)
|
static <T> T |
to(Object o,
Class<T> aClass)
|
@Nullable
public static <T> 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@Nullable
public static <T> T to(@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@Nullable
public static <X,T extends X> T downTo(@Nullable
X o,
@NotNull
Class<T> aClass)
to(Object, Class).public static <T> Iterable<T> iterableTo(@NotNull Iterable<?> iterable, @NotNull Class<T> aClass)
T - iterable - input iterable containing elements to filteraClass - class used to narrow elements of iterablepublic static <X,T extends X> Iterable<T> iterableDownTo(@NotNull Iterable<X> iterable, @NotNull Class<T> aClass)
iterableTo(Iterable, Class) and should be used when casting
down the class structure. (e.g. Listiterable - input iterable containing elements to filteraClass - class used to narrow elements of iterableCopyright © 2016 Atlassian Software Systems Pty Ltd. All rights reserved.