1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.aether.internal.impl;
20
21 public final class PrioritizedComponent<T> implements Comparable<PrioritizedComponent<?>> {
22
23 private final T component;
24
25 private final Class<?> type;
26
27 private final float priority;
28
29 private final int index;
30
31 PrioritizedComponent(T component, Class<?> type, float priority, int index) {
32 this.component = component;
33 this.type = type;
34 this.priority = priority;
35 this.index = index;
36 }
37
38 public T getComponent() {
39 return component;
40 }
41
42 public Class<?> getType() {
43 return type;
44 }
45
46 public float getPriority() {
47 return priority;
48 }
49
50 public boolean isDisabled() {
51 return Float.isNaN(priority);
52 }
53
54 public int compareTo(PrioritizedComponent<?> o) {
55 int rel = (isDisabled() ? 1 : 0) - (o.isDisabled() ? 1 : 0);
56 if (rel == 0) {
57 rel = Float.compare(o.priority, priority);
58 if (rel == 0) {
59 rel = index - o.index;
60 }
61 }
62 return rel;
63 }
64
65 @Override
66 public String toString() {
67 return priority + " (#" + index + "): " + component;
68 }
69 }