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


Java Annotation.annotationType方法代码示例

本文整理汇总了Java中java.lang.annotation.Annotation.annotationType方法的典型用法代码示例。如果您正苦于以下问题:Java Annotation.annotationType方法的具体用法?Java Annotation.annotationType怎么用?Java Annotation.annotationType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.annotation.Annotation的用法示例。


在下文中一共展示了Annotation.annotationType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findBindingAnnotation

import java.lang.annotation.Annotation; //导入方法依赖的package包/类
/**
 * Returns the binding annotation on {@code member}, or null if there isn't one.
 */
public static Annotation findBindingAnnotation(
    Errors errors, Member member, Annotation[] annotations) {
  Annotation found = null;

  for (Annotation annotation : annotations) {
    Class<? extends Annotation> annotationType = annotation.annotationType();
    if (isBindingAnnotation(annotationType)) {
      if (found != null) {
        errors.duplicateBindingAnnotations(member, found.annotationType(), annotationType);
      } else {
        found = annotation;
      }
    }
  }

  return found;
}
 
开发者ID:maetrive,项目名称:businessworks,代码行数:21,代码来源:Annotations.java

示例2: isInjectedField

import java.lang.annotation.Annotation; //导入方法依赖的package包/类
private static boolean isInjectedField(final Field field) {
    for (final Annotation a : field.getDeclaredAnnotations()) {
        final Class<?> t = a.annotationType();
        if (t == javax.inject.Inject.class ||
                t == javax.ws.rs.core.Context.class ||
                t == javax.ws.rs.CookieParam.class ||
                t == javax.ws.rs.FormParam.class ||
                t == javax.ws.rs.HeaderParam.class ||
                t == javax.ws.rs.QueryParam.class ||
                t == javax.ws.rs.PathParam.class ||
                t == javax.ws.rs.BeanParam.class ||
                t == OptionalClasses.PERSISTENCE_CONTEXT) {
            return true;
        }
    }
    return false;
}
 
开发者ID:minijax,项目名称:minijax,代码行数:18,代码来源:ConstructorProviderBuilder.java

示例3: processAnnotations

import java.lang.annotation.Annotation; //导入方法依赖的package包/类
private void processAnnotations(Object device) {

		if (device==null) return;

		final Method[] methods = device.getClass().getMethods();
		for (int i = 0; i < methods.length; i++) {
			final Annotation[] as = methods[i].getAnnotations();
			if (as!=null) for (Annotation annotation : as) {
				Class<? extends Annotation> clazz = annotation.annotationType();
				if (this.annotations.contains(clazz)) {
					Collection<MethodWrapper> ms = annotationMap.get(clazz);
					if (ms == null) {
						ms = new ArrayList<>(31);
						annotationMap.put(clazz, ms);
					}
					ms.add(new MethodWrapper(clazz, device, methods[i]));
				}
			}
		}
	}
 
开发者ID:eclipse,项目名称:scanning,代码行数:21,代码来源:AnnotationManager.java

示例4: getEntityAnnos

import java.lang.annotation.Annotation; //导入方法依赖的package包/类
private static List<Map<String, Object>> getEntityAnnos(Object targetClass, String annotationName) {
	Annotation[] anno = null;
	if (targetClass instanceof Field)
		anno = ((Field) targetClass).getAnnotations();
	else
		anno = ((Class<?>) targetClass).getAnnotations();
	List<Map<String, Object>> l = new ArrayList<Map<String, Object>>();
	for (Annotation annotation : anno) {
		Class<? extends Annotation> type = annotation.annotationType();
		String cName = type.getName();
		if (matchNameCheck(annotationName, cName)) {
			l.add(changeAnnotationValuesToMap(annotation, type));
		}
	}
	return l;
}
 
开发者ID:drinkjava2,项目名称:jDialects,代码行数:17,代码来源:TableModelUtilsOfEntity.java

示例5: invokeAnnotationByField

