I think I have good solution how to fix problem like this - List => List with grouping by Something.a & Something.b.
There is extended definition:
public class Test {
public static void test() {
class A {
private int a;
private int b;
private float c;
private float d;
public A(int a, int b, float c, float d) {
this.a = a;
this.b = b;
this.c = c;
this.d = d;
}
}
List<A> list1 = new ArrayList<A>();
list1.addAll(Arrays.asList(new A(1, 2, 3, 4),
new A(2, 3, 4, 5),
new A(1, 2, 3, 4),
new A(2, 3, 4, 5),
new A(1, 2, 3, 4)));
Map<Integer, A> map = list1.stream()
.collect(HashMap::new, (m, v) -> m.put(
Objects.hash(v.a, v.b, v.c, v.d), v),
HashMap::putAll);
list1.clear();
list1.addAll(map.values());
System.out.println(list1);
}
}
class A, list1 it's just incoming data - magic is in the Objects.hash(...) :)