gumbo.util.state
Class TypeFlag

java.lang.Object
  |
  +--gumbo.util.state.StateFlag
        |
        +--gumbo.util.state.TypeFlag

public class TypeFlag
extends StateFlag

An immutable state flag that represents a target type (Class). Type flag identity (equals(), hashCode()) is that of the target type plus an instanceof test for TypeFlag. The flag name is not a factor in the flag's identity. Type flags that wrap the same object will test equal.

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

Constructor Summary
TypeFlag(java.lang.Class type)
          Constructs an instance, with the specified target type and the default name of the type (type.getName()).
TypeFlag(java.lang.Class type, java.lang.String name)
          Constructs an instance, with a specified target object and name.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 java.lang.Class getType()
          Gets the target type wrapped by this flag.
 int hashCode()
           
 boolean isTypeAssignableFrom(java.lang.Object object)
          Return true if the target object is not null and is an instance of (assignable to) the type wrapped by this flag.
 java.lang.String toString()
          Returns the name of this flag followed by its type.
 
Methods inherited from class gumbo.util.state.StateFlag
getName
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TypeFlag

public TypeFlag(java.lang.Class type)
Constructs an instance, with the specified target type and the default name of the type (type.getName()).

Parameters:
type - Target type. Never null.

TypeFlag

public TypeFlag(java.lang.Class type,
                java.lang.String name)
Constructs an instance, with a specified target object and name. Master constructor.

Parameters:
name - Name of this state flag. Null if none, in which case the name defaults to "(object flag)".
Method Detail

getType

public java.lang.Class getType()
Gets the target type wrapped by this flag.

Returns:
Target type. Never null.

isTypeAssignableFrom

public boolean isTypeAssignableFrom(java.lang.Object object)
Return true if the target object is not null and is an instance of (assignable to) the type wrapped by this flag.

Parameters:
object - The target object. Null if none.
Returns:
The result.

toString

public java.lang.String toString()
Returns the name of this flag followed by its type.

Overrides:
toString in class StateFlag

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object