Package cdc.kernel.rids
Class RawId
- java.lang.Object
-
- cdc.kernel.rids.RawId
-
- All Implemented Interfaces:
Comparable<RawId>
public final class RawId extends Object implements Comparable<RawId>
RawId (raw identifier) is used to identify an object in a generic way.It is a kind of global identifier that carries semantic.
It is an immutable(class, id)pair, whereclassis the class of the identified object andidits identifier.
RawId is intended for in-memory use.
The sister classRawIdProxyis intended for persistence.WARNING: Creating a RawId does not means that the corresponding RawIdProxy can be created.
Appropriate class and id converters must exist.- Author:
- Damien Carbonne
-
-
Constructor Summary
Constructors Constructor Description RawId(RawIdProxy ridp)Creates a RawId from its RawIdProxy.RawId(Class<?> objectClass, Object id)Creates a RawId from an object class and identifier.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(RawId o)static RawIdcreate(Class<?> objectClass, Object id)booleanequals(Object object)static RawIdfromRawIdProxy(RawIdProxy ridp)ObjectgetId()<T> TgetId(Class<T> type)Returns the object identifier converted to a type.StringgetIdCode()Class<?>getObjectClass()StringgetObjectClassCode()inthashCode()static RawIdProxytoRawIdProxy(RawId rid)StringtoString()
-
-
-
Constructor Detail
-
RawId
public RawId(Class<?> objectClass, Object id)
Creates a RawId from an object class and identifier.WARNING: Compatibility between
objectClassandidis not checked.
WARNING: Conversion to a RawIdProxy is not guaranteed.- Parameters:
objectClass- The object class.id- The identifier.- Throws:
IllegalArgumentException- WhenobjectClassisnull.
-
RawId
public RawId(RawIdProxy ridp)
Creates a RawId from its RawIdProxy.- Parameters:
ridp- The RawIdProxy.
-
-
Method Detail
-
getObjectClass
public Class<?> getObjectClass()
- Returns:
- The object class.
-
getObjectClassCode
public String getObjectClassCode()
- Returns:
- The String encoding of object class.
-
getId
public Object getId()
- Returns:
- The object identifier (possibly
null).
-
getId
public <T> T getId(Class<T> type)
Returns the object identifier converted to a type.- Type Parameters:
T- The conversion type.- Parameters:
type- The conversion class.- Returns:
- The object identifier converted as
type.
-
getIdCode
public String getIdCode()
- Returns:
- The String encoding of the id.
-
toRawIdProxy
public static RawIdProxy toRawIdProxy(RawId rid)
-
fromRawIdProxy
public static RawId fromRawIdProxy(RawIdProxy ridp)
-
compareTo
public int compareTo(RawId o)
- Specified by:
compareToin interfaceComparable<RawId>
-
-