com.lonniepryor.blues.util
Class Methods

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

public abstract class Methods
extends java.lang.Object

Specification interface for identifying Methods. 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:
1.0
Author:
Lonnie Pryor

Constructor Summary
protected Methods()
          Creates a new Methods object.
 
Method Summary
 Methods and(Methods specification)
          Returns a specification representing a logical AND of this specification on the left and the supplied specification on the right.
static Methods declaredAbstract()
          Returns a specification satisfied by Methods decalred as abstract.
static Methods declaredFinal()
          Returns a specification satisfied by Methods decalred as final.
static Methods declaredNative()
          Returns a specification satisfied by Methods decalred as native.
static Methods declaredOn(Types specification)
          Creates a new specification satisfied only by Methods hosted on classes that satisfy the supplied specification.
static Methods declaredPackageProtected()
          Returns a specification satisfied by Methods decalred as package protected.
static Methods declaredPrivate()
          Returns a specification satisfied by Methods decalred as private.
static Methods declaredProtected()
          Returns a specification satisfied by Methods decalred as protected.
static Methods declaredPublic()
          Returns a specification satisfied by Methods decalred as public.
static Methods declaredStatic()
          Returns a specification satisfied by Methods decalred as static.
static Methods declaredSynchronized()
          Returns a specification satisfied by Methods decalred as synchronized.
static Methods equalTo(java.lang.reflect.Method toTest)
          Creates a new specification satisfied by Methods equal to the supplied Method.
protected abstract  boolean evaluate(java.lang.reflect.Method method)
          Returns true if the supplied Method satisfies this specification.
 boolean isSatisfiedBy(java.lang.reflect.Method method)
          Returns true if the supplied Method is not null and satisfies this specification.
 boolean isSatisfiedByAll(java.lang.reflect.Method[] all)
          Returns true if all of the supplied Methods satisfy this specification.
 boolean isSatisfiedByAny(java.lang.reflect.Method[] any)
          Returns true if any of the supplied Methods satisfy this specification.
static Methods named(java.lang.String namePattern)
          Creates a new specification satisfied by Methods whose names match the supplied pattern.
static Methods named(Strings specification)
          Creates a new specification satisfied by Methods whose names satisfy the supplied specification.
 Methods not()
          Returns a specification representing a logical NOT of this specification.
 Methods or(Methods specification)
          Returns a specification representing a logical OR of this specification on the left and the supplied specification on the right.
static Methods parse(java.lang.String methodsPattern)
          Parses a pattern string into a complete Methods specification.
static Methods propertyAccessors()
          Returns a specification satisfied by Methods that are valid JavaBeans accessor methods.
static Methods propertyMutators()
          Returns a specification satisfied by Methods that are valid JavaBeans mutator methods.
static Methods returning(Types specification)
          Creates a new specification satisfied only by Methods that return Types that satisfy the supplied specification.
static Methods returningVoid()
          Returns a specification satisfied by Methods returning void.
 java.lang.reflect.Method[] selectAll(java.lang.reflect.Method[] from)
          Selects all the Methods that satisfy this specification from the supplied Collection.
 java.lang.reflect.Method selectFirst(java.lang.reflect.Method[] from)
          Selects the first Method that satisfies this specification from the supplied Collection.
static Methods taking(Parameters specification)
          Creates a new specification satisfied only by Methods with parameter Lists that satisfy the supplied specification.
static Methods takingNoParameters()
          Returns specification satisfied by Methods taking no parameters.
static Methods takingOneParameter()
          Returns a specification satisfied by Methods taking one parameter.
static Methods throwing(Throwables specification)
          Creates a new specification satisfied only by Methods with throwable sets that satisfy the supplied specification.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Methods

protected Methods()
Creates a new Methods object.

Method Detail

declaredPublic

public static Methods declaredPublic()
Returns a specification satisfied by Methods decalred as public.

Returns:
A specification satisfied by Methods decalred as public.

declaredProtected

public static Methods declaredProtected()
Returns a specification satisfied by Methods decalred as protected.

Returns:
A specification satisfied by Methods decalred as protected.

declaredPrivate

public static Methods declaredPrivate()
Returns a specification satisfied by Methods decalred as private.

Returns:
A specification satisfied by Methods decalred as private.

declaredPackageProtected

public static Methods declaredPackageProtected()
Returns a specification satisfied by Methods decalred as package protected.

Returns:
A specification satisfied by Methods decalred as package protected.

declaredStatic

public static Methods declaredStatic()
Returns a specification satisfied by Methods decalred as static.

Returns:
A specification satisfied by Methods decalred as static.

declaredAbstract

public static Methods declaredAbstract()
Returns a specification satisfied by Methods decalred as abstract.

Returns:
A specification satisfied by Methods decalred as abstract.

declaredFinal

