TitleService
Provides methods to programmatically obtain the title and icon of a domain object.
API
TitleService.java
interface TitleService {
String titleOf(Object domainObject) (1)
IconResource iconOf(Object domainObject, IconSize iconSize) (2)
}
| 1 | titleOf(Object)
Returns the title of the object (as rendered in the UI by the framework’s viewers). |
| 2 | iconOf(Object, IconSize)
Returns the icon 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 (record).
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.