Skip to content

Commit 1c2055f

Browse files
committed
212: Add new Jakarta Annotations
Task-Url: #212
1 parent 5115fdd commit 1c2055f

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/main/java/javax/measure/spi/ServiceProvider.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
* All the methods in this class are safe to use by multiple concurrent threads.
5757
* </p>
5858
*
59-
* @version 2.1, November 16, 2020
59+
* @version 2.2, November 16, 2020
6060
* @author Werner Keil
6161
* @author Martin Desruisseaux
6262
* @since 1.0
@@ -106,9 +106,9 @@ protected ServiceProvider() {
106106
* Allows to define a priority for a registered {@code ServiceProvider} instance.
107107
* When multiple providers are registered in the system, the provider with the highest priority value is taken.
108108
*
109-
* <p>If the {@value #PRIORITY_ANNOTATION} annotation (from JSR-250) is present on the {@code ServiceProvider}
110-
* implementation class, then that annotation is taken and this {@code getPriority()} method is ignored.
111-
* Otherwise – if the {@code Priority} annotation is absent – this method is used as a fallback.</p>
109+
* <p>If the {@value #PRIORITY_ANNOTATION} annotation (from JSR-250) or {@value #JAKARTA_PRIORITY_ANNOTATION} annotation (from Jakarta Annotations) is present on the {@code ServiceProvider}
110+
* implementation class, then that annotation (first if both were present) is taken and this {@code getPriority()} method is ignored.
111+
* Otherwise – if a {@code Priority} annotation is absent – this method is used as a fallback.</p>
112112
*
113113
* @return the provider's priority (default is 0).
114114
*/
@@ -242,8 +242,8 @@ public boolean test(ServiceProvider provider) {
242242

243243
/**
244244
* Returns the priority of the given service provider.
245-
* This method looks for the {@value #PRIORITY_ANNOTATION} annotation,
246-
* and if none are found fallbacks on {@link ServiceProvider#getPriority()}.
245+
* This method looks for the {@value #PRIORITY_ANNOTATION} annotation or {@value #JAKARTA_PRIORITY_ANNOTATION},
246+
* and if none are found falls back on {@link ServiceProvider#getPriority()}.
247247
*/
248248
private int priority(ServiceProvider provider) {
249249
if (priorityGetter != null) {
@@ -269,7 +269,9 @@ private int priority(ServiceProvider provider) {
269269
*/
270270
@Override
271271
public int compare(final ServiceProvider p1, final ServiceProvider p2) {
272-
return Integer.compare(priority(p1), priority(p2));
272+
final int i1 = priority(p1);
273+
final int i2 = priority(p2);
274+
return Integer.compare(i2, i1); // reverse order, higher number first.
273275
}
274276

275277
/**

0 commit comments

Comments
 (0)