private void setDefaultValue(JvmOperation operation, Method method) { Object defaultValue = method.getDefaultValue(); if (defaultValue != null) { Class<?> returnType = method.getReturnType(); if (returnType.isArray()) { JvmAnnotationValue annotationValue = createArrayAnnotationValue(defaultValue, returnType); operation.setDefaultValue(annotationValue); annotationValue.setOperation(operation); } else { JvmAnnotationValue annotationValue = createAnnotationValue(defaultValue, returnType); operation.setDefaultValue(annotationValue); annotationValue.setOperation(operation); } } }
private void setDefaultValue(JvmOperation operation, Method method) { Object defaultValue = method.getDefaultValue(); if (defaultValue != null) { Class<?> returnType = method.getReturnType(); if (returnType.isArray()) { JvmAnnotationValue annotationValue = createArrayAnnotationValue(defaultValue, returnType); operation.setDefaultValue(annotationValue); annotationValue.setOperation(operation); } else { JvmAnnotationValue annotationValue = createAnnotationValue(defaultValue, returnType); operation.setDefaultValue(annotationValue); annotationValue.setOperation(operation); } } }
@Override public void visitEnd() { if (result == null) { result = TypesFactory.eINSTANCE.createJvmCustomAnnotationValue(); } result.setOperation(proxies.createMethodProxy(annotationType, name)); values.addUnique(result); } };
protected void setValues(final String name, final Object values, final String componentType, final boolean mustBeArray) { final JvmOperation op = this.findOperation(name, mustBeArray); final JvmAnnotationValue newValue = this.createAnnotationValue(op, values); newValue.setOperation(op); this.setValue(newValue, values, componentType, mustBeArray); this.remove(op); this.delegate.getExplicitValues().add(newValue); }
protected JvmAnnotationReference createAnnotationReference(Annotation annotation) { JvmAnnotationReference annotationReference = TypesFactory.eINSTANCE.createJvmAnnotationReference(); Class<? extends Annotation> type = annotation.annotationType(); annotationReference.setAnnotation(createAnnotationProxy(type)); Method[] declaredMethods = type.getDeclaredMethods(); if (declaredMethods.length > 0) { InternalEList<JvmAnnotationValue> values = (InternalEList<JvmAnnotationValue>)annotationReference.getValues(); for (Method method : declaredMethods) { try { Object value = method.invoke(annotation, EMPTY_ARRAY); Class<?> returnType = method.getReturnType(); if (returnType.isArray()) { JvmAnnotationValue annotationValue = createArrayAnnotationValue(value, returnType); values.addUnique(annotationValue); annotationValue.setOperation(createMethodProxy(method)); } else { JvmAnnotationValue annotationValue = createAnnotationValue(value, returnType); values.addUnique(annotationValue); annotationValue.setOperation(createMethodProxy(method)); } } catch (Exception e) { log.error(e.getMessage(), e); } } } return annotationReference; }
/** * Visits a primitive value of the annotation. * * @param name * the value name. * @param value * the actual value, whose type must be {@link Byte}, {@link Boolean}, {@link Character}, {@link Short}, * {@link Integer}, {@link Long}, {@link Float}, {@link Double}, {@link String} or {@link Type}. This * value can also be an array of byte, boolean, short, char, int, long, float or double values (this is * equivalent to using {@link #visitArray visitArray} and visiting each array element in turn, but is * more convenient). */ @Override public void visit(final String name, final Object value) { JvmAnnotationValue annotationValue = proxies.createAnnotationValue(value); annotationValue.setOperation(proxies.createMethodProxy(annotationType, name)); values.addUnique(annotationValue); }
protected JvmAnnotationReference createAnnotationReference(Annotation annotation) { JvmAnnotationReference annotationReference = TypesFactory.eINSTANCE.createJvmAnnotationReference(); Class<? extends Annotation> type = annotation.annotationType(); annotationReference.setAnnotation(createAnnotationProxy(type)); Method[] declaredMethods = type.getDeclaredMethods(); if (declaredMethods.length > 0) { InternalEList<JvmAnnotationValue> values = (InternalEList<JvmAnnotationValue>)annotationReference.getExplicitValues(); for (Method method : declaredMethods) { try { Object value = method.invoke(annotation, EMPTY_ARRAY); Class<?> returnType = method.getReturnType(); if (returnType.isArray()) { JvmAnnotationValue annotationValue = createArrayAnnotationValue(value, returnType); values.addUnique(annotationValue); annotationValue.setOperation(createMethodProxy(method)); } else { JvmAnnotationValue annotationValue = createAnnotationValue(value, returnType); values.addUnique(annotationValue); annotationValue.setOperation(createMethodProxy(method)); } } catch (Exception e) { log.error(e.getMessage(), e); } } } return annotationReference; }
result.setOperation(operation); operation.setDefaultValue(result); } else {
JvmOperation op = (JvmOperation) val.eGet( XAnnotationsPackage.Literals.XANNOTATION_ELEMENT_VALUE_PAIR__ELEMENT, false); annotationValue.setOperation(op); reference.getExplicitValues().add(annotationValue);
if (jvmAnnotationValue != null) { operation.setDefaultValue(jvmAnnotationValue); jvmAnnotationValue.setOperation(operation);