gumbo.util
Class Types

java.lang.Object
  |
  +--gumbo.util.Types

public final class Types
extends java.lang.Object

Constants and utilities not related to a specific package class.

Version:
$Revision: 1.2 $
Author:
Jon Barrilleaux (jonb@jmbaai.com) of JMB and Associates Inc.

Method Summary
static boolean areAllInstanceOf(java.util.Collection targets, java.lang.Class type)
          Returns true if all target object types are the same or a subtype of (assignable to) a type.
static boolean areAnyAssignableTo(java.util.Collection targets, java.lang.Class type)
          Returns true if any one target type is the same or a subtype of (assignable to) a type.
static boolean areAnyAssignableToAny(java.util.Collection targets, java.util.Collection types)
          Returns true if any one target type is the same or a subtype of (assignable to) any one type.
static boolean areAnyInstanceOf(java.util.Collection targets, java.lang.Class types)
          Returns true if any one target object's type is the same or a subtype of (assignable to) a type.
static boolean areAnyInstanceOfAny(java.util.Collection targets, java.util.Collection types)
          Returns true if any one target object's type is the same or a subtype of (assignable to) any one type.
static java.util.Collection excludeAssignableTypes(java.util.Collection targets, java.util.Collection types, java.util.Collection retVal)
          Returns only those target objects whose type is NOT assignable to (an instance of) any one of the excluded types.
static java.util.Collection excludeExactTypes(java.util.Collection targets, java.util.Collection types, java.util.Collection retVal)
          Returns only those target objects whose type is NOT exactly one of the excluded types.
static java.util.Collection includeAssignableTypes(java.util.Collection targets, java.util.Collection types, java.util.Collection retVal)
          Returns only those target objects whose type is assignable to (an instance of) any one of the included types.
static java.util.Collection includeExactTypes(java.util.Collection targets, java.util.Collection types, java.util.Collection retVal)
          Returns only those target objects whose type is exactly one of the included types.
static boolean isAssignableTo(java.lang.Class target, java.lang.Class type)
          Returns true if a target type is the same or a subtype of (assignable to) a type.
static boolean isAssignableToAny(java.lang.Class target, java.util.Collection types)
          Returns true if a target type is the same or a subtype of (assignable to) any one type.
static boolean isInstanceOf(java.lang.Object target, java.lang.Class type)
          Returns true if a target object's type is the same or a subtype of (assignable to) a type.
static boolean isInstanceOfAny(java.lang.Object target, java.util.Collection types)
          Returns true if a target object's type is the same or a subtype of (assignable to) any one type.
static boolean isTypeExactlyAny(java.lang.Class target, java.util.Collection types)
          Returns true if a target type is exactly any one in a group of types.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isTypeExactlyAny

public static boolean isTypeExactlyAny(java.lang.Class target,
                                       java.util.Collection types)
Returns true if a target type is exactly any one in a group of types.

Parameters:
target - Target type. Never null.
types - Group of types (Class). If empty, returns false. Never null.
Returns:
True if the target is a valid type.

isAssignableTo

public static boolean isAssignableTo(java.lang.Class target,
                                     java.lang.Class type)
Returns true if a target type is the same or a subtype of (assignable to) a type. Convenience method for completeness. Forwards to Class.isAssignableFrom().

Parameters:
target - Target type. Never null.
type - The type. Never null.
Returns:
True if condition is met.

isAssignableToAny

public static boolean isAssignableToAny(java.lang.Class target,
                                        java.util.Collection types)
Returns true if a target type is the same or a subtype of (assignable to) any one type.

Parameters:
target - Target type. Never null.
types - The types (Class). Never null. If empty returns false.
Returns:
True if condition is met.

areAnyAssignableTo

public static boolean areAnyAssignableTo(java.util.Collection targets,
                                         java.lang.Class type)
Returns true if any one target type is the same or a subtype of (assignable to) a type.

Parameters:
targets - Target types (Class). Never null. If empty returns false.
type - The type. Never null.
Returns:
True if condition is met.

areAnyAssignableToAny

public static boolean areAnyAssignableToAny(java.util.Collection targets,
                                            java.util.Collection types)
