I have an array which contains some definitions which are used in the program:
final String[] names = new String[]{"familyNames", "givenNames", "middleNames", "nickNames", "additionalNames", ..., ..., ..., ...}; // Lots of definitions
And now I need to create a new class with these definitions:
public class Person {
final private String id;
final private String familyNames;
final private String givenNames;
final private String middleNames;
final private String nickNames;
final private String additionalNames;
...
...
...
...
... // Very long list
}
Is it possible to define this class by that array? Something like:
public class Person {
final private String id;
final private .... names...
public int compareTo(...) {...}
}
This Person class should support sort by multi fields, e.g. first by given name, then by family name, etc.
Comparable, using @Juned's answer.