1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.tools.plugin.extractor;
20
21 import java.util.Objects;
22
23
24
25
26
27
28
29 public final class GroupKey implements Comparable<GroupKey> {
30
31
32
33 public static final String JAVA_GROUP = "java";
34
35 private final String group;
36
37 private final int order;
38
39 public GroupKey(String group, int order) {
40 if (group == null) {
41 throw new NullPointerException("GroupKey.group null");
42 }
43 this.group = group;
44 this.order = order;
45 }
46
47
48
49
50 public String getGroup() {
51 return group;
52 }
53
54
55
56
57 public int getOrder() {
58 return order;
59 }
60
61 @Override
62 public boolean equals(Object o) {
63 if (this == o) {
64 return true;
65 }
66 if (o == null || getClass() != o.getClass()) {
67 return false;
68 }
69 GroupKey groupKey = (GroupKey) o;
70 return order == groupKey.order && group.equals(groupKey.group);
71 }
72
73 @Override
74 public int hashCode() {
75 return Objects.hash(group, order);
76 }
77
78
79
80
81
82
83
84
85
86 @Override
87 public int compareTo(final GroupKey o) {
88 if (JAVA_GROUP.equals(this.group) && !JAVA_GROUP.equals(o.group)) {
89 return -1;
90 } else if (!JAVA_GROUP.equals(this.group) && JAVA_GROUP.equals(o.group)) {
91 return 1;
92 }
93 int result = this.group.compareTo(o.group);
94 if (result != 0) {
95 return result;
96 }
97 return Integer.compare(this.order, o.order);
98 }
99
100 @Override
101 public String toString() {
102 return group + ":" + order;
103 }
104 }