我有一个数组,其中包含程序中使用的一些定义:
final String[] names = new String[]{"familyNames", "givenNames", "middleNames", "nickNames", "additionalNames", ..., ..., ..., ...}; // Lots of 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
}
是否可以通过该数组定义此类?就像是:
public class Person {
final private String id;
final private .... names...
public int compareTo(...) {...}
}
此类Person
应支持按多字段排序,例如首先按名字,然后按姓氏等。