com.lonniepryor.blues.util
Class Types

java.lang.Object
  |
  +--com.lonniepryor.blues.util.Types

public abstract class Types
extends java.lang.Object

Specification interface for identifying types and classes. Instances of this class may be logically combined using the AND, OR, and NOT operations. Many common use-cases are supplied via static accessor methods.

Version:
$Revision: 1.1 $
Author:
Lonnie Pryor

Constructor Summary
protected Types()
          Creates a new Types object.
 
Method Summary
 Types and(Types specification)
          Returns a specification representing a logical AND of this specification on the left and the supplied specification on the right.
static Types arrays()
          Returns a specification matching array types.
static Types arraysOf(Types specification)
          Creates a new specification satisfied by array types whose component type matches the supplied specification.
static Types assignableFrom(java.lang.Class toTest)
          Creates a new specification satisfied by Types that are assignable from the supplied Class.
static Types assignableTo(java.lang.Class toTest)
          Creates a new specification satisfied by Types that are assignable to the supplied Class.
static Types classes()
          Returns a specification matching class types.
static Types declaredAbstract()
          Returns a specification matching abstract types.
static Types declaredConcrete()
          Returns a specification matching concrete types.
static Types declaredFinal()
          Returns a specification matching final types.
static Types declaredOn(Types specification)
          Creates a new specification satisfied only by Types declared on the Types that satisfy the supplied specification.
static Types declaredPackageProtected()
          Returns a specification matching package protected types.
static Types declaredPrivate()
          Returns a specification matching private types.
static Types declaredProtected()
          Returns a specification matching protected types.
static Types declaredPublic()
          Returns a specification matching public types.
static Types declaredStatic()
          Returns a specification matching static types.
static Types equalTo(java.lang.Class toTest)
          Creates a new specification satisfied by Types equal to the supplied Class.
abstract  boolean evaluate(java.lang.Class cls)
          Returns true if the supplied Class satisfies this specification.
static Types inheritingFrom(Types specification)
          Creates a new specification satisfied by Types that inherit from any Class that is satisfied by the supplied specification.
static Types interfaces()
          Returns a specification matching interface types.
 boolean isSatisfiedBy(java.lang.Class cls)
          Returns true if the supplied Class is not null and satisfies this specification.
 boolean isSatisifiedByAll(java.lang.Class[] all)
          Returns true if all of the supplied Types satisfy this specification.
 boolean isSatisifiedByAny(java.lang.Class[] any)
          Returns true if any of the supplied Types satisfy this specification.
static Types javaBeans()
          Returns a specification matching public classes that are valid JavaBeans.
static Types named(java.lang.String namePattern)
          Parses a pattern consisting of a dot-delimeted type name pattern.
static Types named(Strings specification)
          Creates a new specification satisfied by Types whose names match the supplied pattern.
 Types not()
          Returns a specification representing a logical NOT of this specification.
 Types or(Types specification)
          Returns a specification representing a logical OR of this specification on the left and the supplied specification on the right.
static Types parse(java.lang.String classPattern)
          Parses a pattern consisting of a dot-delimeted class name optionally followed by a '+' to match all subclasses, then a '[]' to match arrays.
static Types parseExpression(java.lang.String classPatternExpr)
          Parses a logical expression as described in the Expression class, using this class's parse() method for creating values.
static Types primitives()
          Returns a specification matching primitive types.
 java.lang.Class[] selectAll(java.lang.Class[] from)
          Selects all the Types that satisfy this specification from the supplied array.
 java.lang.Class selectFirst(java.lang.Class[] from)
          Selects the first Class that satisfies this specification from the supplied array.
static Types voids()
          Returns a specification matching the void type.
static Types withAConstructor(Constructors specification)
          Creates a new specification satisfied by Types that have at least one constructor matching the supplied specification.
static Types withADeclaredConstructor(Constructors specification)
          Creates a new specification satisfied by Types that have at least one declared constructor matching the supplied specification.
static Types withADeclaredField(Fields specification)
          Creates a new specification satisfied by Types that have at least one declared field matching the supplied specification.
