本文整理汇总了Java中java.lang.annotation.RetentionPolicy.SOURCE属性的典型用法代码示例。如果您正苦于以下问题:Java RetentionPolicy.SOURCE属性的具体用法?Java RetentionPolicy.SOURCE怎么用?Java RetentionPolicy.SOURCE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.lang.annotation.RetentionPolicy
的用法示例。
在下文中一共展示了RetentionPolicy.SOURCE属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testAttributes
private void testAttributes(
TestCase.TestMemberInfo member,
ClassFile classFile,
Supplier<Attributes> attributes)
throws ConstantPoolException {
Map<String, Annotation> actualInvisible = collectAnnotations(
classFile,
member,
attributes.get(),
Attribute.RuntimeInvisibleAnnotations);
Map<String, Annotation> actualVisible = collectAnnotations(
classFile,
member,
attributes.get(),
Attribute.RuntimeVisibleAnnotations);
checkEquals(actualInvisible.keySet(),
member.getRuntimeInvisibleAnnotations(), "RuntimeInvisibleAnnotations");
checkEquals(actualVisible.keySet(),
member.getRuntimeVisibleAnnotations(), "RuntimeVisibleAnnotations");
for (TestAnnotationInfo expectedAnnotation : member.annotations.values()) {
RetentionPolicy policy = getRetentionPolicy(expectedAnnotation.annotationName);
if (policy == RetentionPolicy.SOURCE) {
continue;
}
printf("Testing: isVisible: %s %s%n", policy.toString(), expectedAnnotation.annotationName);
Annotation actualAnnotation =
(policy == RetentionPolicy.RUNTIME ? actualVisible : actualInvisible)
.get(expectedAnnotation.annotationName);
if (checkNotNull(actualAnnotation, "Annotation is found : "
+ expectedAnnotation.annotationName)) {
expectedAnnotation.testAnnotation(this, classFile, actualAnnotation);
}
}
}
示例2: retention
/**
* The retention policy for annotations of this type.
* If non-null, this is called a "top-level" annotation definition.
* It may be null for annotations that are used only as a field of other
* annotations.
*/
public /*@Nullable*/ RetentionPolicy retention() {
if (tlAnnotationsHere.contains(Annotations.aRetentionClass)) {
return RetentionPolicy.CLASS;
} else if (tlAnnotationsHere.contains(Annotations.aRetentionRuntime)) {
return RetentionPolicy.RUNTIME;
} else if (tlAnnotationsHere.contains(Annotations.aRetentionSource)) {
return RetentionPolicy.SOURCE;
} else {
return null;
}
}
示例3: write
@Override
public void write(AnnotatableVisitor writer)
{
RetentionPolicy retention = this.getRetention();
if (retention != RetentionPolicy.SOURCE)
{
this.write(writer.visitAnnotation(ClassFormat.internalToExtended(this.type.getInternalName()),
retention == RetentionPolicy.RUNTIME));
}
}
示例4: isSource
@Override
public boolean isSource() {
IsAnnotation retention = retentionAnno.get();
if (retention == null) {
return false;
}
IsMethod value = retention.getMethod("value");
IsAnnotationValue val = retention.getValue(value);
return RetentionPolicy.SOURCE == val.getRawValue();
}
示例5: enum1
@Value.Default
@SerializedName("e1")
public RetentionPolicy enum1() {
return RetentionPolicy.SOURCE;
}
示例6: isRetentionSource
private static boolean isRetentionSource(Class<? extends Annotation> annotationType) {
return annotationType.getAnnotation(Retention.class) != null
&& (annotationType.getAnnotation(Retention.class).value() == RetentionPolicy.SOURCE);
}
示例7: hasSourceRetention
public static boolean hasSourceRetention(Element element) {
return effectiveRetentionPolicy(element) == RetentionPolicy.SOURCE;
}
示例8: setAnnotationVisibility
/**
* Set annotation visibility (to match the annotation retention policy).
*
* @param annotationVisibility
* The annotation visibility: RetentionPolicy.RUNTIME matches only runtime-visible annotations. The
* default value, RetentionPolicy.CLASS, matches all annotations (both runtime-visible and
* runtime-invisible). RetentionPolicy.SOURCE will cause an IllegalArgumentException to be thrown,
* since SOURCE-annotated annotations are not retained in classfiles.
* @return this (for method chaining).
*/
public FastClasspathScanner setAnnotationVisibility(final RetentionPolicy annotationVisibility) {
if (annotationVisibility == RetentionPolicy.SOURCE) {
throw new IllegalArgumentException("RetentionPolicy.SOURCE annotations are not retained in classfiles");
}
getScanSpec().annotationVisibility = annotationVisibility;
return this;
}