Рассмотрите следующие классы для существующего объекта:
Код: Выделить всё
public class Endpoint {
private String key;
private Integer number;
public Endpoint(String key, Integer number) {
this.key = key;
this.number = number;
}
// Getters, Setters and toString()
}
public class Pair {
// It will have exactly 2 entries
List pair;
public Pair(List pair) {
this.pair = pair;
}
// Getters, Setters and toString()
}
Код: Выделить всё
pairs: [
pair: [{"p1",1000},{"p2",2000}],
pair: [{"p1",3000},{"p3",4000}],
pair: [{"p2",5000},{"p3",6000}],
pair: [{"p1",2000},{"p2",3000}],
pair: [{"p1",2001},{"p2",3001}],
pair: [{"p1",4000},{"p3",5000}],
pair: [{"p1",4001},{"p3",5001}],
pair: [{"p2",6000},{"p3",7000}],
pair: [{"p2",6001},{"p3",7001}]
]
Код: Выделить всё
public class CustomEndpoint {
private String key;
// `numbers` can have any number of entries
private List numbers;
public CustomEndpoint(String key, List numbers) {
this.key = key;
this.numbers = numbers;
}
// Getters, Setters and toString()
}
public class CustomPair {
// It will have exactly 2 entries
List pair;
public CustomPair(List pair) {
this.pair = pair;
}
// Getters, Setters and toString()
}
Код: Выделить всё
custom-pairs: [
custom-pair: {[{"p1", [1000,2000,2001]}, {"p2", [2000,3000,3001]}]},
custom-pair: {[{"p1", [3000,4000,4001]}, {"p3", [4000,5000,5001]}]},
custom-pair: {[{"p2", [5000,6000,6001]}, {"p3", [6000,7000,7001]}]}
]
Как я могу сделать это с помощью потоков в Java?
Подробнее здесь: https://stackoverflow.com/questions/723 ... irwise-key