static Types withADeclaredMethod(Methods specification)
          Creates a new specification satisfied by Types that have at least one declared method matching the supplied specification.
static Types withAField(Fields specification)
          Creates a new specification satisfied by Types that have at least one field matching the supplied specification.
static Types withAllConstructors(Constructors specification)
          Creates a new specification satisfied by Types that have all constructors matching the supplied specification.
static Types withAllDeclaredConstructors(Constructors specification)
          Creates a new specification satisfied by Types that have all declared constructors matching the supplied specification.
static Types withAllDeclaredConstructors(Fields specification)
          Creates a new specification satisfied by Types that have all declared fields matching the supplied specification.
static Types withAllDeclaredMethods(Methods specification)
          Creates a new specification satisfied by Types that have all declared methods matching the supplied specification.
static Types withAllFields(Fields specification)
          Creates a new specification satisfied by Types that have all fields matching the supplied specification.
static Types withAllMethods(Methods specification)
          Creates a new specification satisfied by Types that have all methods matching the supplied specification.
static Types withAMethod(Methods specification)
          Creates a new specification satisfied by Types that have at least one method matching the supplied specification.
static Types withAPublicNoArgCtor()
          Returns a specification matching classes with a public , no-arguments constructor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Types

protected Types()
Creates a new Types object.

Method Detail

voids

public static Types voids()
Returns a specification matching the void type.

Returns:
A specification matching the void type.

primitives

public static Types primitives()
Returns a specification matching primitive types.

Returns:
A specification matching primitive types.

arrays

public static Types arrays()
Returns a specification matching array types.

Returns:
A specification matching array types.

interfaces

public static Types interfaces()
Returns a specification matching interface types.

Returns:
A specification matching interface types.

classes

public static Types classes()
Returns a specification matching class types.

Returns:
A specification matching class types.

declaredPublic

public static Types declaredPublic()
Returns a specification matching public types.

Returns:
A specification matching public types.

declaredProtected

public static Types declaredProtected()
Returns a specification matching protected types.

Returns:
A specification matching protected types.

declaredPrivate

public static Types declaredPrivate()
Returns a specification matching private types.

Returns:
A specification matching private types.

declaredPackageProtected

public static Types declaredPackageProtected()
Returns a specification matching package protected types.

Returns:
A specification matching package protected types.

declaredAbstract

public static Types declaredAbstract()
Returns a specification matching abstract types.

Returns:
A specification matching abstract types.

declaredConcrete

public static Types declaredConcrete()
Returns a specification matching concrete types.

Returns:
A specification matching concrete types.

declaredFinal

public static Types declaredFinal()
Returns a specification matching final types.

Returns:
A specification matching final types.

declaredStatic

public static Types declaredStatic()
Returns a specification matching static types.

Returns:
A specification matching static types.

withAPublicNoArgCtor

public static Types withAPublicNoArgCtor()
Returns a specification matching classes with a public , no-arguments constructor.

Returns:
A specification matching classes with a public , no-arguments constructor.

javaBeans

public static Types javaBeans()
Returns a specification matching public classes that are valid JavaBeans.

Returns:
A specification matching public classes that are valid JavaBeans.

equalTo

public static Types equalTo(java.lang.Class toTest)
Creates a new specification satisfied by Types equal to the supplied Class.

Parameters:
toTest - The Class to be equal to.
Returns:
A new specification satisfied by Types equal to the supplied Class.

declaredOn

public static Types declaredOn(Types specification)
Creates a new specification satisfied only by Types declared on the Types that satisfy the supplied specification.

Parameters:
specification - The specification that Types must match.
Returns:
A new specification satisfied only by Types declared on the Types that satisfy the supplied specification.

named

public static Types named(java.lang.String namePattern)
Parses a pattern consisting of a dot-delimeted type name pattern. Example:
   com.lonniepryor..
 
The above matches any class in the 'com.lonniepryor' namespace.

