public List<Columns> getNewList(){
Columns column1=new Columns("VARCHAR2", "XMMC", 1, "项目名称");
Columns column2=new Columns("VARCHAR2", "SJBM", 3, "上级编码");
Columns column3=new Columns("VARCHAR2", "XMDM", 2, "项目代码");
List<Columns> list=new ArrayList<>();
list.add(column1);
list.add(column2);
list.add(column3);
Collections.sort(list, new Comparator<Columns>() {
@Override
public int compare(Columns o1, Columns o2) {
// TODO Auto-generated method stub
return o1.getOrder()-o2.getOrder();
}
});
return list;
}
public static void main(String[] args) {
List<Columns> list=new ListUtil().getNewList();
for(Columns l:list) {
System.out.println(l);
}
}
输出结果:
Columns [type=VARCHAR2, columnName=XMMC, order=1, comments=项目名称]
Columns [type=VARCHAR2, columnName=XMDM, order=2, comments=项目代码]
Columns [type=VARCHAR2, columnName=SJBM, order=3, comments=上级编码]