本文整理汇总了Java中org.jboss.jandex.MethodInfo.hasAnnotation方法的典型用法代码示例。如果您正苦于以下问题:Java MethodInfo.hasAnnotation方法的具体用法?Java MethodInfo.hasAnnotation怎么用?Java MethodInfo.hasAnnotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.jandex.MethodInfo
的用法示例。
在下文中一共展示了MethodInfo.hasAnnotation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: __invoke
import org.jboss.jandex.MethodInfo; //导入方法依赖的package包/类
private static List<Method> __invoke(Class<?> clazz, Index index, Comparator<Method> comparator) throws NoSuchMethodException {
ArrayList methods = new ArrayList();
ClassInfo clazzInfo = index.getClassByName(DotName.createSimple(clazz.getName()));
for (MethodInfo method : clazzInfo.methods()) {
if (method.hasAnnotation(IndexFactory.SUBRESOURCE_META)) {
methods.add(clazz.getMethod(method.name()));
}
}
if (clazzInfo.superName() != null && clazz.getSuperclass() != java.lang.Object.class) {
index = IndexFactory.createIndex(clazz.getSuperclass());
return __invoke(clazz.getSuperclass(), index, comparator);
}
Collections.sort(methods, comparator);
return methods;
}
示例2: fromDMR
import org.jboss.jandex.MethodInfo; //导入方法依赖的package包/类
/**
* Converts a DMR {@link ModelNode} to a java entity of type T.
*
* @param modelNode a ModelNode
* @return an entity representation of type T
*/
@SuppressWarnings("unchecked")
public T fromDMR(String keyValue, ModelNode modelNode) throws Exception {
if (isBaseTypeAdapter()) return convertToBaseType(modelNode);
ModelNode actualPayload = null;
if (ModelType.OBJECT.equals(modelNode.getType())) {
actualPayload = modelNode;
}
/* else if(ModelType.PROPERTY.equals(modelNode.getType()))
{
final Property property = modelNode.asProperty();
actualPayload = property.getValue();
}*/
else {
throw new IllegalArgumentException("Unsupported ModelType " + modelNode.getType() + ": " + modelNode);
}
ClassInfo clazz = index.getClassByName(DotName.createSimple(getType().getCanonicalName()));
T entity = null;
boolean implicitKey = clazz.annotations().containsKey(IndexFactory.IMPLICIT_META);
if (implicitKey) {
// implicit (aka singleton) resource
Constructor<?> ctor = getType().getConstructor();
entity = (T) ctor.newInstance();
} else {
// explicit (regular) resource
entity = (T) getType().getConstructor(String.class)
.newInstance(keyValue);
}
for (MethodInfo method : clazz.methods()) {
if (method.hasAnnotation(IndexFactory.BINDING_META)) {
Method getter = entity.getClass().getMethod(method.name());
Class<?> propertyType = getter.getReturnType();
ModelNodeBinding binding = getter.getDeclaredAnnotation(ModelNodeBinding.class);
String detypedName = binding.detypedName();
ModelNode dmrPayload = actualPayload.get(detypedName);
// EXPRESSIONS
if(ModelType.EXPRESSION == dmrPayload.getType()) {
ValueExpression expression = dmrPayload.asExpression();
((Map)entity).put(method.name(), expression.getExpressionString());
continue; // expression have precedence over real values
}
// VALUES
ModelType dmrType = Types.resolveModelType(propertyType);
if (dmrType == ModelType.LIST) {
new ListTypeAdapter().fromDmr(entity, method.name(), dmrType, propertyType, dmrPayload);
} else if (dmrType == ModelType.OBJECT) {
new MapTypeAdapter().fromDmr(entity, method.name(), dmrType, propertyType, dmrPayload);
} else {
new SimpleTypeAdapter().fromDmr(entity, method.name(), dmrType, propertyType, dmrPayload);
}
}
}
return entity;
}