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); }
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; }
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); }
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 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); }
@Override /* @Nullable */ protected LightweightTypeReference getExpectedType() { JvmOperation operation = annotationValue.getOperation(); LightweightTypeReference result = getResolvedTypes().getActualType(operation); if (result != null && result.isArray()) { return result.getComponentType(); } return result; }
protected JvmTypeReference findExpectedType(final JvmAnnotationValue value) { JvmOperation _operation = value.getOperation(); boolean _tripleNotEquals = (_operation != null); if (_tripleNotEquals) { return value.getOperation().getReturnType();
protected void _setValue(final JvmAnnotationValue it, final Object value, final String componentType, final boolean mustBeArray) { if ((componentType == null)) { this.throwNotApplicable(it, value.getClass().getName()); } boolean _or = false; if (mustBeArray) { _or = true; } else { JvmTypeReference _returnType = it.getOperation().getReturnType(); JvmType _type = null; if (_returnType!=null) { _type=_returnType.getType(); } EClass _eClass = null; if (_type!=null) { _eClass=_type.eClass(); } boolean _equals = Objects.equal(_eClass, TypesPackage.Literals.JVM_ARRAY_TYPE); _or = _equals; } if (_or) { this.throwNotApplicable(it, (componentType + "[]")); } this.throwNotApplicable(it, componentType); }
@Override public Expression getExpression(final String property) { final JvmOperation op = this.findOperation(property); final Function1<JvmAnnotationValue, Boolean> _function = (JvmAnnotationValue it) -> { return Boolean.valueOf((Objects.equal(it.getOperation(), op) || ((it.getOperation() == null) && Objects.equal(op.getSimpleName(), "value")))); }; final JvmAnnotationValue annotationValue = IterableExtensions.<JvmAnnotationValue>findFirst(this.getDelegate().getValues(), _function); boolean _matched = false; if (annotationValue instanceof JvmCustomAnnotationValue) { _matched=true; EObject _head = IterableExtensions.<EObject>head(((JvmCustomAnnotationValue)annotationValue).getValues()); final XExpression expression = ((XExpression) _head); if (((expression != null) && this.getCompilationUnit().isBelongedToCompilationUnit(expression))) { return this.getCompilationUnit().toExpression(expression); } } return null; }
final JvmAnnotationReference activeAnnotation = IterableExtensions.<JvmAnnotationReference>findFirst(it.getAnnotations(), _function); final Function1<JvmAnnotationValue, Boolean> _function_1 = (JvmAnnotationValue it_1) -> { return Boolean.valueOf(((it_1.getOperation() == null) || Objects.equal(it_1.getOperation().getSimpleName(), "value"))); }; final JvmAnnotationValue annoVal = IterableExtensions.<JvmAnnotationValue>findFirst(activeAnnotation.getValues(), _function_1);
@Override public Object getValue(final String property) { try { final JvmOperation op = this.findOperation(property); final Function1<JvmAnnotationValue, Boolean> _function = (JvmAnnotationValue it) -> { return Boolean.valueOf((Objects.equal(it.getOperation(), op) || ((it.getOperation() == null) && Objects.equal(op.getSimpleName(), "value")))); }; final JvmAnnotationValue annotationValue = IterableExtensions.<JvmAnnotationValue>findFirst(this.getDelegate().getValues(), _function); final boolean isArrayType = ((op != null) && this.getCompilationUnit().getTypeReferences().isArray(op.getReturnType())); if ((annotationValue != null)) { return this.getCompilationUnit().translateAnnotationValue(annotationValue, isArrayType); } } catch (final Throwable _t) { if (_t instanceof ConstantExpressionEvaluationException) { final ConstantExpressionEvaluationException e = (ConstantExpressionEvaluationException)_t; this.getCompilationUnit().getProblemSupport().addError(this, e.getMessage()); } else { throw Exceptions.sneakyThrow(_t); } } return null; }
protected void checkType(final JvmAnnotationValue it, final String componentType, final boolean mustBeArray) { if ((componentType == null)) { return; } JvmTypeReference _returnType = it.getOperation().getReturnType(); JvmType _type = null; if (_returnType!=null) { _type=_returnType.getType(); } final JvmType returnType = _type; boolean _or = false; if (mustBeArray) { _or = true; } else { EClass _eClass = null; if (returnType!=null) { _eClass=returnType.eClass(); } boolean _equals = Objects.equal(_eClass, TypesPackage.Literals.JVM_ARRAY_TYPE); _or = _equals; } if (_or) { ConditionUtils.checkTypeName(this.getAnnotationValueTypeName(returnType), (componentType + "[]")); } else { ConditionUtils.checkTypeName(this.getAnnotationValueTypeName(returnType), componentType); } }