本文整理了Java中java.lang.annotation.Retention.value
方法的一些代码示例,展示了Retention.value
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Retention.value
方法的具体详情如下:
包路径:java.lang.annotation.Retention
类名称:Retention
方法名:value
暂无
代码示例来源:origin: google/error-prone
private static RetentionPolicy effectiveRetentionPolicy(Element element) {
RetentionPolicy retentionPolicy = RetentionPolicy.CLASS;
Retention retentionAnnotation = element.getAnnotation(Retention.class);
if (retentionAnnotation != null) {
retentionPolicy = retentionAnnotation.value();
}
return retentionPolicy;
}
代码示例来源:origin: com.google.inject/guice
/** Returns true if the given annotation is retained at runtime. */
public static boolean isRetainedAtRuntime(Class<? extends Annotation> annotationType) {
Retention retention = annotationType.getAnnotation(Retention.class);
return retention != null && retention.value() == RetentionPolicy.RUNTIME;
}
代码示例来源:origin: looly/hutool
/**
* 获取注解类的保留时间,可选值 SOURCE(源码时),CLASS(编译时),RUNTIME(运行时),默认为 CLASS
*
* @param annotationType 注解类
* @return 保留时间枚举
*/
public static RetentionPolicy getRetentionPolicy(Class<? extends Annotation> annotationType) {
final Retention retention = annotationType.getAnnotation(Retention.class);
if (null == retention) {
return RetentionPolicy.CLASS;
}
return retention.value();
}
代码示例来源:origin: looly/hutool
/**
* 获取注解类的保留时间,可选值 SOURCE(源码时),CLASS(编译时),RUNTIME(运行时),默认为 CLASS
*
* @param annotationType 注解类
* @return 保留时间枚举
*/
public static RetentionPolicy getRetentionPolicy(Class<? extends Annotation> annotationType) {
final Retention retention = annotationType.getAnnotation(Retention.class);
if (null == retention) {
return RetentionPolicy.CLASS;
}
return retention.value();
}
代码示例来源:origin: com.google.inject/guice
private static void checkForRuntimeRetention(Class<? extends Annotation> annotationType) {
Retention retention = annotationType.getAnnotation(Retention.class);
checkArgument(
retention != null && retention.value() == RetentionPolicy.RUNTIME,
"Annotation %s is missing RUNTIME retention",
annotationType.getSimpleName());
}
代码示例来源:origin: facebook/litho
/**
* We consider an annotation to be valid for extraction if it's not an internal annotation (i.e.
* is in the <code>com.facebook.litho</code> package and is not a source-only annotation.
*
* @return Whether or not to extract the given annotation.
*/
private static boolean isValidAnnotation(AnnotationMirror annotation) {
final Retention retention =
annotation.getAnnotationType().asElement().getAnnotation(Retention.class);
if (retention != null && retention.value() == RetentionPolicy.SOURCE) {
return false;
}
return !annotation.getAnnotationType().toString().startsWith("com.facebook.");
}
}
代码示例来源:origin: apache/incubator-dubbo
RetentionPolicy retentionPolicy = retention.value();
代码示例来源:origin: apache/incubator-dubbo
RetentionPolicy retentionPolicy = retention.value();
代码示例来源:origin: libgdx/libgdx
if (retention == null || retention.value() != RetentionPolicy.RUNTIME) {
continue;
代码示例来源:origin: libgdx/libgdx
if (retention == null || retention.value() != RetentionPolicy.RUNTIME) {
continue;
代码示例来源:origin: redisson/redisson
/**
* {@inheritDoc}
*/
public RetentionPolicy getRetention() {
AnnotationDescription.Loadable<Retention> retention = getAnnotationType().getDeclaredAnnotations().ofType(Retention.class);
return retention == null
? RetentionPolicy.CLASS
: retention.loadSilent().value();
}
代码示例来源:origin: Sable/soot
switch (r.value()) {
case CLASS:
retPolicy = AnnotationConstants.RUNTIME_INVISIBLE;
代码示例来源:origin: org.netbeans.api/org-openide-util-lookup
if (ret == null || ret.value() != RetentionPolicy.SOURCE) {
processingEnv.getMessager().printMessage(
Diagnostic.Kind.ERROR,
代码示例来源:origin: org.codehaus.groovy/groovy
public void visitAnnotations(AnnotatedNode node) {
List<AnnotationNode> annotations = node.getAnnotations();
if (annotations.isEmpty()) return;
Map<String, AnnotationNode> tmpAnnotations = new HashMap<String, AnnotationNode>();
ClassNode annType;
for (AnnotationNode an : annotations) {
// skip built-in properties
if (an.isBuiltIn()) continue;
annType = an.getClassNode();
resolveOrFail(annType, ", unable to find class for annotation", an);
for (Map.Entry<String, Expression> member : an.getMembers().entrySet()) {
Expression newValue = transform(member.getValue());
Expression adjusted = transformInlineConstants(newValue);
member.setValue(adjusted);
checkAnnotationMemberValue(adjusted);
}
if (annType.isResolved()) {
Class annTypeClass = annType.getTypeClass();
Retention retAnn = (Retention) annTypeClass.getAnnotation(Retention.class);
if (retAnn != null && retAnn.value().equals(RetentionPolicy.RUNTIME) && !isRepeatable(annTypeClass)) {
// remember runtime/non-repeatable annos (auto collecting of Repeatable annotations is handled elsewhere)
AnnotationNode anyPrevAnnNode = tmpAnnotations.put(annTypeClass.getName(), an);
if (anyPrevAnnNode != null) {
addError("Cannot specify duplicate annotation on the same member : " + annType.getName(), an);
}
}
}
}
}
代码示例来源:origin: google/guava
rootLocaleFormat("%s must have RUNTIME RetentionPolicy.", annotationClass),
RetentionPolicy.RUNTIME,
retentionPolicy.value());
assertNotNull(
rootLocaleFormat("%s must be inherited.", annotationClass),
代码示例来源:origin: org.codehaus.groovy/groovy
if (type == Retention.class) {
Retention r = (Retention) annotation;
RetentionPolicy value = r.value();
setRetentionPolicy(value, node);
node.setMember("value", new PropertyExpression(
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Returns true if the given annotation is retained at runtime.
*/
public static boolean isRetainedAtRuntime(Class<? extends Annotation> annotationType) {
Retention retention = annotationType.getAnnotation(Retention.class);
return retention != null && retention.value() == RetentionPolicy.RUNTIME;
}
代码示例来源:origin: org.elasticsearch/elasticsearch
private static void checkForRuntimeRetention(
Class<? extends Annotation> annotationType) {
Retention retention = annotationType.getAnnotation(Retention.class);
if (retention == null || retention.value() != RetentionPolicy.RUNTIME) {
throw new IllegalArgumentException("Annotation " + annotationType.getSimpleName() + " is missing RUNTIME retention");
}
}
代码示例来源:origin: stephanenicolas/toothpick
private void checkScopeAnnotationValidity(TypeElement annotation) {
if (annotation.getAnnotation(Scope.class) == null) {
error(annotation, "Scope Annotation %s does not contain Scope annotation.", annotation.getQualifiedName());
return;
}
Retention retention = annotation.getAnnotation(Retention.class);
if (retention == null || retention.value() != RetentionPolicy.RUNTIME) {
error(annotation, "Scope Annotation %s does not have RUNTIME retention policy.", annotation.getQualifiedName());
}
}
代码示例来源:origin: hibernate/hibernate-validator
@Override
public Set<ConstraintCheckIssue> checkAnnotationType(TypeElement element, AnnotationMirror annotation) {
Retention retention = element.getAnnotation( Retention.class );
if ( retention == null ) {
return CollectionHelper.asSet(
ConstraintCheckIssue.error( element, null, "CONSTRAINT_TYPE_WITH_MISSING_OR_WRONG_RETENTION" )
);
}
if ( !retention.value().equals( RetentionPolicy.RUNTIME ) ) {
return CollectionHelper.asSet(
ConstraintCheckIssue.error(
element,
annotationApiHelper.getMirror( element.getAnnotationMirrors(), Retention.class ),
"CONSTRAINT_TYPE_WITH_MISSING_OR_WRONG_RETENTION"
)
);
}
return Collections.emptySet();
}
内容来源于网络,如有侵权,请联系作者删除!