mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-22 03:55:17 +08:00
86 lines
2.4 KiB
Java
86 lines
2.4 KiB
Java
import com.google.common.collect.Lists;
|
|
|
|
import java.util.Comparator;
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
|
|
/**
|
|
* @program: com.cjml.service.partitem
|
|
* @description:
|
|
* @author: dc
|
|
* @create: 2023-09-09 13:46
|
|
**/
|
|
public class Test {
|
|
|
|
public static void main(String[] args) {
|
|
List<Category> testList = Lists.newArrayList();
|
|
testList.add(new Category("100-50-10", 100, 50, 10));
|
|
testList.add(new Category("110-30-8", 110, 30, 8));
|
|
testList.add(new Category("0-10-12", 0, 10, 12));
|
|
|
|
testList = testList.stream().sorted(
|
|
Comparator.comparing(Category::getCategoryGroupSort, Comparator.reverseOrder())
|
|
.thenComparing(Category::getCategorySort, Comparator.reverseOrder())
|
|
.thenComparing(Category::getPartSort)
|
|
)
|
|
.collect(Collectors.toList());
|
|
|
|
System.out.println(testList.get(0).getCategoryName());
|
|
System.out.println(testList.get(1).getCategoryName());
|
|
System.out.println(testList.get(2).getCategoryName());
|
|
}
|
|
|
|
static class Category {
|
|
|
|
private String categoryName;
|
|
|
|
private int categoryGroupSort;
|
|
|
|
private int categorySort;
|
|
|
|
private int partSort;
|
|
|
|
public Category() {
|
|
}
|
|
|
|
public Category(String categoryName, int categoryGroupSort, int categorySort, int partSort) {
|
|
this.categoryName = categoryName;
|
|
this.categoryGroupSort = categoryGroupSort;
|
|
this.categorySort = categorySort;
|
|
this.partSort = partSort;
|
|
}
|
|
|
|
public String getCategoryName() {
|
|
return categoryName;
|
|
}
|
|
|
|
public void setCategoryName(String categoryName) {
|
|
this.categoryName = categoryName;
|
|
}
|
|
|
|
public int getCategoryGroupSort() {
|
|
return categoryGroupSort;
|
|
}
|
|
|
|
public void setCategoryGroupSort(int categoryGroupSort) {
|
|
this.categoryGroupSort = categoryGroupSort;
|
|
}
|
|
|
|
public int getCategorySort() {
|
|
return categorySort;
|
|
}
|
|
|
|
public void setCategorySort(int categorySort) {
|
|
this.categorySort = categorySort;
|
|
}
|
|
|
|
public int getPartSort() {
|
|
return partSort;
|
|
}
|
|
|
|
public void setPartSort(int partSort) {
|
|
this.partSort = partSort;
|
|
}
|
|
}
|
|
}
|