James Raitsev
James Raitsev

Reputation: 96581

How control order in which annotation elements appear?

When creating new annotation

public @interface Invariant {
    String min();
    String max();
    String Default();
    String freeform();
}

Elements appear in what seems to be alphabetical order. I wonder if there is a way to force the same order as established in the annotation itself?

I get

    @Invariant(Default = "", freeform = "", max = "", min = "")

I'd like to get

    @Invariant(min = "", max = "", Default = "", freeform = "")

Upvotes: 2

Views: 91

Answers (2)

Óscar López
Óscar López

Reputation: 236170

The order of the elements in an annotation is irrelevant, it makes no sense at all to force an ordering. Don't waste your efforts on this, it's not worth it - and anyway, you can't force an ordering, it's just not possible.

Upvotes: 1

Biju Kunjummen
Biju Kunjummen

Reputation: 49935

No, I doubt if there is a way to force the order of the attributes.

Upvotes: 0

Related Questions