MCPcopy Create free account
hub / github.com/PCGen/pcgen / compare

Method compare

code/src/java/pcgen/core/utils/CoreUtility.java:49–88  ·  view source on GitHub ↗
(final Equipment obj1, final Equipment obj2)

Source from the content-addressed store, hash-verified

47 public static final Comparator<Equipment> EQUIPMENT_COMPARATOR = new Comparator<>()
48 {
49 @Override
50 public int compare(final Equipment obj1, final Equipment obj2)
51 {
52 int o1i = obj1.getOutputIndex();
53 int o2i = obj2.getOutputIndex();
54
55 // Force unset items (index of 0) to appear at the end
56 o1i = (o1i == 0) ? 999 : o1i;
57 o2i = (o2i == 0) ? 999 : o2i;
58
59 final int result1 = Integer.compare(o1i, o2i);
60
61 if (result1 != 0)
62 {
63 return result1;
64 }
65
66 final int result2 = Integer.compare(obj1.getOutputSubindex(), obj2.getOutputSubindex());
67
68 if (result2 != 0)
69 {
70 return result2;
71 }
72
73 final int result3 = obj1.getName().compareToIgnoreCase(obj2.getName());
74
75 if (result3 != 0)
76 {
77 return result3;
78 }
79
80 final int result4 = obj1.getAppliedName().compareToIgnoreCase(obj2.getAppliedName());
81
82 if (result4 != 0)
83 {
84 return result4;
85 }
86
87 return obj1.getParentName().compareToIgnoreCase(obj2.getParentName());
88 }
89
90 @Override
91 public boolean equals(final Object obj)

Callers 15

runTestMethod · 0.45
passesMethod · 0.45
passesMethod · 0.45
passesMethod · 0.45
passesMethod · 0.45
passesMethod · 0.45
passesMethod · 0.45
getRunningTotalMethod · 0.45
passesMethod · 0.45
passesMethod · 0.45
passesMethod · 0.45
passesMethod · 0.45

Calls 5

getOutputIndexMethod · 0.80
getOutputSubindexMethod · 0.80
getParentNameMethod · 0.80
getNameMethod · 0.65
getAppliedNameMethod · 0.45

Tested by 15

runTestMethod · 0.36
passesMethod · 0.36
passesMethod · 0.36
passesMethod · 0.36
passesMethod · 0.36
passesMethod · 0.36
passesMethod · 0.36
getRunningTotalMethod · 0.36
passesMethod · 0.36
passesMethod · 0.36
passesMethod · 0.36
passesMethod · 0.36