當前位置: 首頁>>代碼示例>>Java>>正文


Java Repeatable類代碼示例

本文整理匯總了Java中java.lang.annotation.Repeatable的典型用法代碼示例。如果您正苦於以下問題:Java Repeatable類的具體用法?Java Repeatable怎麽用?Java Repeatable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Repeatable類屬於java.lang.annotation包,在下文中一共展示了Repeatable類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getLabels

import java.lang.annotation.Repeatable; //導入依賴的package包/類
private <T extends Annotation> Stream<Label> getLabels(final Description result, final Class<T> labelAnnotation,
                                                       final Function<T, Label> extractor) {

    final List<Label> labels = getAnnotationsOnMethod(result, labelAnnotation).stream()
            .map(extractor)
            .collect(Collectors.toList());

    if (labelAnnotation.isAnnotationPresent(Repeatable.class) || labels.isEmpty()) {
        final Stream<Label> onClassLabels = getAnnotationsOnClass(result, labelAnnotation).stream()
                .map(extractor);
        labels.addAll(onClassLabels.collect(Collectors.toList()));
    }

    return labels.stream();
}
 
開發者ID:allure-framework,項目名稱:allure-java,代碼行數:16,代碼來源:AllureJunit4.java

示例2: getAnnotations

import java.lang.annotation.Repeatable; //導入依賴的package包/類
/**
 * Get all the annotations of given <code>annotationType</code> present in given <code>element</code>, including any
 * meta-annotation and supporting repeatable annotations.
 * @param <A> Annotation type
 * @param element Annotated element to inspect (not null)
 * @param annotationType Annotation type to lookup
 * @return List of detected annotation of given <code>annotationType</code>, an empty List if none found
 */
public static <A extends Annotation> List<A> getAnnotations(AnnotatedElement element, Class<A> annotationType) {
	ObjectUtils.argumentNotNull(element, "AnnotatedElement must be not null");
	ObjectUtils.argumentNotNull(annotationType, "Annotation type must be not null");

	Class<? extends Annotation> repeatableContainerType = null;
	if (annotationType.isAnnotationPresent(Repeatable.class)) {
		repeatableContainerType = annotationType.getAnnotation(Repeatable.class).value();
	}

	List<A> annotations = new LinkedList<>();
	findAnnotations(annotations, element, annotationType, repeatableContainerType);
	return annotations;
}
 
開發者ID:holon-platform,項目名稱:holon-core,代碼行數:22,代碼來源:AnnotationUtils.java

示例3: getAnnotationsByType

import java.lang.annotation.Repeatable; //導入依賴的package包/類
/**
 * Return the annotations present by type. Repeated annotations are taken
 * into account
 */
public static List<AnnotationNode> getAnnotationsByType(List<AnnotationNode> annotations,
        Class<? extends Annotation> annotation) {
    Repeatable repeatable = annotation.getAnnotation(Repeatable.class);
    return getAnnotationsByType(annotations, Type.getInternalName(annotation),
            repeatable != null ? Type.getInternalName(repeatable.value()) : null);
}
 
開發者ID:ruediste,項目名稱:rise,代碼行數:11,代碼來源:AsmUtil.java

示例4: isRepeated

import java.lang.annotation.Repeatable; //導入依賴的package包/類
/**
 * 繰り返されたアノテーションかどうか判定する。
 * <p>屬性「value」に、繰り返しのアノテーション{@link Repeatable}が付與されている
 *    アノテーションの配列を保持しているかどうかで判定する。</p>
 * @param targetAnno
 * @return
 */
private boolean isRepeated(final Annotation targetAnno) {
    
    try {
        final Method method = targetAnno.getClass().getMethod("value");
        
        // 値のクラスタイプがアノテーションの配列かどうかのチェック
        final Class<?> returnType = method.getReturnType();
        if(!(returnType.isArray() && Annotation.class.isAssignableFrom(returnType.getComponentType()))) {
            return false;
        }
        
        final Annotation[] annos = (Annotation[]) method.invoke(targetAnno);
        if(annos.length == 0) {
            return false;
        }
        
        // @Repetableアノテーションが付與されているかどうか
        if(annos[0].annotationType().getAnnotation(Repeatable.class) != null) {
            return true;
        }
        
    } catch (Exception e) {
        
    }
    
    return false;
    
}
 
開發者ID:mygreen,項目名稱:super-csv-annotation,代碼行數:36,代碼來源:AnnotationExpander.java

示例5: getContainer

import java.lang.annotation.Repeatable; //導入依賴的package包/類
private static Class<? extends Annotation> getContainer(Class<? extends Annotation> annoType) {
    Repeatable repeatable = annoType.getAnnotation(Repeatable.class);
    return (repeatable == null) ? null : repeatable.value();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:5,代碼來源:AnnoConstruct.java

示例6: findRepeatableAnnotationOnComposedAnnotation

import java.lang.annotation.Repeatable; //導入依賴的package包/類
@Test
public void findRepeatableAnnotationOnComposedAnnotation() {
	Repeatable repeatable = findAnnotation(MyRepeatableMeta1.class, Repeatable.class);
	assertNotNull(repeatable);
	assertEquals(MyRepeatableContainer.class, repeatable.value());
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:7,代碼來源:AnnotationUtilsTests.java

示例7: isRepeatableAnnotation

import java.lang.annotation.Repeatable; //導入依賴的package包/類
private boolean isRepeatableAnnotation() {
    return annotationClass.isAnnotationPresent(Repeatable.class);
}
 
開發者ID:dataz,項目名稱:dataz-core,代碼行數:4,代碼來源:AnnotationTraverserBuilder.java


注:本文中的java.lang.annotation.Repeatable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。