public abstract class HandleObject extends EventManager implements IIdentifiable
An object that can exist in one of two states: defined and undefined. This is used by APIs that want to give a handle to an object, even though the object does not fully exist yet. This way, users can attach listeners to objects before they come into existence. It also protects the API from users that do not release references when they should.
To enforce good coding practice, all handle objects must implement
equals
and toString
. Please use
string
to cache the result for toString
once
calculated.
All handle objects are referred to using a single identifier. This identifier
is a instance of String
. It is important that this identifier
remain unique within whatever context that handle object is being used. For
example, there should only ever be one instance of Command
with a given identifier.
Modifier and Type | Field and Description |
---|---|
protected boolean |
defined
Whether this object is defined.
|
protected String |
id
The identifier for this object.
|
protected String |
string
The string representation of this object.
|
Modifier | Constructor and Description |
---|---|
protected |
HandleObject(String id)
Constructs a new instance of
HandleObject . |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object object)
Tests whether this object is equal to another object.
|
String |
getId()
Returns the identifier for this object.
|
int |
hashCode()
Computes the hash code for this object based on the id.
|
boolean |
isDefined()
Whether this instance is defined.
|
abstract String |
toString()
The string representation of this object -- for debugging purposes only.
|
abstract void |
undefine()
Makes this object becomes undefined.
|
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
protected transient boolean defined
protected final String id
null
.protected transient String string
protected HandleObject(String id)
HandleObject
.id
- The id of this handle; must not be null
.public boolean equals(Object object)
public final String getId()
IIdentifiable
getId
in interface IIdentifiable
null
.public final int hashCode()
public final boolean isDefined()
true
if this object is defined; false
otherwise.public abstract String toString()
public abstract void undefine()
null
. It should also send notification to any
listeners that these properties have changed.
Copyright (c) 2000, 2013 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.