use of javax.annotation.Priority in project jsr354-ri-bp by JavaMoney.
the class OSGIServiceComparator method getPriority.
/**
* Checks the given type optionally annotated with a @Priority. If present the annotation's value is evaluated.
* If no such annotation is present, a default priority {@code 1} is returned.
*
* @param type the type, not {@code null}.
* @return a priority, by default 1.
*/
public static int getPriority(Class<?> type) {
int prio = 1;
Priority priority = type.getAnnotation(Priority.class);
if (priority != null) {
prio = priority.value();
}
return prio;
}
use of javax.annotation.Priority in project jsr354-ri-bp by JavaMoney.
the class PriorityAwareServiceProvider method compareServices.
public static int compareServices(Object o1, Object o2) {
int prio1 = 0;
int prio2 = 0;
Priority prio1Annot = o1.getClass().getAnnotation(Priority.class);
if (prio1Annot != null) {
prio1 = prio1Annot.value();
}
Priority prio2Annot = o2.getClass().getAnnotation(Priority.class);
if (prio2Annot != null) {
prio2 = prio2Annot.value();
}
if (prio1 < prio2) {
return 1;
}
if (prio2 < prio1) {
return -1;
}
return o2.getClass().getSimpleName().compareTo(o1.getClass().getSimpleName());
}
use of javax.annotation.Priority in project redkale by redkale.
the class Filter method compareTo.
@Override
public int compareTo(Object o) {
if (!(o instanceof Filter))
return 1;
Priority p1 = this.getClass().getAnnotation(Priority.class);
Priority p2 = o.getClass().getAnnotation(Priority.class);
return (p2 == null ? 0 : p2.value()) - (p1 == null ? 0 : p1.value());
}
use of javax.annotation.Priority in project jsr354-ri by JavaMoney.
the class PriorityServiceComparator method getPriority.
/**
* Checks the given type optionally annotated with a @Priority. If present the annotation's value is evaluated.
* If no such annotation is present, a default priority {@code 1} is returned.
*
* @param type the type, not {@code null}.
* @return a priority, by default 1.
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public static int getPriority(Class type) {
int prio = 1;
Priority priority = (Priority) type.getAnnotation(Priority.class);
if (priority != null) {
prio = priority.value();
}
return prio;
}
use of javax.annotation.Priority in project jsr354-ri by JavaMoney.
the class OSGIServiceComparator method getPriority.
/**
* Checks the given type optionally annotated with a @Priority. If present the annotation's value is evaluated.
* If no such annotation is present, a default priority {@code 1} is returned.
*
* @param type the type, not {@code null}.
* @return a priority, by default 1.
*/
public static int getPriority(Class<?> type) {
int prio = 1;
Priority priority = type.getAnnotation(Priority.class);
if (priority != null) {
prio = priority.value();
}
return prio;
}
Aggregations