當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。