gumbo.util.state
Class ObjectFlag

java.lang.Object
  |
  +--gumbo.util.state.StateFlag
        |
        +--gumbo.util.state.ObjectFlag
Direct Known Subclasses:
SelectFlag

public class ObjectFlag
extends StateFlag

An immutable state flag that represents a target object (instance). Object flag identity (equals(), hashCode()) is that of the target object plus an instanceof test for ObjectFlag. The flag name is not a factor in the flag's identity. Object flags that wrap the same object, including null, will test equal. As with any object not using "reference" identity, mutating the object may affect its use in collections.

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

Constructor Summary
ObjectFlag(java.lang.Object object)
          Constructs an instance, with the specified target object and the default name "(object flag)".
ObjectFlag(java.lang.Object object, java.lang.String name)
          Constructs an instance, with a specified target object and name.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 java.lang.Object getObject()
          Get this target object wrapped by this flag.
 int hashCode()
           
 boolean isObjectAssignableTo(java.lang.Class type)
          Returns true if the object wrapped by this flag is not null and is an instance of the target type.
 java.lang.String toString()
          Returns the name of this flag followed by its object.
 
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

ObjectFlag

public ObjectFlag(java.lang.Object object)
Constructs an instance, with the specified target object and the default name "(object flag)". Master constructor.

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

ObjectFlag

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

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

getObject

public final java.lang.Object getObject()
Get this target object wrapped by this flag.

Returns:
Target object. None if null.

isObjectAssignableTo

public boolean isObjectAssignableTo(java.lang.Class type)
Returns true if the object wrapped by this flag is not null and is an instance of the target type.

Parameters:
type - The target type. Never null.
Returns:
The result.

toString

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

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