com.metamatrix.common.namedobject
Class BasicObject

java.lang.Object
  extended by com.metamatrix.common.namedobject.BasicObject
All Implemented Interfaces:
BaseObject, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable
Direct Known Subclasses:
BasicComponentObject, BasicComponentType, BasicComponentTypeDefn, BasicConfigurationInfo, BasicPropDefnAllowedValue

public abstract class BasicObject
extends java.lang.Object
implements BaseObject, java.io.Serializable

This class represents the basic implementation of MetadataObject, which is the foundation for all classes that are used to capture metadata. This abstract class is immutable, although it is intended that subclasses are mutable. Additionally, although this class is thread safe, subclasses do not have to be thread safe, since the framework for update and modifying these objects must guarantee proper concurrent access.

These classes are shipped between the client and Metadata Service, so this class is serializable.

Also, the hashCode, equals and compareTo methods are all consistent and optimized for fast performance. This is in part accomplished by caching the hash code value which identifies quickly that two objects are not equal.

This class and all of its subclasses are designed to be publicly immutable. That is, no component outside of the Configuration Service changes these objects once they are created.

See Also:
Serialized Form

Constructor Summary
protected BasicObject(BaseID id)
          Create a new instance with the specified ID.
 
Method Summary
 java.lang.Object clone()
          Return a deep cloned instance of this object.
 int compareTo(java.lang.Object obj)
          Compares this object to another.
 boolean equals(java.lang.Object obj)
          Returns true if the specified object is semantically equal to this instance.
 java.lang.String getFullName()
          Returns the full name for this instance of the object.
 BaseID getID()
          Get the ID for this metadata object.
 java.lang.String getName()
          Returns the name for this instance of the object.
 int hashCode()
          Overrides Object hashCode method.
protected  void setID(BaseID newID)
          Sets the id for this objects
 java.lang.String toString()
          Returns a string representing the current state of the object.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicObject

protected BasicObject(BaseID id)
Create a new instance with the specified ID.

Parameters:
id - the ID for this object (may not be null).
Throws:
java.lang.IllegalArgumentException - if either the ID or data source ID is null.
Method Detail

getID

public BaseID getID()
Get the ID for this metadata object. The ID can never change in an object, so it is an immutable field.

Specified by:
getID in interface BaseObject
Returns:
the identifier for this metadata object.

getName

public java.lang.String getName()
Returns the name for this instance of the object. If you are using the dot notation for a naming conventions, this will return the last node in name.

Specified by:
getName in interface BaseObject
Returns:
the name
See Also:
getFullName

getFullName

public java.lang.String getFullName()
Returns the full name for this instance of the object.

Specified by:
getFullName in interface BaseObject
Returns:
the name

setID

protected void setID(BaseID newID)
Sets the id for this objects

Parameters:
newID - is of type BaseID

hashCode

public int hashCode()
Overrides Object hashCode method. Note that the hash code is computed purely from the ID, so two distinct instances that have the same identifier (i.e., full name) will have the same hash code value.

This hash code must be consistent with the equals method. defined by subclasses.

Overrides:
hashCode in class java.lang.Object
Returns:
the hash code value for this metadata object.

equals

public boolean equals(java.lang.Object obj)
Returns true if the specified object is semantically equal to this instance. Note: this method is consistent with compareTo().

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object that this instance is to be compared to.
Returns:
whether the object is equal to this object.

compareTo

public int compareTo(java.lang.Object obj)
Compares this object to another. If the specified object is an instance of the same class, then this method compares the name; otherwise, it throws a ClassCastException (as instances are comparable only to instances of the same class). Note: this method is consistent with equals().

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
obj - the object that this instance is to be compared to.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object, respectively.
Throws:
java.lang.IllegalArgumentException - if the specified object reference is null
java.lang.ClassCastException - if the specified object's type prevents it from being compared to this instance.

toString

public java.lang.String toString()
Returns a string representing the current state of the object.

Overrides:
toString in class java.lang.Object
Returns:
the string representation of this instance.

clone

public java.lang.Object clone()
Description copied from interface: BaseObject
Return a deep cloned instance of this object. Subclasses must override this method.

Specified by:
clone in interface BaseObject
Overrides:
clone in class java.lang.Object
Returns:
the object that is the clone of this instance. Defaults cannot be cloned).


Copyright © 2009. All Rights Reserved.