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, where class is the class of the identified object and id its identifier.
RawId is intended for in-memory use.
The sister class RawIdProxy is 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 Details

    • RawId

      public RawId(Class<?> objectClass, Object id)
      Creates a RawId from an object class and identifier.

      WARNING: Compatibility between objectClass and id is not checked.
      WARNING: Conversion to a RawIdProxy is not guaranteed.

      Parameters:
      objectClass - The object class.
      id - The identifier.
      Throws:
      IllegalArgumentException - When objectClass is null.
    • RawId

      public RawId(RawIdProxy ridp)
      Creates a RawId from its RawIdProxy.
      Parameters:
      ridp - The RawIdProxy.
  • Method Details

    • create

      public static RawId create(Class<?> objectClass, Object id)
    • 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.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toRawIdProxy

      public static RawIdProxy toRawIdProxy(RawId rid)
    • fromRawIdProxy

      public static RawId fromRawIdProxy(RawIdProxy ridp)
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • compareTo

      public int compareTo(RawId o)
      Specified by:
      compareTo in interface Comparable<RawId>
    • toString

      public String toString()
      Overrides:
      toString in class Object