java.lang.Object
org.jtrim2.concurrent.query.DataWithUid<DataType>
- Type Parameters:
DataType- the type of the data held by theDataWithUidinstance
Defines an object and its ID which uniquely identifies the object within the
JVM. That is, two objects with the same ID (according to
equals are considered to be equivalent
objects).
This class overrides equals and
hashCode, so that two DataWithUid instances are
considered equivalent, if and only if, their ID equal (according to their
equals method).
Thread safety
The methods of this class are safe to be accessed by multiple threads concurrently. Instances of this class cannot be directly modified, only its properties if they are mutable. In case both theID and
the data is immutable, then the DataWithUid is
completely immutable.
Synchronization transparency
The methods of this class are synchronization transparent.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks whether the passed object is aDataWithUidand has an equivalent ID or not.getData()Returns the data specified at construction time.getID()Returns the ID which is used to determine if twodatais to be considered equivalent.inthashCode()Returns a hash code which can be used in has tables and is compatible with theequalsmethod.toString()Returns the string representation of thisDataWithUidin no particular format.
-
Constructor Details
-
DataWithUid
-
DataWithUid
- Parameters:
data- the data held by theDataWithUidinstance. This argument is allowed to benull.id- the ID identifying the given data. That is, only this ID needs to be compared to determine if two data is equivalent. This argument can benullbut note thatnullID can only be equivalent to anothernullID.
-
-
Method Details
-
getData
Returns the data specified at construction time. If two data is considered to be equivalent should be determined by theirID.- Returns:
- the data specified at construction time. This method may return
nullifnullwas specified at construction time.
-
getID
Returns the ID which is used to determine if twodatais to be considered equivalent. That is, if the IDs are equivalent according to theirequalsmethod, the data they identify should be considered equal as well. Note that it is allowed for the data objects to have anequalsmethod inconsistent with the IDs.- Returns:
- the ID which is used to determine if two
datais to be considered equivalent. This method may returnnullandnullvalues can be equivalent only to othernullvalues.
-
equals
Checks whether the passed object is aDataWithUidand has an equivalent ID or not. That is, this method returnstrue, if and only if, the passed object is an instance ofDataWithUidand its ID is alsoequalsto the ID of thisDataWithUid.- Overrides:
equalsin classObject- Parameters:
obj- the object to which thisDataWithUidis to be compared to. This argument can benull, in which case this method returnsfalse.- Returns:
true, the passed object is an instance ofDataWithUidand its ID is alsoequalsto the ID of thisDataWithUid,falseotherwise
-
hashCode
public int hashCode()Returns a hash code which can be used in has tables and is compatible with theequalsmethod. -
toString
-