BookmarkService (interface)

This service provides a serializable 'bookmark' for any entity, and conversely to lookup an entity from a bookmark.

API

BookmarkService.java
interface BookmarkService {
  Bookmark bookmarkFor(Object domainObject)     (1)
  Bookmark bookmarkForElseThrow(Object domainObject)     (2)
  Bookmark bookmarkFor(Class<?> cls, String identifier)     (3)
  Object lookup(BookmarkHolder bookmarkHolder)     (4)
  Object lookup(Bookmark bookmark)     (5)
  T lookup(Bookmark bookmark, Class<T> cls)     (6)
}
1 bookmarkFor(Object)

Returns the Bookmark for the given domain object.

2 bookmarkForElseThrow(Object)

As per #bookmarkFor(Object) , but requires that a non-null Bookmark is returned.

3 bookmarkFor(Class, String)

Utility method that creates a Bookmark from the constituent parts.

4 lookup(BookmarkHolder)
5 lookup(Bookmark)

Reciprocal of #bookmarkFor(Object)

6 lookup(Bookmark, Class)

As #lookup(Bookmark) , but down-casting to the specified type.

Members

bookmarkFor(Object)

Returns the Bookmark for the given domain object.

*Note* : Not every domain object is bookmark-able: only entities, view models and services (NOT values or collections)

bookmarkForElseThrow(Object)

As per #bookmarkFor(Object) , but requires that a non-null Bookmark is returned.

bookmarkFor(Class, String)

Utility method that creates a Bookmark from the constituent parts.

lookup(BookmarkHolder)

lookup(Bookmark)

Reciprocal of #bookmarkFor(Object)

lookup(Bookmark, Class)

As #lookup(Bookmark) , but down-casting to the specified type.

Usage

There are two mixins that will contribute to this interface:

Either of these can be suppressed, if required, using a vetoing subscriber that listens to the action or property domain event in order to hide the member.

Examples

For example, a Customer object with an object type of "custmgmt.Customer" and an id of 123 would correspond to a Bookmark with a string representation of "custmgmt.Customer|123".

Bookmarks are useful to store a reference to an arbitrary object, although be aware that there is no referential integrity.

Several of the extension libraries use bookmarks. For example the EntityPropertyChangeSubscriber uses bookmarks to identify the object that is being modified.

Serialized form of bookmarks also appear within schema instances, for example as used by CommandSubscriber and the ExecutionSubscriber.