Parameters:
namePattern - The pattern names must match.
Returns:
A new specification satisfied by Types whose names match the supplied pattern.
Throws:
ParseException - if the name pattern is invalid.

named

public static Types named(Strings specification)
Creates a new specification satisfied by Types whose names match the supplied pattern.

Parameters:
specification - The specification names must match.
Returns:
A new specification satisfied by Types whose names match the supplied pattern.

arraysOf

public static Types arraysOf(Types specification)
Creates a new specification satisfied by array types whose component type matches the supplied specification.

Parameters:
specification - The specification component types must match.
Returns:
A new specification satisfied by array types whose component type matches the supplied specification.

assignableFrom

public static Types assignableFrom(java.lang.Class toTest)
Creates a new specification satisfied by Types that are assignable from the supplied Class.

Parameters:
toTest - The Class to be assignable from.
Returns:
A new specification satisfied by Types that are assignable from the supplied Class.

assignableTo

public static Types assignableTo(java.lang.Class toTest)
Creates a new specification satisfied by Types that are assignable to the supplied Class.

Parameters:
toTest - The Class to be assignable to.
Returns:
A new specification satisfied by Types that are assignable to the supplied Class.

inheritingFrom

public static Types inheritingFrom(Types specification)
Creates a new specification satisfied by Types that inherit from any Class that is satisfied by the supplied specification.

Parameters:
specification - The specification to inherit from.
Returns:
A new specification satisfied by Types that inherit from to any Class that is satisfied by the supplied specification.

withAField

public static Types withAField(Fields specification)
Creates a new specification satisfied by Types that have at least one field matching the supplied specification.

Parameters:
specification - The specification to match fields to.
Returns:
A new specification satisfied by Types that have at least one field matching the supplied specification.

withADeclaredField

public static Types withADeclaredField(Fields specification)
Creates a new specification satisfied by Types that have at least one declared field matching the supplied specification.

Parameters:
specification - The specification to match fields to.
Returns:
A new specification satisfied by Types that have at least one declared field matching the supplied specification.

withAllFields

public static Types withAllFields(Fields specification)
Creates a new specification satisfied by Types that have all fields matching the supplied specification.

Parameters:
specification - The specification to match fields to.
Returns:
A new specification satisfied by Types that have all fields matching the supplied specification.

withAllDeclaredConstructors

public static Types withAllDeclaredConstructors(Fields specification)
Creates a new specification satisfied by Types that have all declared fields matching the supplied specification.

Parameters:
specification - The specification to match fields to.
Returns:
A new specification satisfied by Types that have all declared fields matching the supplied specification.

withAConstructor

public static Types withAConstructor(Constructors specification)
Creates a new specification satisfied by Types that have at least one constructor matching the supplied specification.

Parameters:
specification - The specification to match constructors to.
Returns:
A new specification satisfied by Types that have at least one constructor matching the supplied specification.

withADeclaredConstructor

public static Types withADeclaredConstructor(Constructors specification)
Creates a new specification satisfied by Types that have at least one declared constructor matching the supplied specification.

Parameters:
specification - The specification to match constructors to.
Returns:
A new specification satisfied by Types that have at least one declared constructor matching the supplied specification.

withAllConstructors

public static Types withAllConstructors(Constructors specification)
Creates a new specification satisfied by Types that have all constructors matching the supplied specification.

Parameters:
specification - The specification to match constructors to.
Returns:
A new specification satisfied by Types that have all constructors matching the supplied specification.

withAllDeclaredConstructors

public static Types withAllDeclaredConstructors(Constructors specification)
Creates a new specification satisfied by Types that have all declared constructors matching the supplied specification.

Parameters:
specification - The specification to match constructors to.
Returns:
A new specification satisfied by Types that have all declared constructors matching the supplied specification.

withAMethod

public static Types withAMethod(Methods specification)
Creates a new specification satisfied by Types that have at least one method matching the supplied specification.

Parameters:
specification - The specification to match methods to.
Returns:
A new specification satisfied by Types that have at least one method matching the supplied specification.

withADeclaredMethod

