@MemberOrder

Indicates the position a method should be placed in.

An alternative is to use the Xxx.layout.xml file, where Xxx is the domain object name.

API

MemberOrder.java
@interface MemberOrder {
  String name() default "";     (1)
  String sequence();     (2)
}
1 name

Groups or associate members with each other.

2 sequence

The order of this member relative to other members in the same group, in Dewey-decimal notation.

Members

name

Groups or associate members with each other.

The intepretation ofthis grouping depends on the member:

  • For actions, indicates the property or collection to associate.

  • For properties, indicates the property group

  • For collections, currently has no meaning

sequence

The order of this member relative to other members in the same group, in Dewey-decimal notation.

Usage notes

The interpretation of the name() element varies dependent on the type of object member it is annotated upon, but generally speaking it is used to associate members together.

The sequence() element then orders those members that have been grouped together.

Properties

For properties, the name attribute is used to group properties together, and sequence orders the properties within that group. It corresponds to a <fieldset> if using layout files.

For example:

import lombok.Getter;
import lombok.Setter;

public class Customer {

    @MemberOrder(name = "Personal Details", sequence = "1.0")
    private String firstName;

    @MemberOrder(name = "Personal Details", sequence = "2.0")
    private String lastName;

    @MemberOrder(name = "Address", sequence = "1.0")
    private String addressLine1;

    @MemberOrder(name = "Address", sequence = "2.0")
    private String addressLine2;

    @MemberOrder(name = "Address", sequence = "3.0")
    private String city;

    @MemberOrder(name = "Address", sequence = "4.0")
    private String zipCode;

    // ...
}
It’s possible to combine @MemberOrder with layout file. Use the layout file to define the positioning of the fieldsets, and use @MemberOrder to organise the properties within the fieldset.

Actions

For actions, the name attribute indicates the name of a property to associate the action with, and sequence orders all the actions associated with the same property or collection (on the panel of the property’s fieldset, or collection’s title bar).

For example:

import lombok.Getter;
import lombok.Setter;

public class Customer {

    @MemberOrder(name = "Personal Details")
    public Customer updateName(String firstName, String lastName) {
        // ...
    }

    @MemberOrder(name = "Address")
    public Customer changeAddress(String firstName, String lastName) {
        // ...
    }

    // ...
}
For actions, @Member#name() element and @Action#associateWith() element have the same effect.
For actions associated with properties, the @ActionLayout#position() element indicates whether the action should be rendered beneath the property’s field, or instead on the property’s fieldset panel’s header.

Collections

The name attribute is ignored when annotated on collections.