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 {
  Optional<Bookmark> bookmarkFor(Object domainObject)     (1)
  Optional<Bookmark> bookmarkFor(Class<?> type, String identifier)     (2)
  Optional<Object> lookup(BookmarkHolder bookmarkHolder)     (3)
  Optional<Object> lookup(Bookmark bookmark)     (4)
  Optional<T> lookup(Bookmark bookmark, Class<T> cls)     (5)
  Bookmark bookmarkForElseFail(Object domainObject)     (6)
}
1 bookmarkFor(Object)

Optionally returns the Bookmark for the given domain object, based on whether can create a bookmark for it.

2 bookmarkFor(Class, String)

Optionally returns a Bookmark created from the constituent parts, based on whether can create a bookmark from these.

3 lookup(BookmarkHolder)
4 lookup(Bookmark)

Reciprocal of #bookmarkFor(Object)

5 lookup(Bookmark, Class)

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

6 bookmarkForElseFail(Object)

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

Members

bookmarkFor(Object)

Optionally returns the Bookmark for the given domain object, based on whether can create a bookmark for it.

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

bookmarkFor(Class, String)

Optionally returns a Bookmark created from the constituent parts, based on whether can create a bookmark from these.

With constituent parts a type and an identifier that uniquely identifies an instance of this type.

lookup(BookmarkHolder)

lookup(Bookmark)

Reciprocal of #bookmarkFor(Object)

lookup(Bookmark, Class)

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

bookmarkForElseFail(Object)

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

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 logical type name 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.