当前位置: 首页>>代码示例>>Java>>正文


Java MethodInfo.hasAnnotation方法代码示例

本文整理汇总了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;
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-config-api,代码行数:16,代码来源:SubresourceFilter.java

示例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;
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-config-api,代码行数:81,代码来源:EntityAdapter.java


注:本文中的org.jboss.jandex.MethodInfo.hasAnnotation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。