public static boolean hasPureAnnotation(final JvmOperation jvmOperation) { EList<JvmAnnotationReference> _annotations = jvmOperation.getAnnotations(); final Function1<JvmAnnotationReference, Boolean> _function = new Function1<JvmAnnotationReference, Boolean>() { @Override public Boolean apply(final JvmAnnotationReference it) { JvmAnnotationType _annotation = it.getAnnotation(); String _qualifiedName = _annotation.getQualifiedName(); String _name = Pure.class.getName(); return Boolean.valueOf(Objects.equal(_qualifiedName, _name)); } }; return IterableExtensions.<JvmAnnotationReference>exists(_annotations, _function); } }
public static boolean hasPureAnnotation(JvmOperation jvmOperation) { return jvmOperation.getAnnotations().stream() .anyMatch(ref -> Objects.equals(ref.getAnnotation().getQualifiedName(), Pure.class.getName())); } }
/** * @return {@code true} if the operation is annotated with {@code org.testeditor.fixture.core.interaction.FixtureMethod}. */ private boolean hasFixtureMethodAnnotation(final JvmOperation operation) { final Function1<JvmAnnotationReference, Boolean> _function = (JvmAnnotationReference it) -> { String _qualifiedName = it.getAnnotation().getQualifiedName(); return Boolean.valueOf(Objects.equal(_qualifiedName, "org.testeditor.fixture.core.interaction.FixtureMethod")); }; return IterableExtensions.<JvmAnnotationReference>exists(operation.getAnnotations(), _function); } }
private boolean addOverrideAnnotation(final JvmOperation it) { EList<JvmAnnotationReference> _annotations = it.getAnnotations(); JvmAnnotationReference _annotationRef = this._annotationTypesBuilder.annotationRef(Override.class); return this._jvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); }
public boolean isMandatory(JvmIdentifiableElement feature) { if (feature.eIsProxy()) return false; if (feature instanceof DeclaredProperty) { return ((DeclaredProperty) feature).getDefault() == null; } JvmOperation operation = (JvmOperation) feature; for(JvmAnnotationReference annotation: operation.getAnnotations()) { if (Mandatory.class.getName().equals(annotation.getAnnotation().getIdentifier())) return true; } return false; }
protected void setOverride(JvmOperation operation) { if (generatorConfig.getJavaSourceVersion().isAtLeast(JAVA6) && !containsAnnotation(operation, Override.class)) { operation.getAnnotations().add(_annotationTypesBuilder.annotationRef(Override.class)); } }
@Override public void apply(final JvmOperation it) { EList<JvmAnnotationReference> _annotations = it.getAnnotations(); JvmAnnotationReference _annotationRef = PatternMatchClassInferrer.this.annBuilder.annotationRef(Override.class); PatternMatchClassInferrer.this._eMFJvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); StringConcatenationClient _client = new StringConcatenationClient() { @Override protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { _builder.append("return \""); QualifiedName _fullyQualifiedName = PatternMatchClassInferrer.this._iQualifiedNameProvider.getFullyQualifiedName(pattern); _builder.append(_fullyQualifiedName, ""); _builder.append("\";"); _builder.newLineIfNotEmpty(); } }; PatternMatchClassInferrer.this._eMFJvmTypesBuilder.setBody(it, _client); } };
@Override public void apply(final JvmOperation it) { EList<JvmAnnotationReference> _annotations = it.getAnnotations(); JvmAnnotationReference _annotationRef = PatternMatchClassInferrer.this.annBuilder.annotationRef(Override.class); PatternMatchClassInferrer.this._eMFJvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); StringConcatenationClient _client = new StringConcatenationClient() { @Override protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { _builder.append("return "); String _matchClassName = PatternMatchClassInferrer.this._eMFPatternLanguageJvmModelInferrerUtil.matchClassName(pattern); _builder.append(_matchClassName, ""); _builder.append(".parameterNames;"); _builder.newLineIfNotEmpty(); } }; PatternMatchClassInferrer.this._eMFJvmTypesBuilder.setBody(it, _client); } };
@Override public void apply(final JvmOperation it) { EList<JvmAnnotationReference> _annotations = it.getAnnotations(); JvmAnnotationReference _annotationRef = PatternMatchClassInferrer.this.annBuilder.annotationRef(Override.class); PatternMatchClassInferrer.this._eMFJvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); StringConcatenationClient _client = new StringConcatenationClient() { @Override protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { _builder.append("return new Object[]{"); { EList<Variable> _parameters = pattern.getParameters(); boolean _hasElements = false; for(final Variable variable : _parameters) { if (!_hasElements) { _hasElements = true; } else { _builder.appendImmediate(", ", ""); } String _fieldName = PatternMatchClassInferrer.this._eMFPatternLanguageJvmModelInferrerUtil.fieldName(variable); _builder.append(_fieldName, ""); } } _builder.append("};"); _builder.newLineIfNotEmpty(); } }; PatternMatchClassInferrer.this._eMFJvmTypesBuilder.setBody(it, _client); } };
@Override public void apply(final JvmOperation it) { EList<JvmAnnotationReference> _annotations = it.getAnnotations(); JvmAnnotationReference _annotationRef = PatternMatchClassInferrer.this.annBuilder.annotationRef(Override.class); PatternMatchClassInferrer.this._eMFJvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); StringConcatenationClient _client = new StringConcatenationClient() { @Override protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { _builder.append("return isMutable() ? newMatch("); { EList<Variable> _parameters = pattern.getParameters(); boolean _hasElements = false; for(final Variable variable : _parameters) { if (!_hasElements) { _hasElements = true; } else { _builder.appendImmediate(", ", ""); } String _fieldName = PatternMatchClassInferrer.this._eMFPatternLanguageJvmModelInferrerUtil.fieldName(variable); _builder.append(_fieldName, ""); } } _builder.append(") : this;"); _builder.newLineIfNotEmpty(); } }; PatternMatchClassInferrer.this._eMFJvmTypesBuilder.setBody(it, _client); } };
@Override public void apply(final JvmOperation it) { it.setVisibility(JvmVisibility.PUBLIC); EList<JvmAnnotationReference> _annotations = it.getAnnotations(); JvmAnnotationReference _annotationRef = PatternQuerySpecificationClassInferrer.this.annBuilder.annotationRef(Override.class); PatternQuerySpecificationClassInferrer.this._eMFJvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); StringConcatenationClient _client = new StringConcatenationClient() { @Override protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) { _builder.append("return \""); String _fullyQualifiedName = CorePatternLanguageHelper.getFullyQualifiedName(pattern); _builder.append(_fullyQualifiedName, ""); _builder.append("\";"); _builder.newLineIfNotEmpty(); } }; PatternQuerySpecificationClassInferrer.this._eMFJvmTypesBuilder.setBody(it, _client); } };
/** * Creates a <code>toString()</code> method accumulating the values of all fields. * * @return a result representing a Java toString() method, <code>null</code> if sourceElement or declaredType are <code>null</code>. */ /* @Nullable */ public JvmOperation toToStringMethod(/* @Nullable */ final EObject sourceElement, /* @Nullable */ final JvmDeclaredType declaredType) { if(sourceElement == null || declaredType == null) return null; JvmOperation result = toMethod(sourceElement, "toString", newTypeRef(sourceElement, String.class), null); if (result == null) return null; JvmType overrideType = references.findDeclaredType(Override.class, sourceElement); if (overrideType != null) result.getAnnotations().add(toAnnotation(sourceElement, Override.class)); setBody(result, new Procedure1<ITreeAppendable>() { @Override public void apply(/* @Nullable */ ITreeAppendable p) { if (p == null) return; p.append("String result = new "); p.append(ToStringBuilder.class); p.append("(this).addAllFields().toString();"); p.newLine().append("return result;"); } }); return result; }
@Override public void apply(final JvmOperation it) { it.setVisibility(JvmVisibility.PUBLIC); EList<JvmAnnotationReference> _annotations = it.getAnnotations(); JvmAnnotationReference _annotationRef = PatternQuerySpecificationClassInferrer.this.annBuilder.annotationRef(Override.class); PatternQuerySpecificationClassInferrer.this._eMFJvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
@Override public void apply(final JvmOperation it) { it.setVisibility(JvmVisibility.PUBLIC); EList<JvmAnnotationReference> _annotations = it.getAnnotations(); JvmAnnotationReference _annotationRef = PatternQuerySpecificationClassInferrer.this.annBuilder.annotationRef(Override.class); PatternQuerySpecificationClassInferrer.this._eMFJvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
@Override public void apply(final JvmOperation it) { it.setVisibility(JvmVisibility.PUBLIC); EList<JvmAnnotationReference> _annotations = it.getAnnotations(); JvmAnnotationReference _annotationRef = PatternQuerySpecificationClassInferrer.this.annBuilder.annotationRef(Override.class); PatternQuerySpecificationClassInferrer.this._eMFJvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef);
@Override public void apply(final JvmOperation it) { EList<JvmAnnotationReference> _annotations = it.getAnnotations(); JvmAnnotationReference _annotationRef = PatternMatcherClassInferrer.this.annBuilder.annotationRef(Override.class); PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); it.setVisibility(JvmVisibility.PROTECTED); EList<JvmFormalParameter> _parameters = it.getParameters(); JvmTypeReference _typeRef = PatternMatcherClassInferrer.this.builder.typeRef(Tuple.class); JvmFormalParameter _parameter = PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.toParameter(pattern, "t", _typeRef); PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); } };
@Override public void apply(final JvmOperation it) { EList<JvmAnnotationReference> _annotations = it.getAnnotations(); JvmAnnotationReference _annotationRef = PatternMatcherClassInferrer.this.annBuilder.annotationRef(Override.class); PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); it.setVisibility(JvmVisibility.PROTECTED); EList<JvmFormalParameter> _parameters = it.getParameters(); JvmTypeReference _typeRef = PatternMatcherClassInferrer.this.builder.typeRef(Object.class); JvmTypeReference _addArrayTypeDimension = PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.addArrayTypeDimension(_typeRef); JvmFormalParameter _parameter = PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.toParameter(pattern, "match", _addArrayTypeDimension); PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); } };
@Override public void apply(final JvmOperation it) { EList<JvmAnnotationReference> _annotations = it.getAnnotations(); JvmAnnotationReference _annotationRef = PatternMatcherClassInferrer.this.annBuilder.annotationRef(Override.class); PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.<JvmAnnotationReference>operator_add(_annotations, _annotationRef); it.setVisibility(JvmVisibility.PROTECTED); EList<JvmFormalParameter> _parameters = it.getParameters(); JvmTypeReference _typeRef = PatternMatcherClassInferrer.this.builder.typeRef(Object.class); JvmTypeReference _addArrayTypeDimension = PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.addArrayTypeDimension(_typeRef); JvmFormalParameter _parameter = PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.toParameter(pattern, "match", _addArrayTypeDimension); PatternMatcherClassInferrer.this._eMFJvmTypesBuilder.<JvmFormalParameter>operator_add(_parameters, _parameter); } };
public void generateAnnotationMethod(final JvmOperation it, final ITreeAppendable appendable, final GeneratorConfig config) { appendable.increaseIndentation().newLine(); appendable.openScope(); this.generateJavaDoc(it, appendable, config); final ITreeAppendable tracedAppendable = appendable.trace(it); this.generateAnnotations(it.getAnnotations(), tracedAppendable, true, config); this.generateModifier(it, tracedAppendable, config); this._errorSafeExtensions.serializeSafely(it.getReturnType(), "Object", tracedAppendable); tracedAppendable.append(" "); this._treeAppendableUtil.traceSignificant(tracedAppendable, it).append(this.makeJavaIdentifier(it.getSimpleName())); tracedAppendable.append("()"); this.generateDefaultExpression(it, tracedAppendable, config); tracedAppendable.append(";"); appendable.decreaseIndentation(); appendable.closeScope(); }
this.generateJavaDoc(it, appendable, config); final ITreeAppendable tracedAppendable = appendable.trace(it); this.generateAnnotations(it.getAnnotations(), tracedAppendable, true, config); this.generateModifier(it, tracedAppendable, config); this.generateTypeParameterDeclaration(it, tracedAppendable, config);