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

Method compare

code/src/java/pcgen/core/SkillComparator.java:45–85  ·  view source on GitHub ↗
(final Skill obj1, final Skill obj2)

Source from the content-addressed store, hash-verified

43
44 // Comparator will be specific to Skill objects
45 @Override
46 public int compare(final Skill obj1, final Skill obj2)
47 {
48 final Skill s1;
49 final Skill s2;
50
51 if ((sortOrder == RESORT_ASCENDING) || (sort == RESORT_TRAINED))
52 {
53 s1 = obj1;
54 s2 = obj2;
55 }
56 else
57 {
58 s1 = obj2;
59 s2 = obj1;
60 }
61
62 switch (sort)
63 {
64 case RESORT_TRAINED: {
65
66 float r1 = SkillRankControl.getTotalRank(pc, s1);
67 float r2 = SkillRankControl.getTotalRank(pc, s2);
68 if ((r1 > 0.0f) && (r2 <= 0.0f))
69 {
70 return ((sortOrder == RESORT_ASCENDING) ? (-1) : 1);
71 }
72 else if ((r1 <= 0.0f) && (r2 > 0.0f))
73 {
74 return ((sortOrder == RESORT_ASCENDING) ? 1 : (-1));
75 }
76 else
77 {
78 return s1.getOutputName().compareToIgnoreCase(s2.getOutputName());
79 }
80 }
81 case RESORT_NAME:
82 default:
83 return s1.getOutputName().compareToIgnoreCase(s2.getOutputName());
84 }
85 }
86}

Callers

nothing calls this directly

Calls 2

getTotalRankMethod · 0.95
getOutputNameMethod · 0.45

Tested by

no test coverage detected