private static boolean isConstantExpression(JvmAnnotationReference reference) { for (final JvmAnnotationValue annotationValue: reference.getValues()) { if ("constantExpression".equals(annotationValue.getValueName())) { if (annotationValue instanceof JvmBooleanAnnotationValue) { return ((JvmBooleanAnnotationValue) annotationValue).getValues().get(0).booleanValue(); } else if (annotationValue instanceof JvmCustomAnnotationValue) { final EObject value = ((JvmCustomAnnotationValue) annotationValue).getValues().get(0); if (value instanceof XBooleanLiteral) { return ((XBooleanLiteral) value).isIsTrue(); } } } } return false; }
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); } } }
protected boolean remove(final JvmOperation op) { final Predicate<JvmAnnotationValue> _function = (JvmAnnotationValue it) -> { return (Objects.equal(op, it.getOperation()) || ((it.getOperation() == null) && Objects.equal(op.getSimpleName(), "value"))); }; return Iterators.<JvmAnnotationValue>removeIf(this.delegate.getExplicitValues().iterator(), _function); }
public void toJava(final JvmAnnotationValue it, final ITreeAppendable appendable, final GeneratorConfig config) { JvmOperation _operation = it.getOperation(); boolean _tripleNotEquals = (_operation != null); if (_tripleNotEquals) { String _simpleName = it.getOperation().getSimpleName(); boolean _tripleEquals = (_simpleName == null); if (_tripleEquals) { return; } appendable.append(it.getOperation().getSimpleName()); appendable.append(" = "); } else { EObject _eContainer = it.eContainer(); int _size = ((JvmAnnotationReference) _eContainer).getExplicitValues().size(); boolean _greaterThan = (_size > 1); if (_greaterThan) { appendable.append("value = "); } } this.toJavaLiteral(it, appendable, config); }
@Override public void visit(String name, Object value) { if (name != null) { throw new IllegalStateException(); } if (result == null) { result = proxies.createAnnotationValue(value); } else { if (value instanceof Type) { Type type = (Type) value; BinaryTypeSignature signature; if (type.getSort() == Type.OBJECT) { String typeName = type.getInternalName(); signature = BinarySignatures.createObjectTypeSignature(typeName); } else { String typeName = type.getDescriptor(); signature = BinarySignatures.createTypeSignature(typeName); } ((InternalEList<JvmTypeReference>) ((JvmTypeAnnotationValue) result).getValues()).addUnique(proxies.createTypeReference(signature, null)); } else { @SuppressWarnings("unchecked") InternalEList<Object> list = (InternalEList<Object>) result.eGet(result.eClass().getEStructuralFeature("values")); list.addUnique(value); } } }
protected JvmTypeReference findExpectedType(final JvmAnnotationValue value) { JvmOperation _operation = value.getOperation(); boolean _tripleNotEquals = (_operation != null); if (_tripleNotEquals) { return value.getOperation().getReturnType(); EObject _eContainer = value.eContainer(); final EObject container = _eContainer; boolean _matched = false;
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); } } }
if (_explicitValues!=null) { final Function1<JvmAnnotationValue, Boolean> _function_1 = (JvmAnnotationValue it) -> { String _valueName = it.getValueName(); return Boolean.valueOf(Objects.equal(_valueName, typeString)); };
protected boolean isArrayOfAnnotations(final JvmAnnotationValue annotationValue) { final JvmTypeReference returnType = annotationValue.getOperation().getReturnType(); if ((returnType instanceof JvmGenericArrayTypeReference)) { JvmType _type = ((JvmGenericArrayTypeReference)returnType).getComponentType().getType(); return (_type instanceof JvmAnnotationType); } return false; }
@Override public void visitEnd() { if (result == null) { result = TypesFactory.eINSTANCE.createJvmCustomAnnotationValue(); } result.setOperation(proxies.createMethodProxy(annotationType, name)); values.addUnique(result); } };
List<JvmTypeReference> importedTypes = Lists.newArrayListWithCapacity(2); for(JvmAnnotationValue annotationValue: inlineAnnotation.getValues()) { if ("value".equals(annotationValue.getValueName()) || null == annotationValue.getValueName()) { if (annotationValue instanceof JvmStringAnnotationValue) { formatString = ((JvmStringAnnotationValue)annotationValue).getValues().get(0); } else if ("imported".equals(annotationValue.getValueName())) { if (annotationValue instanceof JvmTypeAnnotationValue) { JvmTypeAnnotationValue typeAnnotationValue = (JvmTypeAnnotationValue) annotationValue;
protected void throwNotApplicable(final JvmAnnotationValue it, final String valueType) { JvmTypeReference _returnType = it.getOperation().getReturnType(); JvmType _type = null; if (_returnType!=null) { _type=_returnType.getType(); } String _isNotApplicableMessage = ConditionUtils.isNotApplicableMessage(valueType, this.getAnnotationValueTypeName(_type)); throw new IllegalArgumentException(_isNotApplicableMessage); }
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); }
final List<JvmTypeReference> importedTypes = Lists.newArrayListWithCapacity(2); for (final JvmAnnotationValue annotationValue: inlineAnnotation.getValues()) { final String valueName = annotationValue.getValueName(); if (Strings.isEmpty(valueName)) {
@Override public EList<JvmAnnotationValue> getValues() { EList<JvmAnnotationValue> explicitValues = getExplicitValues(); List<JvmOperation> operations = Lists.newArrayList(getAnnotation().getDeclaredOperations()); if (operations.size() <= explicitValues.size()) { return ECollections.unmodifiableEList(explicitValues); } Set<JvmOperation> seenOperations = Sets.newHashSetWithExpectedSize(operations.size()); BasicEList<JvmAnnotationValue> result = new BasicEList<JvmAnnotationValue>(operations.size()); for(JvmAnnotationValue value: explicitValues) { seenOperations.add(value.getOperation()); result.add(value); } for(JvmOperation operation: operations) { if (seenOperations.add(operation)) { JvmAnnotationValue defaultValue = operation.getDefaultValue(); if (defaultValue != null) { result.add(defaultValue); } } } return ECollections.unmodifiableEList(result); }
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; }
final Function1<JvmAnnotationValue, String> _function_1 = (JvmAnnotationValue it) -> { String _elvis = null; String _valueName = it.getValueName(); if (_valueName != null) { _elvis = _valueName;
@Override /* @Nullable */ protected LightweightTypeReference getExpectedType() { JvmOperation operation = annotationValue.getOperation(); LightweightTypeReference result = getResolvedTypes().getActualType(operation); if (result != null && result.isArray()) { return result.getComponentType(); } return result; }
/** * 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); }
if (value instanceof JvmBooleanAnnotationValue && value.getValueName().equals("constantExpression")) { EList<Boolean> values = ((JvmBooleanAnnotationValue )value).getValues(); if (!values.isEmpty()) {