Returns true if any one target type is the same or a subtype of (assignable to) any one type.

Parameters:
targets - Target types (Class). Never null. If empty returns false.
types - The types (Class). Never null. If empty returns false.
Returns:
True if condition is met.

isInstanceOf

public static boolean isInstanceOf(java.lang.Object target,
                                   java.lang.Class type)
Returns true if a target object's type is the same or a subtype of (assignable to) a type. Convenience method for completeness. Forwards to Class.isInstance().

Parameters:
target - Target object. Never null.
type - The type. Never null.
Returns:
True if condition is met.

isInstanceOfAny

public static boolean isInstanceOfAny(java.lang.Object target,
                                      java.util.Collection types)
Returns true if a target object's type is the same or a subtype of (assignable to) any one type.

Parameters:
target - Target object. Never null.
types - The types (Class). Never null. If empty returns false.
Returns:
True if condition is met.

areAnyInstanceOf

public static boolean areAnyInstanceOf(java.util.Collection targets,
                                       java.lang.Class types)
Returns true if any one target object's type is the same or a subtype of (assignable to) a type.

Parameters:
targets - Target objects (Object). Never null. If empty returns false.
Returns:
True if condition is met.

areAllInstanceOf

public static boolean areAllInstanceOf(java.util.Collection targets,
                                       java.lang.Class type)
Returns true if all target object types are the same or a subtype of (assignable to) a type.

Parameters:
targets - Target objects (Object). Never null. If empty returns false.
type - The type. Never null.
Returns:
True if condition is met.

areAnyInstanceOfAny

public static boolean areAnyInstanceOfAny(java.util.Collection targets,
                                          java.util.Collection types)
Returns true if any one target object's type is the same or a subtype of (assignable to) any one type.

Parameters:
targets - Target objects (Object). Never null. If empty returns false.
types - The types (Class). Never null. If empty returns false.
Returns:
True if condition is met.

includeExactTypes

public static java.util.Collection includeExactTypes(java.util.Collection targets,
                                                     java.util.Collection types,
                                                     java.util.Collection retVal)
Returns only those target objects whose type is exactly one of the included types.

Parameters:
targets - Group of target objects (Object). If empty, returns empty. Never null.
types - Group of included types (Class). If empty, returns empty. If null, all types are included (all targets are returned).
retVal - Return value object. The collection of valid target objects (Object). Can be targets. Never null.
Returns:
Reference to retVal. Never null.

excludeExactTypes

public static java.util.Collection excludeExactTypes(java.util.Collection targets,
                                                     java.util.Collection types,
                                                     java.util.Collection retVal)
Returns only those target objects whose type is NOT exactly one of the excluded types.

Parameters:
targets - Group of target objects (Object). If empty, returns empty. Never null.
types - Group of excluded types (Class). If empty, returns empty. If null, no types are excluded (all targets are returned).
retVal - Return value object. The collection of valid target objects (Object). Can be targets. Never null.
Returns:
Reference to retVal. Never null.

includeAssignableTypes

public static java.util.Collection includeAssignableTypes(java.util.Collection targets,
                                                          java.util.Collection types,
                                                          java.util.Collection retVal)
Returns only those target objects whose type is assignable to (an instance of) any one of the included types.

Parameters:
targets - Group of target objects (Object). If empty, returns empty. Never null.
types - Group of same/super types (Class) to include. If empty, returns empty. If null, all types are included (all targets are returned).
retVal - Return value object. The collection of valid target objects (Object). Can be targets. Never null.
Returns:
Reference to retVal. Never null.

excludeAssignableTypes

public static java.util.Collection excludeAssignableTypes(java.util.Collection targets,
                                                          java.util.Collection types,
                                                          java.util.Collection retVal)
Returns only those target objects whose type is NOT assignable to (an instance of) any one of the excluded types.

Parameters:
targets - Group of target objects (Object). If empty, returns empty. Never null.
types - Group of same/super types (Class) to exclude. If empty, returns empty. If null, no types are excluded (all targets are returned).
retVal - Return value object. The collection of valid target objects (Object). Never null.
Returns:
Reference to retVal. Never null.