IdStringifier

SPI to convert the identifier (primary key) of an entity, of a given type (eg Integer) into a string, and to convert back again into the key object used to actually look up the target entity instance; supported by both JDO and JPA persistence mechanisms.

This is ultimately used by BookmarkService where we hold a persistent reference to an entity. The resultant string also appears in URLs of the Wicket viewer and Restful Objects viewers, and in mementos eg in org.apache.causeway.schema.cmd.v2.CommandDto and org.apache.causeway.schema.ixn.v2.InteractionDto .

The framework provides default implementations of this SPI for JDO (data store and application identity) and for JPA. Because this is a SPI, other modules or application code can provide their own implementations. An example of such is the JPA implementation of the commandlog extension.

API

IdStringifier.java
interface IdStringifier<T> {
  public final static char SEPARATOR;
  Class<T> getCorrespondingClass()
  String enstring(T value)     (1)
  T destring(Class<?> targetEntityClass, String stringified)     (2)
  boolean isValid(T value)     (3)
}
1 enstring(T)

Convert the value (which will be of the same type as returned by #getCorrespondingClass() into a string representation.

2 destring(Class, String)

Convert a string representation of the identifier (as returned by #enstring(Object) ) into an object that can be used to retrieve.

3 isValid(T)

Whether the non-null primary key object is valid, that is, in the case of a composite, whether it is fully populated.

Members

enstring(T)

Convert the value (which will be of the same type as returned by #getCorrespondingClass() into a string representation.

destring(Class, String)

Convert a string representation of the identifier (as returned by #enstring(Object) ) into an object that can be used to retrieve.

isValid(T)

Whether the non-null primary key object is valid, that is, in the case of a composite, whether it is fully populated.