982 * Debug helper function that returns the diff of two property maps, only 983 * displaying the information that is different and in which map it exists 984 * compared to the other map. Can be used to e.g. debug map guards and 985 * investigate why they fail, causing relink 986 * 987 * @param map0 the first property map 988 * @param map1 the second property map 989 * 990 * @return property map diff as string 991 */ 992 public static String diff(final PropertyMap map0, final PropertyMap map1) { 993 final StringBuilder sb = new StringBuilder(); 994 995 if (map0 != map1) { 996 sb.append(">>> START: Map diff"); 997 boolean found = false; 998 999 for (final Property p : map0.getProperties()) { 1000 final Property p2 = map1.findProperty(p.getKey()); 1001 if (p2 == null) { 1002 sb.append("FIRST ONLY : [" + p + "]"); 1003 found = true; 1004 } else if (p2 != p) { 1005 sb.append("DIFFERENT : [" + p + "] != [" + p2 + "]"); 1006 found = true; 1007 } 1008 } 1009 1010 for (final Property p2 : map1.getProperties()) { 1011 final Property p1 = map0.findProperty(p2.getKey()); 1012 if (p1 == null) { 1013 sb.append("SECOND ONLY: [" + p2 + "]"); 1014 found = true; 1015 } 1016 } 1017 1018 //assert found; 1019 1020 if (!found) { 1021 sb.append(map0). 1022 append("!="). 1023 append(map1); 1024 } 1025 1026 sb.append("<<< END: Map diff\n"); 1027 } 1028 1029 return sb.toString(); 1030 } 1031 1032 // counters updated only in debug mode 1033 private static int count; | 982 * Debug helper function that returns the diff of two property maps, only 983 * displaying the information that is different and in which map it exists 984 * compared to the other map. Can be used to e.g. debug map guards and 985 * investigate why they fail, causing relink 986 * 987 * @param map0 the first property map 988 * @param map1 the second property map 989 * 990 * @return property map diff as string 991 */ 992 public static String diff(final PropertyMap map0, final PropertyMap map1) { 993 final StringBuilder sb = new StringBuilder(); 994 995 if (map0 != map1) { 996 sb.append(">>> START: Map diff"); 997 boolean found = false; 998 999 for (final Property p : map0.getProperties()) { 1000 final Property p2 = map1.findProperty(p.getKey()); 1001 if (p2 == null) { 1002 sb.append("FIRST ONLY : [").append(p).append("]"); 1003 found = true; 1004 } else if (p2 != p) { 1005 sb.append("DIFFERENT : [").append(p).append("] != [").append(p2).append("]"); 1006 found = true; 1007 } 1008 } 1009 1010 for (final Property p2 : map1.getProperties()) { 1011 final Property p1 = map0.findProperty(p2.getKey()); 1012 if (p1 == null) { 1013 sb.append("SECOND ONLY: [").append(p2).append("]"); 1014 found = true; 1015 } 1016 } 1017 1018 //assert found; 1019 1020 if (!found) { 1021 sb.append(map0). 1022 append("!="). 1023 append(map1); 1024 } 1025 1026 sb.append("<<< END: Map diff\n"); 1027 } 1028 1029 return sb.toString(); 1030 } 1031 1032 // counters updated only in debug mode 1033 private static int count; |