@Title
Used to indicate which property or properties make up the object title.
If more than one property is used, the order can be specified (using the same Dewey-decimal notation). The string to use between the components can also be specified.
API
@interface Title {
String sequence() default "1.0"; (1)
String prepend() default " "; (2)
String append() default ""; (3)
int abbreviatedTo() default Integer.MAX_VALUE; (4)
}
1 | sequence |
2 | prepend
The string to use to separate this property from any preceding properties in the title. |
3 | append
The string to append to this property if non-empty. |
4 | abbreviatedTo
The length to abbreviate this title element to. |
Examples
For example:
public void Customer {
@Title(sequence="1.0")
public String getLastName() { /* ... */ } (1)
...
@Title(sequence="1.5", prepend=", ")
public String getFirstName() { /* ... */ }
...
@Title(sequence="1.7", append=".")
public String getMidInitial() { /* ... */ }
...
}
1 | backing field and setters omitted |
could be used to create names of the style "Bloggs, Joe K."
It is also possible to annotate reference properties; in this case the title will return the title of the referenced object (rather than, say, its string representation).
An additional convention for @Title
properties is that they are hidden in tables (in other words, it implies @Property(where=Where.ALL_TABLES)
.
For viewers that support this annotation (for example, the Wicket viewer), this convention excludes any properties whose value is already present in the title column.
This convention can be overridden using @Property(where=Where.NOWHERE)
.
Lombok support
If Project Lombok is being used, then @Title
can be specified on the backing field.
For example:
public void Customer {
@Title(sequence="1.0")
@Getter @Setter
private String name;
@Title(sequence="1.5", prepend=", ")
@Getter @Setter
private String firstName;
@Title(sequence="1.7", append=".")
@Getter @Setter
private String midInitial;
}