BookmarkService

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

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

2 bookmarksFor(Object)

Returns all possible Bookmark s for the provided domain object, taking into account any aliases defined as per DomainObject#aliased() or DomainService#aliased() .

3 bookmarkFor(Class, String)

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

4 lookup(BookmarkHolder)
5 lookup(Bookmark)

Reciprocal of #bookmarkFor(Object)

6 lookup(Bookmark, Class)

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

7 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)

bookmarksFor(Object)

Returns all possible Bookmark s for the provided domain object, taking into account any aliases defined as per DomainObject#aliased() or DomainService#aliased() .

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.