本文整理汇总了Java中javax.annotation.Priority.value方法的典型用法代码示例。如果您正苦于以下问题:Java Priority.value方法的具体用法?Java Priority.value怎么用?Java Priority.value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.annotation.Priority
的用法示例。
在下文中一共展示了Priority.value方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compareServices
import javax.annotation.Priority; //导入方法依赖的package包/类
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());
}
示例2: getPriority
import javax.annotation.Priority; //导入方法依赖的package包/类
/**
* The priority of this mapper. By default, it will use the {@link Priority} annotation's value as the priority.
* If no annotation is present, it uses a default priority of {@link Priorities#USER}.
* @return the priority of this mapper
*/
default int getPriority() {
Priority priority = getClass().getAnnotation(Priority.class);
if(priority == null) {
return DEFAULT_PRIORITY;
}
return priority.value();
}
示例3: getPriority
import javax.annotation.Priority; //导入方法依赖的package包/类
private int getPriority(Converter<?> converter) {
int priority = 100;
Priority priorityAnnotation = converter.getClass().getAnnotation(Priority.class);
if (priorityAnnotation != null) {
priority = priorityAnnotation.value();
}
return priority;
}
示例4: returnPrimaryOrHighestPriorityBean
import javax.annotation.Priority; //导入方法依赖的package包/类
private Object returnPrimaryOrHighestPriorityBean(List<Bean> beans) {
long highestPriority = Integer.MIN_VALUE;
Object highestPrioBean = null;
for (Bean bean : beans) {
if (bean.isPrimary()) {
return bean.getInstance();
}
// TODO figure out to retrieve order from BeanDefinition /
// BeanDeclaration
Object instance = bean.getInstance();
Order order = instance.getClass().getAnnotation(Order.class);
if (order != null) {
if (order.value() > highestPriority) {
highestPriority = order.value();
highestPrioBean = instance;
}
}
Priority priority = instance.getClass().getAnnotation(Priority.class);
if (priority != null) {
if (priority.value() > highestPriority) {
highestPriority = priority.value();
highestPrioBean = instance;
}
}
}
return highestPrioBean;
}
开发者ID:thomasdarimont,项目名称:spring-boot-cdi-instance-example,代码行数:35,代码来源:CustomAutowireCandidateResolver.java
示例5: compareTo
import javax.annotation.Priority; //导入方法依赖的package包/类
@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());
}
示例6: getPriority
import javax.annotation.Priority; //导入方法依赖的package包/类
/**
* 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;
}
示例7: getPriority
import javax.annotation.Priority; //导入方法依赖的package包/类
/**
* Checks the given instance for a @Priority annotation. If present the annotation's value is evaluated. If no such
* annotation is present, a default priority of {@code 1} is returned.
* @param o the instance, not {@code null}.
* @return a priority, by default 1.
*/
public static int getPriority(Object o){
int prio = 1; //X TODO discuss default priority
Priority priority = o.getClass().getAnnotation(Priority.class);
if (priority != null) {
prio = priority.value();
}
return prio;
}
示例8: comparePropertyFilters
import javax.annotation.Priority; //导入方法依赖的package包/类
/**
* Compare 2 filters for ordering the filter chain.
*
* @param filter1 the first filter
* @param filter2 the second filter
* @return the comparison result
*/
private int comparePropertyFilters(PropertyFilter filter1, PropertyFilter filter2) {
Priority prio1 = filter1.getClass().getAnnotation(Priority.class);
Priority prio2 = filter2.getClass().getAnnotation(Priority.class);
int ord1 = prio1 != null ? prio1.value() : 0;
int ord2 = prio2 != null ? prio2.value() : 0;
if (ord1 < ord2) {
return -1;
} else if (ord1 > ord2) {
return 1;
} else {
return filter1.getClass().getName().compareTo(filter2.getClass().getName());
}
}
示例9: getPriority
import javax.annotation.Priority; //导入方法依赖的package包/类
/**
* 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<? extends Object> type) {
int prio = 1;
Priority priority = type.getAnnotation(Priority.class);
if (priority != null) {
prio = priority.value();
}
return prio;
}
示例10: getConverterPriority
import javax.annotation.Priority; //导入方法依赖的package包/类
private int getConverterPriority(Class<? extends Converter<?>> converter) {
Priority priority = converter.getAnnotation(Priority.class);
return priority == null ? 0 : priority.value();
}