@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)); } };
protected boolean isRelevant(JvmAnnotationReference annotationReference) { if (annotationReference == null || annotationReference.getAnnotation() == null || annotationReference.getAnnotation().getIdentifier() == null) return false; return getRelevantAnnotations().contains(annotationReference.getAnnotation().getIdentifier()); }
private boolean containsAnnotation(JvmAnnotationTarget annotationTarget, Class<? extends Annotation> annotationClass) { for (JvmAnnotationReference annotationRef : annotationTarget.getAnnotations()) { if (annotationClass.getName().equals(annotationRef.getAnnotation().getIdentifier())) { return true; } } return false; }
protected boolean isActiveAnnotation(final JvmAnnotationType annotationType) { EList<JvmAnnotationReference> _annotations = annotationType.getAnnotations(); for (final JvmAnnotationReference anno : _annotations) { String _identifier = anno.getAnnotation().getIdentifier(); String _name = Active.class.getName(); boolean _equals = Objects.equal(_identifier, _name); if (_equals) { return true; } } return false; } }
protected JvmAnnotationReference findAnnotation(JvmAnnotationTarget feature, String annotationType) { if (feature == null) return null; if (annotationType == null) throw new NullPointerException(); List<JvmAnnotationReference> annotations = feature.getAnnotations(); for (JvmAnnotationReference annotation : annotations) { if (annotationType.equals(annotation.getAnnotation().getQualifiedName())) { return annotation; } } return null; }
public static boolean hasPureAnnotation(JvmOperation jvmOperation) { return jvmOperation.getAnnotations().stream() .anyMatch(ref -> Objects.equals(ref.getAnnotation().getQualifiedName(), Pure.class.getName())); } }
/** * @return <code>true</code> if this annotation is annotated with Java8 Repeatable meta-annotation. */ public boolean isRepeatable(final JvmAnnotationType annotationType) { for (Iterator<JvmAnnotationReference> iterator = annotationType.getAnnotations().iterator(); iterator.hasNext();) { JvmAnnotationReference metaAnnotation = iterator.next(); if ("java.lang.annotation.Repeatable".equals(metaAnnotation.getAnnotation().getIdentifier())) { return true; } } return false; }
/** * @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); } }
public JvmAnnotationReference findAnnotation(/* @NonNull */ JvmAnnotationTarget annotationTarget, /* @NonNull */ Class<? extends Annotation> lookupType) { // avoid creating an empty list for all given targets but check for #eIsSet first if (annotationTarget.eIsSet(TypesPackage.Literals.JVM_ANNOTATION_TARGET__ANNOTATIONS)) { for(JvmAnnotationReference annotation: annotationTarget.getAnnotations()) { JvmAnnotationType annotationType = annotation.getAnnotation(); if (annotationType != null && lookupType.getCanonicalName().equals(annotationType.getQualifiedName())) { return annotation; } } } return null; }
protected boolean isActiveAnnotation(JvmAnnotationType annotationType) { for (JvmAnnotationReference anno : annotationType.getAnnotations()) { JvmAnnotationType annotation = anno.getAnnotation(); if (annotation != null && !annotation.eIsProxy()) { if ("org.eclipse.xtend.lib.macro.Active".equals(annotation.getIdentifier())) { return true; } } } return false; } }
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; }
public Set<ElementType> getAnnotationTargets(JvmAnnotationType annotation) { EList<JvmAnnotationReference> annotations = annotation.getAnnotations(); for (JvmAnnotationReference annoRef : annotations) { if (Target.class.getName().equals(annoRef.getAnnotation().getIdentifier())) { EList<JvmAnnotationValue> values = annoRef.getValues(); JvmAnnotationValue value = values.isEmpty() ? null : values.get(0); if (value instanceof JvmEnumAnnotationValue) { Set<ElementType> result = newHashSet(); for (JvmEnumerationLiteral elementType : ((JvmEnumAnnotationValue) value).getValues()) { final String simpleName = elementType.getSimpleName(); result.add(ElementType.valueOf(simpleName)); } return result; } } } return emptySet(); }
public static boolean isDeprecatedMember(JvmMember member) { if (member.isSetDeprecated()) { return member.isDeprecated(); } List<JvmAnnotationReference> annotations = member.getAnnotations(); for(JvmAnnotationReference annotation: annotations) { JvmAnnotationType annotationType = annotation.getAnnotation(); if (annotationType != null && Deprecated.class.getName().equals(annotationType.getIdentifier())) { return true; } } return false; }
@Override public AnnotationTypeDeclaration getAnnotationTypeDeclaration() { TypeDeclaration _typeDeclaration = this.getCompilationUnit().toTypeDeclaration(this.getDelegate().getAnnotation()); return ((AnnotationTypeDeclaration) _typeDeclaration); }
@Nullable public JvmAnnotationReference findAnnotation(@NonNull JvmAnnotationTarget annotationTarget, @NonNull Class<? extends Annotation> lookupType) { // avoid creating an empty list for all given targets but check for #eIsSet first if (annotationTarget.eIsSet(TypesPackage.Literals.JVM_ANNOTATION_TARGET__ANNOTATIONS)) { for(JvmAnnotationReference annotation: annotationTarget.getAnnotations()) { JvmAnnotationType annotationType = annotation.getAnnotation(); if (annotationType != null && lookupType.getCanonicalName().equals(annotationType.getQualifiedName())) { return annotation; } } } return null; }
public void serializeSafely(final JvmAnnotationReference annotationRef, final ITreeAppendable appendable, final Procedure1<? super ITreeAppendable> onSuccess) { if (((annotationRef == null) || (annotationRef.getAnnotation() == null))) { final ITreeAppendable errorChild = this.openErrorAppendable(appendable, appendable); errorChild.append("annotation is \'null\'"); this.closeErrorAppendable(appendable, errorChild); } else { boolean _eIsProxy = annotationRef.getAnnotation().eIsProxy(); if (_eIsProxy) { final ITreeAppendable errorChild_1 = this.openErrorAppendable(appendable, appendable); appendable.append("@"); appendable.append(annotationRef.getAnnotation()); this.closeErrorAppendable(appendable, errorChild_1); } else { appendable.append("@"); appendable.append(annotationRef.getAnnotation()); onSuccess.apply(appendable); } } } }
public static boolean isDeprecated(JvmAnnotationTarget jvmAnnotationTarget) { for (JvmAnnotationReference ref : jvmAnnotationTarget.getAnnotations()) { if (ref != null && !ref.eIsProxy()) { JvmAnnotationType annotation = ref.getAnnotation(); if(annotation != null && !annotation.eIsProxy() && isDeprecated(annotation)) return true; } } return false; }
protected void appendAnnotationReferences(JvmAnnotationTarget target) { for(JvmAnnotationReference annotationReference: target.getAnnotations()) { if(annotationRelevance.isRelevant(annotationReference)) append(hashProvider.getHash(annotationReference.getAnnotation())) .append(" "); } }
protected JvmOperation findOperation(final String name) { ConditionUtils.checkJavaIdentifier(name, "name"); final JvmAnnotationType annotationType = this.delegate.getAnnotation(); final Function1<JvmOperation, Boolean> _function = (JvmOperation it) -> { String _simpleName = it.getSimpleName(); return Boolean.valueOf(Objects.equal(_simpleName, name)); }; final JvmOperation jvmOperation = IterableExtensions.<JvmOperation>findFirst(annotationType.getDeclaredOperations(), _function); if ((jvmOperation == null)) { StringConcatenation _builder = new StringConcatenation(); _builder.append("The annotation property \'"); _builder.append(name); _builder.append("\' is not declared on the annotation type \'"); String _identifier = annotationType.getIdentifier(); _builder.append(_identifier); _builder.append("\'."); throw new IllegalArgumentException(_builder.toString()); } return jvmOperation; }
public void generateAnnotation(final JvmAnnotationReference it, final ITreeAppendable appendable, final GeneratorConfig config) { appendable.append("@"); appendable.append(it.getAnnotation()); final Procedure1<LoopParams> _function = (LoopParams it_1) -> { it_1.setPrefix("("); it_1.setSeparator(", "); it_1.setSuffix(")"); }; final Procedure1<JvmAnnotationValue> _function_1 = (JvmAnnotationValue it_1) -> { this.toJava(it_1, appendable, config); }; this._loopExtensions.<JvmAnnotationValue>forEach(appendable, it.getExplicitValues(), _function, _function_1); }