/** * 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(); }
/** * 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(); }
return getAnnotationType(); MemberValue mv = annotation.getMemberValue(name); if (mv == null) return getDefault(name, method);
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; }
MemberValue mv = annotation.getMemberValue(name); Object value = null; try {
MemberValue mv = annotation.getMemberValue(name); Object value = null; Object otherValue = null;
/** * 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); }
MemberValue mv = annotation.getMemberValue(name); Object value = null; try {
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);
MemberValue mv = annotation.getMemberValue(name); Object value = null; Object otherValue = null;
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++) {
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; } }
for (String key : keys) { if (key.equalsIgnoreCase("name")) { StringMemberValue value = (StringMemberValue) annotation.getMemberValue(key); String oldTableName = value.getValue(); value.setValue(tableName);
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);
/** * 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); }
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: 重複?
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; }
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; } }
private Collection<String> addSubtypes(Annotation each, String memberName) { final ClassExtractorAnnotationMemberValue classExtractorAnnotationMemberValue = new ClassExtractorAnnotationMemberValue(); each.getMemberValue(memberName).accept(classExtractorAnnotationMemberValue); return classExtractorAnnotationMemberValue.getImports(); }
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); }