import java.lang.annotation.Annotation; //导入方法依赖的package包/类
/**
 * Invokes the annotation of the given field
 *
 * @param field           field
 * @param annotationClazz annotation
 * @param <T>             returnType
 * @return returnValue
 */
public static <T extends Annotation> T invokeAnnotationByField(Field field, Class<T> annotationClazz) {
    if (field == null)
        throw new IllegalArgumentException("Field cannot be null!");
    if (annotationClazz == null)
        throw new IllegalArgumentException("AnnotationClass cannot be null!");
    for (final Annotation annotation : field.getDeclaredAnnotations()) {
        if (annotation.annotationType() == annotationClazz)
            return (T) annotation;
    }
    return null;
}
 
开发者ID:Shynixn,项目名称:AstralEdit,代码行数:20,代码来源:ReflectionUtils.java

示例6: getAnnotation

import java.lang.annotation.Annotation; //导入方法依赖的package包/类
protected Class<?> getAnnotation(Class<?> c) {
  // we should get only declared annotations, not inherited ones
  Annotation[] anns = c.getDeclaredAnnotations();

  for (Annotation ann : anns) {
    // Hadoop clearly got it wrong for not making the annotation values (private, public, ..)
    // an enum instead we have three independent annotations!
    Class<?> type = ann.annotationType();
    if (isInterfaceAudienceClass(type)) {
      return type;
    }
  }
  return null;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:15,代码来源:TestInterfaceAudienceAnnotations.java

示例7: getAlwaysRunFromAnnotation

import java.lang.annotation.Annotation; //导入方法依赖的package包/类
private boolean getAlwaysRunFromAnnotation(final Annotation methodAnnotation) {
    if (methodAnnotation.annotationType() == OurBeforeSuite.class) {
        return ((OurBeforeSuite) methodAnnotation).alwaysRun();
    }
    if (methodAnnotation.annotationType() == OurBeforeGroups.class) {
        return ((OurBeforeGroups) methodAnnotation).alwaysRun();
    }
    if (methodAnnotation.annotationType() == OurAfterGroups.class) {
        return ((OurAfterGroups) methodAnnotation).alwaysRun();
    }

    return methodAnnotation.annotationType() != OurAfterSuite.class || ((OurAfterSuite) methodAnnotation).alwaysRun();
}
 
开发者ID:WileyLabs,项目名称:teasy,代码行数:14,代码来源:MethodsInvoker.java

示例8: getValueAnnotation

import java.lang.annotation.Annotation; //导入方法依赖的package包/类
/**
 * Gets the class of the value annotation belonging
 * to a field, null if there is none.
 *
 * @param field Field being checked
 * @return The value annotation of the field
 */
private static Class<? extends Annotation> getValueAnnotation(Field field) {
    // Values must have a label annotation
    if (!field.isAnnotationPresent(Label.class))
        return null;

    // Find a valid value type annotation, if any
    Annotation a = Arrays.stream(field.getDeclaredAnnotations())
            .filter(annotation -> annotation.annotationType().isAnnotationPresent(ValueDefinition.class))
            .findFirst().orElse(null);

    return a != null ? a.annotationType() : null;
}
 
开发者ID:ImpactDevelopment,项目名称:ClientAPI,代码行数:20,代码来源:Values.java

示例9: findAnnotation

import java.lang.annotation.Annotation; //导入方法依赖的package包/类
@Nullable public static Annotation findAnnotation(Set<? extends Annotation> annotations,
    Class<? extends Annotation> annotationClass) {
  if (annotations.isEmpty()) return null; // Save an iterator in the common case.
  for (Annotation annotation : annotations) {
    if (annotation.annotationType() == annotationClass) return annotation;
  }
  return null;
}
 
开发者ID:hzsweers,项目名称:inspector,代码行数:9,代码来源:IntRangeValidator.java

示例10: get

import java.lang.annotation.Annotation; //导入方法依赖的package包/类
/**
 * Finds the specified annotation from the array and returns it.
 * Null if not found.
 */
public <A extends Annotation> A get( Class<A> annotationType ) {
    for (Annotation a : annotations) {
        if(a.annotationType()==annotationType)
            return annotationType.cast(a);
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:TypeInfo.java

示例11: printArrContents

import java.lang.annotation.Annotation; //导入方法依赖的package包/类
private static void printArrContents(Annotation[] actualAnnos) {
    System.out.print("Actual Arr Values: ");
    for (Annotation a : actualAnnos) {
        if (a != null && a.annotationType() != null) {
            System.out.print("[" + a.toString() + "]");
        } else {
            System.out.println("[null]");
        }
    }
    System.out.println();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:ReflectionTest.java

示例12: invokeAnnotationByMethod

import java.lang.annotation.Annotation; //导入方法依赖的package包/类
/**
 * Invokes the annotation of the given method
 *
 * @param method          method
 * @param annotationClazz annotation
 * @param <T>             returnType
 * @return returnValue
 */
public static <T extends Annotation> T invokeAnnotationByMethod(Method method, Class<T> annotationClazz) {
    if (method == null)
        throw new IllegalArgumentException("Method cannot be null!");
    if (annotationClazz == null)
        throw new IllegalArgumentException("AnnotationClass cannot be null!");
    for (final Annotation annotation : method.getDeclaredAnnotations()) {
        if (annotation.annotationType() == annotationClazz)
            return (T) annotation;
    }
    return null;
}
 
开发者ID:Shynixn,项目名称:PetBlocks,代码行数:20,代码来源:ReflectionUtils.java

示例13: hasRequestBodyAnnotation

import java.lang.annotation.Annotation; //导入方法依赖的package包/类
private static boolean hasRequestBodyAnnotation(Annotation[][] annotations) {
    if (annotations.length == 1) {
        Annotation[] containerAnnotations = annotations[0];
        for (Annotation annotation : containerAnnotations) {
            Type annotationType = annotation.annotationType();
            if (annotationType == RequestBody.class) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:pCloud,项目名称:pcloud-networking-java,代码行数:13,代码来源:MultiCallWrappedApiMethod.java

示例14: processAnnotation

import java.lang.annotation.Annotation; //导入方法依赖的package包/类
private void processAnnotation(final Annotation annotation) {
    final Class<? extends Annotation> annType = annotation.annotationType();

    if (annType == Context.class) {
        setStrategy(Strategy.CONTEXT);

    } else if (annType == CookieParam.class) {
        processCookieParamAnnotation((CookieParam) annotation);

    } else if (annType == FormParam.class) {
        processFormParamAnnotation((FormParam) annotation);

    } else if (annType == HeaderParam.class) {
        processHeaderParamAnnotation((HeaderParam) annotation);

    } else if (annType == Named.class) {
        processNamedAnnotation((Named) annotation);

    } else if (annType == PathParam.class) {
        processPathParamAnnotation((PathParam) annotation);

    } else if (annType == OptionalClasses.PERSISTENCE_CONTEXT) {
        processPersistenceContextAnnotation((PersistenceContext) annotation);

    } else if (annType == QueryParam.class) {
        processQueryParamAnnotation((QueryParam) annotation);

    } else if (annType == DefaultValue.class) {
        defaultValue = (DefaultValue) annotation;

    } else if (annType.isAnnotationPresent(Qualifier.class)) {
        processQualifierAnnotation(annType);
    }
}
 
开发者ID:minijax,项目名称:minijax,代码行数:35,代码来源:Key.java

示例15: search

import java.lang.annotation.Annotation; //导入方法依赖的package包/类
private Class<? extends Annotation> search(
        final Field field
) {
    final Annotation[] annotations = field.getDeclaredAnnotations();
    final Set<Class<? extends Annotation>>
            annotationCls = Plugins.INFIX_MAP.keySet();
    Class<? extends Annotation> hitted = null;
    for (final Annotation annotation : annotations) {
        if (annotationCls.contains(annotation.annotationType())) {
            hitted = annotation.annotationType();
            break;
        }
    }
    return hitted;
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:16,代码来源:AffluxScatter.java


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