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.
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 the supported value types. Modules that define application-defined primary keys can provide their own implementations of this SPI, for examples see the JPA entities defined in the commandlog-jpa module.
API
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. |