public static Methods declaredFinal()
Returns a specification satisfied by Methods decalred as final.

Returns:
A specification satisfied by Methods decalred as final.

declaredSynchronized

public static Methods declaredSynchronized()
Returns a specification satisfied by Methods decalred as synchronized.

Returns:
A specification satisfied by Methods decalred as synchronized.

declaredNative

public static Methods declaredNative()
Returns a specification satisfied by Methods decalred as native.

Returns:
A specification satisfied by Methods decalred as native.

takingNoParameters

public static Methods takingNoParameters()
Returns specification satisfied by Methods taking no parameters.

Returns:
A specification satisfied by Methods taking no parameters.

takingOneParameter

public static Methods takingOneParameter()
Returns a specification satisfied by Methods taking one parameter.

Returns:
A specification satisfied by Methods taking one parameter.

returningVoid

public static Methods returningVoid()
Returns a specification satisfied by Methods returning void.

Returns:
A specification satisfied by Methods returning void.

propertyAccessors

public static Methods propertyAccessors()
Returns a specification satisfied by Methods that are valid JavaBeans accessor methods.

Returns:
A specification satisfied by Methods that are valid JavaBeans accessor methods.

propertyMutators

public static Methods propertyMutators()
Returns a specification satisfied by Methods that are valid JavaBeans mutator methods.

Returns:
A specification satisfied by Methods that are valid JavaBeans mutator methods.

equalTo

public static Methods equalTo(java.lang.reflect.Method toTest)
Creates a new specification satisfied by Methods equal to the supplied Method.

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

named

public static Methods named(java.lang.String namePattern)
Creates a new specification satisfied by Methods whose names match the supplied pattern.

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

named

public static Methods named(Strings specification)
Creates a new specification satisfied by Methods whose names satisfy the supplied specification.

Parameters:
specification - The specification names must satisfy.
Returns:
A new specification satisfied by Methods whose names satisfy the supplied specification.

declaredOn

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

Parameters:
specification - The specification that classes must match.
Returns:
A new specification satisfied only by Methods hosted on classes that satisfy the supplied specification.

taking

public static Methods taking(Parameters specification)
Creates a new specification satisfied only by Methods with parameter Lists that satisfy the supplied specification.

Parameters:
specification - The specification that parameter Lists must match.
Returns:
A new specification satisfied only by Methods with parameter Lists that satisfy the supplied specification.

throwing

public static Methods throwing(Throwables specification)
Creates a new specification satisfied only by Methods with throwable sets that satisfy the supplied specification.

Parameters:
specification - The specification that throwable sets must match.
Returns:
A new specification satisfied only by Methods with throwable sets that satisfy the supplied specification.

returning

public static Methods returning(Types specification)
Creates a new specification satisfied only by Methods that return Types that satisfy the supplied specification.

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

parse

public static Methods parse(java.lang.String methodsPattern)
Parses a pattern string into a complete Methods specification. Format:
   methods         ::=  throws-clause
   throws-clause   ::=  param-list [ " throws " throwables ]
   param-list      ::=  name "(" [ parameters ] ")" 
   name            ::=  [ return-type ] [ types | "(" types-expr ")" "." ] ( strings | "(" strings-expr ")" )
   return-type     ::=  [ modifiers ] ( types | "(" types-expr ")" )
   modifiers       ::=  ( [ "!" ] 
                          ( "public" | "protected" | "package" | "private"
                            | "static" | "abstract" | "final" | "synchronized" | "native" ) )...
 
Example:
   public void (com.lonniepryor..* && !javax..*+).foo(..)
 
The above matches public void methods named foo taking any number of parameters on any class in the 'com.lonniepryor' namespace that is not assignable to a class in the 'javax' namespace.

Parameters:
methodsPattern - The pattern string.
Returns:
A specification matching the supplied constructor pattern.

isSatisfiedBy

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

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

evaluate

protected abstract boolean evaluate(java.lang.reflect.Method method)
Returns true if the supplied Method satisfies this specification.

Parameters:
method - The Method to test.
Returns:
True if the supplied Method satisfies this specification.

isSatisfiedByAll

public final boolean isSatisfiedByAll(java.lang.reflect.Method[] all)
Returns true if all of the supplied Methods satisfy this specification.

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

isSatisfiedByAny

public final boolean isSatisfiedByAny(java.lang.reflect.Method[] any)
Returns true if any of the supplied Methods satisfy this specification.

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

selectFirst

public final java.lang.reflect.Method selectFirst(java.lang.reflect.Method[] from)
Selects the first Method that satisfies this specification from the supplied Collection.

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

selectAll

public final java.lang.reflect.Method[] selectAll(java.lang.reflect.Method[] from)
Selects all the Methods that satisfy this specification from the supplied Collection.

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

and

public final Methods and(Methods 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 Methods or(Methods 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 Methods 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.