本文整理了Java中javassist.bytecode.annotation.Annotation.getMemberValue()
方法的一些代码示例,展示了Annotation.getMemberValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation.getMemberValue()
方法的具体详情如下:
包路径:javassist.bytecode.annotation.Annotation
类名称:Annotation
方法名:getMemberValue
[英]Obtains the member value with the given name.
If this annotation does not have a value for the specified member, this method returns null. It does not return a MemberValue
with the default value. The default value can be obtained from the annotation type.
[中]获取具有给定名称的成员值。
如果此批注没有指定成员的值,则此方法返回null。它不会返回带有默认值的MemberValue
。可以从注释类型中获取默认值。
代码示例来源:origin: redisson/redisson
/**
* Returns a string representation of the annotation.
*/
public String toString() {
StringBuffer buf = new StringBuffer("@");
buf.append(getTypeName());
if (members != null) {
buf.append("(");
Iterator mit = members.keySet().iterator();
while (mit.hasNext()) {
String name = (String)mit.next();
buf.append(name).append("=").append(getMemberValue(name));
if (mit.hasNext())
buf.append(", ");
}
buf.append(")");
}
return buf.toString();
}
代码示例来源:origin: org.javassist/javassist
/**
* Returns a string representation of the annotation.
*/
@Override
public String toString() {
StringBuffer buf = new StringBuffer("@");
buf.append(getTypeName());
if (members != null) {
buf.append("(");
for (String name:members.keySet()) {
buf.append(name).append("=")
.append(getMemberValue(name))
.append(", ");
}
buf.setLength(buf.length()-2);
buf.append(")");
}
return buf.toString();
}
代码示例来源:origin: redisson/redisson
return getAnnotationType();
MemberValue mv = annotation.getMemberValue(name);
if (mv == null)
return getDefault(name, method);
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
protected Annotation getEntityListeners(ConstPool constantPool, Annotation existingEntityListeners, Annotation templateEntityListeners) {
Annotation listeners = new Annotation(EntityListeners.class.getName(), constantPool);
ArrayMemberValue listenerArray = new ArrayMemberValue(constantPool);
Set<MemberValue> listenerMemberValues = new HashSet<>();
{
ArrayMemberValue templateListenerValues = (ArrayMemberValue) templateEntityListeners.getMemberValue("value");
listenerMemberValues.addAll(Arrays.asList(templateListenerValues.getValue()));
logger.debug("Adding template values to new EntityListeners");
}
if (existingEntityListeners != null) {
ArrayMemberValue oldListenerValues = (ArrayMemberValue) existingEntityListeners.getMemberValue("value");
listenerMemberValues.addAll(Arrays.asList(oldListenerValues.getValue()));
logger.debug("Adding previous values to new EntityListeners");
}
listenerArray.setValue(listenerMemberValues.toArray(new MemberValue[listenerMemberValues.size()]));
listeners.addMemberValue("value", listenerArray);
return listeners;
}
代码示例来源:origin: redisson/redisson
MemberValue mv = annotation.getMemberValue(name);
Object value = null;
try {
代码示例来源:origin: redisson/redisson
MemberValue mv = annotation.getMemberValue(name);
Object value = null;
Object otherValue = null;
代码示例来源:origin: org.javassist/javassist
/**
* Executes a method invocation on a proxy instance.
* The implementations of <code>toString()</code>, <code>equals()</code>,
* and <code>hashCode()</code> are directly supplied by the
* <code>AnnotationImpl</code>. The <code>annotationType()</code> method
* is also available on the proxy instance.
*/
@Override
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable
{
String name = method.getName();
if (Object.class == method.getDeclaringClass()) {
if ("equals".equals(name)) {
Object obj = args[0];
return Boolean.valueOf(checkEquals(obj));
}
else if ("toString".equals(name))
return annotation.toString();
else if ("hashCode".equals(name))
return Integer.valueOf(hashCode());
}
else if ("annotationType".equals(name)
&& method.getParameterTypes().length == 0)
return getAnnotationType();
MemberValue mv = annotation.getMemberValue(name);
if (mv == null)
return getDefault(name, method);
return mv.getValue(classLoader, pool, method);
}
代码示例来源:origin: org.javassist/javassist
MemberValue mv = annotation.getMemberValue(name);
Object value = null;
try {
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
String typeName = annotation.getTypeName();
if (typeName.equals(NamedQueries.class.getName())) {
namedQueryArray = (ArrayMemberValue) annotation.getMemberValue("value");
} else if (typeName.equals(NamedNativeQueries.class.getName())) {
nativeQueryArray = (ArrayMemberValue) annotation.getMemberValue("value");
} else {
newItems.add(annotation);
代码示例来源:origin: org.javassist/javassist
MemberValue mv = annotation.getMemberValue(name);
Object value = null;
Object otherValue = null;
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
String typeName = annotation.getTypeName();
if (typeName.equals(DirectCopyTransform.class.getName())) {
ArrayMemberValue arrayMember = (ArrayMemberValue) annotation.getMemberValue("value");
for (MemberValue arrayMemberValue : arrayMember.getValue()) {
AnnotationMemberValue member = (AnnotationMemberValue) arrayMemberValue;
Annotation memberAnnot = member.getValue();
ArrayMemberValue annot = (ArrayMemberValue) memberAnnot.getMemberValue("templateTokens");
List<String> addedTemplates = new ArrayList<>();
for (MemberValue memberValue : annot.getValue()) {
BooleanMemberValue skipAnnot = (BooleanMemberValue) memberAnnot.getMemberValue("skipOverlaps");
if (skipAnnot != null) {
for (int j=0;j<addedTemplates.size();j++) {
BooleanMemberValue renameAnnot = (BooleanMemberValue) memberAnnot.getMemberValue("renameMethodOverlaps");
if (renameAnnot != null) {
for (int j=0;j<addedTemplates.size();j++) {
代码示例来源: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
for (String key : keys) {
if (key.equalsIgnoreCase("name")) {
StringMemberValue value = (StringMemberValue) annotation.getMemberValue(key);
String oldTableName = value.getValue();
value.setValue(tableName);
代码示例来源:origin: BroadleafCommerce/BroadleafCommerce
String typeName = annotation.getTypeName();
if (typeName.equals(Type.class.getName())) {
StringMemberValue annot = (StringMemberValue) annotation.getMemberValue("type");
if (annot != null && annot.getValue().equals(StringClobType.class.getName())) {
Annotation clobType = new Annotation(Type.class.getName(), constantPool);
代码示例来源:origin: com.atlassian.plugin/atlassian-spring-scanner-maven-plugin
/**
* Return the member value of an annotation
*
* @param annotation the annotation to inspect
* @param memberName the name of the annotation member
* @return a value or null if it has no member
*/
String getAnnotationMember(final Annotation annotation, final String memberName) {
final MemberValue value = annotation == null ? null : annotation.getMemberValue(memberName);
return dataForMemberValue(value);
}
代码示例来源:origin: jp.objectfanatics/assertion-weaver
private double getMinThreshold(CtBehavior ctBehavior, Annotation annotation) throws NonFiniteThresholdException {
double threshold = DoubleMemberValue.class.cast(annotation.getMemberValue("min")).getValue();
if (Double.isNaN(threshold) || Double.isInfinite(threshold)) {
throw new NonFiniteThresholdException(ctBehavior, threshold);
}
return threshold;
}
// TODO: 重複?
代码示例来源:origin: jp.objectfanatics/assertion-weaver
private double getMaxThreshold(CtBehavior ctBehavior, Annotation annotation) throws NonFiniteThresholdException {
double threshold = DoubleMemberValue.class.cast(annotation.getMemberValue("max")).getValue();
if (Double.isNaN(threshold) || Double.isInfinite(threshold)) {
throw new NonFiniteThresholdException(ctBehavior, threshold);
}
return threshold;
}
代码示例来源:origin: com.googlecode.gwt-test-utils/gwt-test-utils
private String tryExtractFromParamTypeAnnotation(Object[] annotations) {
for (Object o : annotations) {
AnnotationImpl annotation = (AnnotationImpl) Proxy.getInvocationHandler(o);
if (annotation.getTypeName().equals(ParamType.class.getName())) {
String value = ((StringMemberValue) annotation.getAnnotation().getMemberValue("value")).getValue();
return value.equals("") ? null : value;
}
}
return null;
}
}
代码示例来源:origin: org.arquillian.smart.testing/strategy-affected
private Collection<String> addSubtypes(Annotation each, String memberName) {
final ClassExtractorAnnotationMemberValue classExtractorAnnotationMemberValue = new ClassExtractorAnnotationMemberValue();
each.getMemberValue(memberName).accept(classExtractorAnnotationMemberValue);
return classExtractorAnnotationMemberValue.getImports();
}
代码示例来源:origin: jpmml/jpmml-model
static
private void updatePropOrder(CtClass ctClass, String name){
ClassFile classFile = ctClass.getClassFile();
AnnotationsAttribute annotations = (AnnotationsAttribute)classFile.getAttribute(AnnotationsAttribute.visibleTag);
Annotation xmlTypeAnnotation = annotations.getAnnotation("javax.xml.bind.annotation.XmlType");
ArrayMemberValue propOrderValue = (ArrayMemberValue)xmlTypeAnnotation.getMemberValue("propOrder");
removeValue(propOrderValue, name);
annotations.addAnnotation(xmlTypeAnnotation);
}
内容来源于网络,如有侵权,请联系作者删除!