public static Types withADeclaredMethod(Methods specification)
Creates a new specification satisfied by Types that have at least one declared method matching the supplied specification.

Parameters:
specification - The specification to match methods to.
Returns:
A new specification satisfied by Types that have at least one declared method matching the supplied specification.

withAllMethods

public static Types withAllMethods(Methods specification)
Creates a new specification satisfied by Types that have all methods matching the supplied specification.

Parameters:
specification - The specification to match methods to.
Returns:
A new specification satisfied by Types that have all methods matching the supplied specification.

withAllDeclaredMethods

public static Types withAllDeclaredMethods(Methods specification)
Creates a new specification satisfied by Types that have all declared methods matching the supplied specification.

Parameters:
specification - The specification to match methods to.
Returns:
A new specification satisfied by Types that have all declared methods matching the supplied specification.

parse

public static Types parse(java.lang.String classPattern)
Parses a pattern consisting of a dot-delimeted class name optionally followed by a '+' to match all subclasses, then a '[]' to match arrays. Format:
    types         ::=  name-pattern [ "+" ] [ "[]" ]
    name-pattern  ::=  A '.'-delimeted TokenizedStrings pattern.
 
Example:
   com.lonniepryor..*+[]
 
The above matches arrays of any class inheriting from any class in the 'com.lonniepryor' namespace.

Parameters:
classPattern - The pattern definition string.
Returns:
A specification matching the pattern.
Throws:
ParseException - if the pattern is invalid.
See Also:
TokenizedStrings.parse(String, char)

parseExpression

public static Types parseExpression(java.lang.String classPatternExpr)
Parses a logical expression as described in the Expression class, using this class's parse() method for creating values.

Parameters:
classPatternExpr - The pattern expression definition string.
Returns:
A specification matching the pattern expression.
Throws:
ParseException - if the pattern expression is invalid.
See Also:
Expression, parse(String)

isSatisfiedBy

public final boolean isSatisfiedBy(java.lang.Class cls)
Returns true if the supplied Class is not null and satisfies this specification.

Parameters:
cls - The Class to test.
Returns:
True if the supplied Class is not null and satisfies this specification.

evaluate

public abstract boolean evaluate(java.lang.Class cls)
Returns true if the supplied Class satisfies this specification.

Returns:
True if the supplied Class satisfies this specification.

isSatisifiedByAll

public final boolean isSatisifiedByAll(java.lang.Class[] all)
Returns true if all of the supplied Types satisfy this specification.

Parameters:
all - The array of Types to test.
Returns:
True if all of the supplied Types satisfy this specification.

isSatisifiedByAny

public final boolean isSatisifiedByAny(java.lang.Class[] any)
Returns true if any of the supplied Types satisfy this specification.

Parameters:
any - The array of Types to test.
Returns:
True if any of the supplied Types satisfy this specification.

selectFirst

public final java.lang.Class selectFirst(java.lang.Class[] from)
Selects the first Class that satisfies this specification from the supplied array.

Parameters:
from - The array to select from.
Returns:
The first Class that satisfies this specification from the supplied array.

selectAll

public final java.lang.Class[] selectAll(java.lang.Class[] from)
Selects all the Types that satisfy this specification from the supplied array.

Parameters:
from - The array to select from.
Returns:
All the Types that satisfy this specification from the supplied array.

and

public final Types and(Types specification)
Returns a specification representing a logical AND of this specification on the left and the supplied specification on the right.

Parameters:
specification - The specification to AND with.
Returns:
A specification representing a logical AND of this specification on the left and the supplied specification on the right.

or

public final Types or(Types specification)
Returns a specification representing a logical OR of this specification on the left and the supplied specification on the right.

Parameters:
specification - The specification to OR with.
Returns:
A specification representing a logical OR of this specification on the left and the supplied specification on the right.

not

public final Types not()
Returns a specification representing a logical NOT of this specification.

Returns:
A specification representing a logical NOT of this specification.


Copyright © 2003 Blues Framework. All Rights Reserved.