com.atlassian.bamboo.util
Class Narrow

java.lang.Object
  extended by com.atlassian.bamboo.util.Narrow

public class Narrow
extends java.lang.Object

Utility for narrowing object instances to Class types See to(Object, Class)

Since:
2.7

Method Summary
static
<T> java.lang.Iterable<T>
iterableTo(java.lang.Iterable<?> iterable, java.lang.Class<T> aClass)
          Filters given Iterable returning only these objects which could be narrowed to given type
static
<T> T
to(java.lang.Object o, java.lang.Class<T> aClass)
          Narrows the given Object to the type of the Class If object cannot be narrowed to the given type this method returns null This is a safe form of Class.cast(Object)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

to

@Nullable
public static <T> T to(@Nullable
                                java.lang.Object o,
                                @NotNull
                                java.lang.Class<T> aClass)
Narrows the given Object to the type of the Class If object cannot be narrowed to the given type this method returns null This is a safe form of Class.cast(Object)

Type Parameters:
T - the type to be narrowed to
Parameters:
o - the object to be narrowed. This object can be a null reference
aClass - the class to narrow to
Returns:
narrowed object

iterableTo

public static <T> java.lang.Iterable<T> iterableTo(@NotNull
                                                   java.lang.Iterable<?> iterable,
                                                   @NotNull
                                                   java.lang.Class<T> aClass)
Filters given Iterable returning only these objects which could be narrowed to given type

Type Parameters:
T -
Parameters:
iterable - input iterable containing elements to filter
aClass - class used to narrow elements of iterable
Returns:
filtered iterable with non-null elements narrowed to aClass


Copyright © 2011 Atlassian. All Rights Reserved.