@Test public void testMerge() { Lakare lakare1 = new Lakare("1", "1"); Lakare lakare2 = new Lakare("2", "2"); Lakare lakare3 = new Lakare("3", "3"); Lakare lakare4 = new Lakare("4", "4"); List<Lakare> a = Arrays.asList(lakare1, lakare2, lakare4); List<Lakare> b = Arrays.asList(lakare2, lakare3, lakare4); List<Lakare> merged = Lakare.merge(a, b); assertNotNull(merged); assertFalse(merged.isEmpty()); assertEquals(Arrays.asList(lakare1, lakare2, lakare3, lakare4), merged); }
public static List<Lakare> merge(List<Lakare> a, List<Lakare> b) { if (a == null && b == null) { return new ArrayList<>(); } else if (a == null) { return b; } else if (b == null) { return a; } Set<Lakare> lakarSet = new HashSet<>(a); lakarSet.addAll(b); List<Lakare> res = new ArrayList<>(lakarSet); res.sort(Comparator.comparing(Lakare::getName)); return res; }
Lakare { public static List<Lakare> merge(List<Lakare> a, List<Lakare> b) { if (a == null && b == null) { return new ArrayList<>(); } else if (a == null) { return b; } else if (b == null) { return a; } Set<Lakare> lakarSet = new HashSet<>(a); lakarSet.addAll(b); List<Lakare> res = new ArrayList<>(lakarSet); res.sort(Comparator.comparing(Lakare::getName)); return res; } }
Lakare { public static List<Lakare> merge(List<Lakare> a, List<Lakare> b) { if (a == null && b == null) { return new ArrayList<>(); } else if (a == null) { return b; } else if (b == null) { return a; } Set<Lakare> lakarSet = new HashSet<>(a); lakarSet.addAll(b); List<Lakare> res = new ArrayList<>(lakarSet); res.sort(Comparator.comparing(Lakare::getName)); return res; } Lakare();  Lakare(String hsaId, String name); }
Lakare { public static List<Lakare> merge(List<Lakare> a, List<Lakare> b) { if (a == null && b == null) { return new ArrayList<>(); } else if (a == null) { return b; } else if (b == null) { return a; } Set<Lakare> lakarSet = new HashSet<>(a); lakarSet.addAll(b); List<Lakare> res = new ArrayList<>(lakarSet); res.sort(Comparator.comparing(Lakare::getName)); return res; } Lakare();  Lakare(String hsaId, String name); @JsonProperty("id") String getHsaId(); @JsonProperty("label") String getName(); @Override int hashCode(); @Override boolean equals(Object obj); static List<Lakare> merge(List<Lakare> a, List<Lakare> b); }
Lakare { public static List<Lakare> merge(List<Lakare> a, List<Lakare> b) { if (a == null && b == null) { return new ArrayList<>(); } else if (a == null) { return b; } else if (b == null) { return a; } Set<Lakare> lakarSet = new HashSet<>(a); lakarSet.addAll(b); List<Lakare> res = new ArrayList<>(lakarSet); res.sort(Comparator.comparing(Lakare::getName)); return res; } Lakare();  Lakare(String hsaId, String name); @JsonProperty("id") String getHsaId(); @JsonProperty("label") String getName(); @Override int hashCode(); @Override boolean equals(Object obj); static List<Lakare> merge(List<Lakare> a, List<Lakare> b);  }