TitleService

Provides methods to programmatically obtain the title and icon of a domain object.

API

TitleService.java
interface TitleService {
  String titleOf(Object domainObject)     (1)
  String iconNameOf(Object domainObject)     (2)
}
1 titleOf(Object)

Returns the title of the object (as rendered in the UI by the framework’s viewers).

2 iconNameOf(Object)

Returns the icon name of the object (as rendered in the UI by the framework’s viewers).

Members

titleOf(Object)

Returns the title of the object (as rendered in the UI by the framework’s viewers).

iconNameOf(Object)

Returns the icon name of the object (as rendered in the UI by the framework’s viewers).

Implementation

The Core Metamodel module provides a default implementation of this service, TitleServiceDefault.

Usage

By way of example, here’s some code based on a system for managing government benefits:

public class QualifiedAdult {

    private Customer qualifying;

    public String title() {
        return "QA for " + titleService.titleOf(qualifying);
    }

    // ...

    @Inject TitleService titleService;
}

In this example, whatever the title of a Customer, it is reused within the title of that customer’s QualifiedAdult object.