本文整理了Java中javassist.bytecode.annotation.Annotation.getMemberNames()
方法的一些代码示例,展示了Annotation.getMemberNames()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation.getMemberNames()
方法的具体详情如下:
包路径:javassist.bytecode.annotation.Annotation
类名称:Annotation
方法名:getMemberNames
[英]Obtains all the member names.
[中]获取所有成员名称。
代码示例来源:origin: apache/drill
private List<AnnotationDescriptor> getAnnotationDescriptors(AnnotationsAttribute annotationsAttr) {
if (annotationsAttr == null) {
return Collections.emptyList();
}
List<AnnotationDescriptor> annotationDescriptors = new ArrayList<>(annotationsAttr.numAnnotations());
for (javassist.bytecode.annotation.Annotation annotation : annotationsAttr.getAnnotations()) {
// Sigh: javassist uses raw collections (is this 2002?)
@SuppressWarnings("unchecked")
Set<String> memberNames = annotation.getMemberNames();
List<AttributeDescriptor> attributes = new ArrayList<>();
if (memberNames != null) {
for (String name : memberNames) {
MemberValue memberValue = annotation.getMemberValue(name);
final List<String> values = new ArrayList<>();
memberValue.accept(new ListingMemberValueVisitor(values));
attributes.add(new AttributeDescriptor(name, values));
}
}
annotationDescriptors.add(new AnnotationDescriptor(annotation.getTypeName(), attributes));
}
return annotationDescriptors;
}
}
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
String typeName = annotation.getTypeName();
if (typeName.equals(Table.class.getName())) {
Set<String> keys = annotation.getMemberNames();
for (String key : keys) {
if (key.equalsIgnoreCase("name")) {
代码示例来源:origin: org.modeshape/modeshape-sequencer-java
@SuppressWarnings( "unchecked" )
AnnotationMetadata( Annotation annotation ) {
this.annotationClassName = annotation.getTypeName();
Set<Object> memberNames = annotation.getMemberNames();
if (memberNames != null) {
Map<String, String> members = new HashMap<String, String>(memberNames.size());
for (Object rawMemberName : memberNames) {
String memberName = (String)rawMemberName;
members.put(memberName, annotation.getMemberValue(memberName).toString());
}
this.memberValues = Collections.unmodifiableMap(members);
} else {
this.memberValues = Collections.emptyMap();
}
}
代码示例来源:origin: org.modeshape/modeshape-sequencer-classfile
@SuppressWarnings( "unchecked" )
AnnotationMetadata( Annotation annotation ) {
this.annotationClassName = annotation.getTypeName();
Set<Object> memberNames = annotation.getMemberNames();
if (memberNames != null) {
Map<String, String> members = new HashMap<String, String>(memberNames.size());
for (Object rawMemberName : memberNames) {
String memberName = (String)rawMemberName;
members.put(memberName, annotation.getMemberValue(memberName).toString());
}
this.memberValues = Collections.unmodifiableMap(members);
} else {
this.memberValues = Collections.emptyMap();
}
}
代码示例来源:origin: org.jboss.aop/jboss-aop
public Object visit(ASTSingleMemberValue node, Object data)
{
if (base.getMemberNames().size() > 1) throw new RuntimeException("single value expected from annotation: " + base.getTypeName());
Set<String> set = base.getMemberNames();
MemberValue mv = base.getMemberValue(set.iterator().next());
node.getValue().jjtAccept(this, mv);
return data;
}
代码示例来源:origin: ModeShape/modeshape
@SuppressWarnings( "unchecked" )
AnnotationMetadata( Annotation annotation ) {
this.annotationClassName = annotation.getTypeName();
Set<Object> memberNames = annotation.getMemberNames();
if (memberNames != null) {
Map<String, String> members = new HashMap<String, String>(memberNames.size());
for (Object rawMemberName : memberNames) {
String memberName = (String)rawMemberName;
members.put(memberName, annotation.getMemberValue(memberName).toString());
}
this.memberValues = Collections.unmodifiableMap(members);
} else {
this.memberValues = Collections.emptyMap();
}
}
代码示例来源:origin: org.jboss.aop/jboss-aop
public static void printAnnotation(Annotation info)
{
System.out.print("@" + info.getTypeName());
Set<String> members = info.getMemberNames();
if (members != null)
{
System.out.print("(");
Iterator<String> mit = members.iterator();
while (mit.hasNext())
{
String name = mit.next();
System.out.print(name + "=" + info.getMemberValue(name).toString());
if (mit.hasNext()) System.out.print(", ");
}
System.out.print(")");
}
System.out.println("");
}
}
代码示例来源:origin: org.jboss.microcontainer/jboss-container
public static Map<String, Object> createProxyMap(Class annotation, javassist.bytecode.annotation.Annotation info)
{
Map<String, Object> map = new HashMap<String, Object>();
if (info.getMemberNames() == null) return map;
Set members = info.getMemberNames();
Iterator it = members.iterator();
while (it.hasNext())
{
String name = (String) it.next();
MemberValue mv = info.getMemberValue(name);
ProxyMapCreator creator = new ProxyMapCreator(getMemberType(annotation, name));
mv.accept(creator);
map.put(name, creator.value);
}
return map;
}
}
代码示例来源:origin: org.jboss/jboss-mdr
@SuppressWarnings("unchecked")
public static Map<String, Object> createProxyMap(Class<?> annotation, javassist.bytecode.annotation.Annotation info)
{
Map<String, Object> map = new HashMap<String, Object>();
if (info.getMemberNames() == null) return map;
Set members = info.getMemberNames();
Iterator it = members.iterator();
while (it.hasNext())
{
String name = (String) it.next();
MemberValue mv = info.getMemberValue(name);
ProxyMapCreator creator = new ProxyMapCreator(getMemberType(annotation, name));
mv.accept(creator);
map.put(name, creator.value);
}
return map;
}
}
代码示例来源:origin: com.github.siom79.japicmp/japicmp
private Map<String, Optional<MemberValue>> buildMemberValueMap(Annotation annotation) {
Map<String, Optional<MemberValue>> map = new HashMap<>();
@SuppressWarnings("unchecked")
Set<String> memberNames = annotation.getMemberNames();
if (memberNames != null) {
for (String memberName : memberNames) {
MemberValue memberValue = annotation.getMemberValue(memberName);
if (memberValue == null) {
map.put(memberName, Optional.<MemberValue>absent());
} else {
map.put(memberName, Optional.of(memberValue));
}
}
}
return map;
}
代码示例来源:origin: org.arquillian.smart.testing/strategy-affected
private void addAnnotations(Collection<String> imports, AnnotationsAttribute annotations) {
if (annotations != null) {
for (Annotation each : annotations.getAnnotations()) {
imports.add(each.getTypeName());
final Set<String> memberNames = each.getMemberNames();
if (memberNames != null) {
for (String memberName : memberNames) {
imports.addAll(addSubtypes(each, memberName));
}
}
}
}
}
代码示例来源:origin: siom79/japicmp
private Map<String, Optional<MemberValue>> buildMemberValueMap(Annotation annotation) {
Map<String, Optional<MemberValue>> map = new HashMap<>();
@SuppressWarnings("unchecked")
Set<String> memberNames = annotation.getMemberNames();
if (memberNames != null) {
for (String memberName : memberNames) {
MemberValue memberValue = annotation.getMemberValue(memberName);
if (memberValue == null) {
map.put(memberName, Optional.<MemberValue>absent());
} else {
map.put(memberName, Optional.of(memberValue));
}
}
}
return map;
}
代码示例来源:origin: siom79/japicmp
@XmlElementWrapper(name = "values")
@XmlElement(name = "value")
public List<JApiAnnotationElementValue> getValues() {
List<JApiAnnotationElementValue> values = new ArrayList<>();
if (type == Type.Array) {
if (value instanceof MemberValue[]) {
MemberValue[] memberValues = (MemberValue[]) value;
for (MemberValue memberValue : memberValues) {
JApiAnnotationElementValue elementValue = JApiAnnotationElement.getMemberValue(memberValue);
values.add(elementValue);
}
}
} else if (type == Type.Annotation) {
if (value instanceof Annotation) {
Annotation annotation = (Annotation) value;
@SuppressWarnings("unchecked")
Set<String> memberNames = annotation.getMemberNames();
if (memberNames != null) {
for (String memberName : memberNames) {
MemberValue memberValue = annotation.getMemberValue(memberName);
JApiAnnotationElementValue elementValue = JApiAnnotationElement.getMemberValue(memberValue);
elementValue.setName(Optional.of(memberName));
values.add(elementValue);
}
}
}
}
return values;
}
代码示例来源:origin: com.github.siom79.japicmp/japicmp
@XmlElementWrapper(name = "values")
@XmlElement(name = "value")
public List<JApiAnnotationElementValue> getValues() {
List<JApiAnnotationElementValue> values = new ArrayList<>();
if (type == Type.Array) {
if (value instanceof MemberValue[]) {
MemberValue[] memberValues = (MemberValue[]) value;
for (MemberValue memberValue : memberValues) {
JApiAnnotationElementValue elementValue = JApiAnnotationElement.getMemberValue(memberValue);
values.add(elementValue);
}
}
} else if (type == Type.Annotation) {
if (value instanceof Annotation) {
Annotation annotation = (Annotation) value;
@SuppressWarnings("unchecked")
Set<String> memberNames = annotation.getMemberNames();
if (memberNames != null) {
for (String memberName : memberNames) {
MemberValue memberValue = annotation.getMemberValue(memberName);
JApiAnnotationElementValue elementValue = JApiAnnotationElement.getMemberValue(memberValue);
elementValue.setName(Optional.of(memberName));
values.add(elementValue);
}
}
}
}
return values;
}
代码示例来源:origin: org.apache.drill/drill-common
private List<AnnotationDescriptor> getAnnotationDescriptors(AnnotationsAttribute annotationsAttr) {
if (annotationsAttr == null) {
return Collections.emptyList();
}
List<AnnotationDescriptor> annotationDescriptors = new ArrayList<>(annotationsAttr.numAnnotations());
for (javassist.bytecode.annotation.Annotation annotation : annotationsAttr.getAnnotations()) {
// Sigh: javassist uses raw collections (is this 2002?)
@SuppressWarnings("unchecked")
Set<String> memberNames = annotation.getMemberNames();
List<AttributeDescriptor> attributes = new ArrayList<>();
if (memberNames != null) {
for (String name : memberNames) {
MemberValue memberValue = annotation.getMemberValue(name);
final List<String> values = new ArrayList<>();
memberValue.accept(new ListingMemberValueVisitor(values));
attributes.add(new AttributeDescriptor(name, values));
}
}
annotationDescriptors.add(new AnnotationDescriptor(annotation.getTypeName(), attributes));
}
return annotationDescriptors;
}
}
代码示例来源:origin: dremio/dremio-oss
private List<AnnotationDescriptor> getAnnotationDescriptors(AnnotationsAttribute annotationsAttr) {
List<AnnotationDescriptor> annotationDescriptors = new ArrayList<>(annotationsAttr.numAnnotations());
for (javassist.bytecode.annotation.Annotation annotation : annotationsAttr.getAnnotations()) {
// Sigh: javassist uses raw collections (is this 2002?)
@SuppressWarnings("unchecked")
Set<String> memberNames = annotation.getMemberNames();
List<AttributeDescriptor> attributes = new ArrayList<>();
if (memberNames != null) {
for (String name : memberNames) {
MemberValue memberValue = annotation.getMemberValue(name);
final List<String> values = new ArrayList<>();
memberValue.accept(new ListingMemberValueVisitor(values));
attributes.add(new AttributeDescriptor(name, values));
}
}
annotationDescriptors.add(new AnnotationDescriptor(annotation.getTypeName(), attributes));
}
return annotationDescriptors;
}
}
代码示例来源:origin: org.rhq/rhq-script-bindings
/**
* Copies the provided annotation into the provided const pool.
*
* @param annotation
* @param constPool
* @return
* @throws NotFoundException
*/
private static Annotation cloneAnnotation(Annotation annotation, final ConstPool constPool)
throws NotFoundException {
Annotation ret = new Annotation(annotation.getTypeName(), constPool);
if (annotation.getMemberNames() != null) {
for (Object m : annotation.getMemberNames()) {
final String memberName = (String) m;
MemberValue origValue = annotation.getMemberValue(memberName);
final MemberValue[] newValue = new MemberValue[1];
origValue.accept(new ArrayIndexAssigningVisitor(newValue, 0, constPool));
ret.addMemberValue(memberName, newValue[0]);
}
}
return ret;
}
代码示例来源:origin: com.github.vindell/javassist-plus
/**
* Copies the provided annotation into the provided const pool.
*
* @param annotation {@link Annotation}
* @param constPool {@link ConstPool}
* @return {@link Annotation}
* @throws NotFoundException If Not Found
*/
public static Annotation cloneAnnotation(Annotation annotation, final ConstPool constPool)
throws NotFoundException {
Annotation ret = new Annotation(annotation.getTypeName(), constPool);
if (annotation.getMemberNames() != null) {
for (Object m : annotation.getMemberNames()) {
final String memberName = (String) m;
MemberValue origValue = annotation.getMemberValue(memberName);
final MemberValue[] newValue = new MemberValue[1];
origValue.accept(new ArrayIndexAssigningVisitor(newValue, 0, constPool));
ret.addMemberValue(memberName, newValue[0]);
}
}
return ret;
}
代码示例来源:origin: locationtech/geowave
if (annotation.getMemberNames() != null) {
for (Object memberName : annotation.getMemberNames()) {
MemberValue memberValue = annotation.getMemberValue((String) memberName);
if (memberValue != null) {
代码示例来源:origin: org.streampipes/streampipes-empire-core
private static void inheritAnnotations(final CtClass theClass, final CtMethod theMethod) throws NotFoundException {
if (hasMethod(theClass, theMethod)) {
CtMethod aOtherMethod = theClass.getMethod(theMethod.getName(), theMethod.getSignature());
// method we're probably overriding or implementing in the case of an abstract method.
AnnotationsAttribute annotationsAttribute = (AnnotationsAttribute) aOtherMethod.getMethodInfo().getAttribute(AnnotationsAttribute.visibleTag);
if (annotationsAttribute != null) {
ConstPool cp = theClass.getClassFile().getConstPool();
AnnotationsAttribute attr = new AnnotationsAttribute(cp, AnnotationsAttribute.visibleTag);
for (Object obj : annotationsAttribute.getAnnotations()) {
Annotation a = (Annotation) obj;
Annotation theAnnotation = new Annotation(a.getTypeName(), cp);
if (a.getMemberNames() != null) {
for (Object aName : a.getMemberNames()) {
theAnnotation.addMemberValue(aName.toString(), a.getMemberValue(aName.toString()));
}
}
attr.addAnnotation(theAnnotation);
}
theMethod.getMethodInfo().addAttribute(attr);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!