本文整理汇总了Java中java.lang.annotation.RetentionPolicy.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Java RetentionPolicy.valueOf方法的具体用法?Java RetentionPolicy.valueOf怎么用?Java RetentionPolicy.valueOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.annotation.RetentionPolicy
的用法示例。
在下文中一共展示了RetentionPolicy.valueOf方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitType
import java.lang.annotation.RetentionPolicy; //导入方法依赖的package包/类
@Override
protected void visitType(TypeDefinition td) {
if (!td.isAnnotation())
return;
DeclaredAnnotation da = getOrCreate(td);
for (CustomAnnotation ca : td.getAnnotations()) {
if (Types.is(ca.getAnnotationType(), Retention.class)) {
for (AnnotationParameter ap : ca.getParameters()) {
if (ap.getMember().equals("value")) {
AnnotationElement value = ap.getValue();
if (value instanceof EnumAnnotationElement) {
EnumAnnotationElement enumValue = (EnumAnnotationElement) value;
if (Types.is(enumValue.getEnumType(), RetentionPolicy.class)) {
da.policy = RetentionPolicy.valueOf(enumValue.getEnumConstantName());
}
}
}
}
}
}
}
示例2: ClassRepr
import java.lang.annotation.RetentionPolicy; //导入方法依赖的package包/类
public ClassRepr(final DependencyContext context, final DataInput in) {
super(in);
try {
this.myContext = context;
myFileName = DataInputOutputUtil.readINT(in);
mySuperClass = (TypeRepr.ClassType)TypeRepr.externalizer(context).read(in);
myInterfaces = (Set<TypeRepr.AbstractType>)RW.read(TypeRepr.externalizer(context), new THashSet<TypeRepr.AbstractType>(1), in);
myFields = (Set<FieldRepr>)RW.read(FieldRepr.externalizer(context), new THashSet<FieldRepr>(), in);
myMethods = (Set<MethodRepr>)RW.read(MethodRepr.externalizer(context), new THashSet<MethodRepr>(), in);
myAnnotationTargets = (Set<ElemType>)RW.read(UsageRepr.AnnotationUsage.elementTypeExternalizer, EnumSet.noneOf(ElemType.class), in);
final String s = RW.readUTF(in);
myRetentionPolicy = s.length() == 0 ? null : RetentionPolicy.valueOf(s);
myOuterClassName = DataInputOutputUtil.readINT(in);
int flags = DataInputOutputUtil.readINT(in);
myIsLocal = (flags & LOCAL_MASK) != 0;
myIsAnonymous = (flags & ANONYMOUS_MASK) != 0;
myUsages =(Set<UsageRepr.Usage>)RW.read(UsageRepr.externalizer(context), new THashSet<UsageRepr.Usage>(), in);
}
catch (IOException e) {
throw new BuildDataCorruptedException(e);
}
}
示例3: test_valueOfLjava_lang_String
import java.lang.annotation.RetentionPolicy; //导入方法依赖的package包/类
/**
* @throws Exception
* @tests java.lang.annotation.RetentionPolicy#valueOf(String)
*/
@SuppressWarnings("nls")
public void test_valueOfLjava_lang_String() throws Exception {
assertSame(RetentionPolicy.CLASS, RetentionPolicy
.valueOf("CLASS"));
assertSame(RetentionPolicy.RUNTIME, RetentionPolicy
.valueOf("RUNTIME"));
assertSame(RetentionPolicy.SOURCE, RetentionPolicy
.valueOf("SOURCE"));
try {
RetentionPolicy.valueOf("OTHER");
fail("Should throw an IllegalArgumentException");
} catch (IllegalArgumentException e) {
// expected
}
}
示例4: ClassRepr
import java.lang.annotation.RetentionPolicy; //导入方法依赖的package包/类
public ClassRepr(final DependencyContext context, final DataInput in) {
super(in);
try {
this.myContext = context;
myFileName = in.readInt();
mySuperClass = (TypeRepr.ClassType)TypeRepr.externalizer(context).read(in);
myInterfaces = (Set<TypeRepr.AbstractType>)RW.read(TypeRepr.externalizer(context), new HashSet<TypeRepr.AbstractType>(), in);
myFields = (Set<FieldRepr>)RW.read(FieldRepr.externalizer(context), new HashSet<FieldRepr>(), in);
myMethods = (Set<MethodRepr>)RW.read(MethodRepr.externalizer(context), new HashSet<MethodRepr>(), in);
myAnnotationTargets = (Set<ElemType>)RW.read(UsageRepr.AnnotationUsage.elementTypeExternalizer, EnumSet.noneOf(ElemType.class), in);
final String s = in.readUTF();
myRetentionPolicy = s.length() == 0 ? null : RetentionPolicy.valueOf(s);
myOuterClassName = in.readInt();
myIsLocal = in.readBoolean();
myIsAnonymous = in.readBoolean();
myUsages =(Set<UsageRepr.Usage>)RW.read(UsageRepr.externalizer(context), new HashSet<UsageRepr.Usage>(), in);
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
示例5: getRetentionPolicy
import java.lang.annotation.RetentionPolicy; //导入方法依赖的package包/类
@Nullable
private static RetentionPolicy getRetentionPolicy(PsiClass annotation) {
PsiModifierList modifierList = annotation.getModifierList();
if (modifierList != null) {
PsiAnnotation retentionAnno = modifierList.findAnnotation(CommonClassNames.JAVA_LANG_ANNOTATION_RETENTION);
if (retentionAnno == null) return RetentionPolicy.CLASS;
PsiAnnotationMemberValue policyRef = PsiImplUtil.findAttributeValue(retentionAnno, null);
if (policyRef instanceof PsiReference) {
PsiElement field = ((PsiReference)policyRef).resolve();
if (field instanceof PsiEnumConstant) {
String name = ((PsiEnumConstant)field).getName();
try {
return RetentionPolicy.valueOf(name);
}
catch (Exception e) {
LOG.warn("Unknown policy: " + name);
}
}
}
}
return null;
}
示例6: readRetention
import java.lang.annotation.RetentionPolicy; //导入方法依赖的package包/类
private void readRetention()
{
final Annotation retention = this.theClass.getAnnotation(Annotation.LazyFields.RETENTION_CLASS);
if (retention == null)
{
return;
}
final IValue value = retention.getArguments().get(0, Names.value);
if (!(value instanceof EnumValue))
{
return;
}
try
{
final String name = ((EnumValue) value).getName().qualified;
this.retention = RetentionPolicy.valueOf(name);
}
catch (IllegalArgumentException ignored)
{
// Problematic RetentionPolicy annotation - do not handle this
}
}
示例7: bindRetention
import java.lang.annotation.RetentionPolicy; //导入方法依赖的package包/类
private static RetentionPolicy bindRetention(AnnoInfo annotation) {
Const value = annotation.values().get("value");
if (value.kind() != Kind.ENUM_CONSTANT) {
return null;
}
EnumConstantValue enumValue = (EnumConstantValue) value;
if (!enumValue.sym().owner().toString().equals("java/lang/annotation/RetentionPolicy")) {
return null;
}
return RetentionPolicy.valueOf(enumValue.sym().name());
}
示例8: bindRetention
import java.lang.annotation.RetentionPolicy; //导入方法依赖的package包/类
private RetentionPolicy bindRetention(AnnotationInfo annotation) {
ElementValue val = annotation.elementValuePairs().get("value");
if (val.kind() != Kind.ENUM) {
return null;
}
EnumConstValue enumVal = (EnumConstValue) val;
if (!enumVal.typeName().equals("Ljava/lang/annotation/RetentionPolicy;")) {
return null;
}
return RetentionPolicy.valueOf(enumVal.constName());
}
示例9: visitEnum
import java.lang.annotation.RetentionPolicy; //导入方法依赖的package包/类
@Override
public void visitEnum(String name, String desc, String value) {
myRetentionPolicy = RetentionPolicy.valueOf(value);
}
示例10: visitEnum
import java.lang.annotation.RetentionPolicy; //导入方法依赖的package包/类
public void visitEnum(String name, String desc, String value) {
myRetentionPolicy = RetentionPolicy.valueOf(value);
}