public static boolean isDeprecatedAnnotation(JvmAnnotationType jvmAnnotationType) { return !jvmAnnotationType.eIsProxy() && Deprecated.class.getName().equals(jvmAnnotationType.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 boolean isRelevant(JvmAnnotationReference annotationReference) { if (annotationReference == null || annotationReference.getAnnotation() == null || annotationReference.getAnnotation().getIdentifier() == null) return false; return getRelevantAnnotations().contains(annotationReference.getAnnotation().getIdentifier()); }
/** * @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; }
/** Copy the annotations, except the ones given as parameters. * * @param annotations the annotations to copy. * @param target the target. * @param exceptions the annotations to skip. */ @SuppressWarnings("static-method") protected void translateAnnotationsTo(List<JvmAnnotationReference> annotations, JvmAnnotationTarget target, Class<?>... exceptions) { final Set<String> excepts = new HashSet<>(); for (final Class<?> type : exceptions) { excepts.add(type.getName()); } final List<JvmAnnotationReference> addition = new ArrayList<>(); for (final JvmAnnotationReference annotation : Iterables.filter(annotations, an -> { if (!ANNOTATION_TRANSLATION_FILTER.apply(an)) { return false; } return !excepts.contains(an.getAnnotation().getIdentifier()); })) { addition.add(annotation); } target.getAnnotations().addAll(addition); }
/** * @param qualifiedNames * The annotations' qualified names to search for. * * @param annotationTarget * The element the annotations are search on. * * @return The annotations that are applied on the <i>annotationTarget</i> * and their qualified names appear in the <i>qualifiedNames</i> set. * The annotations are returned in the order of their appearance. * * @since 2.15 */ public List<JvmAnnotationReference> findAnnotations(Set<String> qualifiedNames, JvmAnnotationTarget annotationTarget) { List<JvmAnnotationReference> result = new ArrayList<>(); if (annotationTarget != null) { for (JvmAnnotationReference annotation : annotationTarget.getAnnotations()) { String id = annotation.getAnnotation().getIdentifier(); if (qualifiedNames.contains(id)) { result.add(annotation); } } } return result; } }
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; }
private JvmOperation findOperation(final String name) { ConditionUtils.checkJavaIdentifier(name, "name"); AnnotationTypeDeclaration _annotationTypeDeclaration = this.getAnnotationTypeDeclaration(); final JvmAnnotationType jvmAnnoType = ((JvmAnnotationTypeDeclarationImpl) _annotationTypeDeclaration).getDelegate(); final Function1<JvmOperation, Boolean> _function = (JvmOperation it) -> { String _simpleName = it.getSimpleName(); return Boolean.valueOf(Objects.equal(_simpleName, name)); }; final JvmOperation jvmOperation = IterableExtensions.<JvmOperation>findFirst(jvmAnnoType.getDeclaredOperations(), _function); if ((jvmOperation == null)) { String _identifier = jvmAnnoType.getIdentifier(); String _plus = ((("The annotation property \'" + name) + "\' is not declared on the annotation type \'") + _identifier); String _plus_1 = (_plus + "\'."); throw new IllegalArgumentException(_plus_1); } return jvmOperation; }
@SuppressWarnings({"checkstyle:returncount", "checkstyle:npathcomplexity", "checkstyle:cyclomaticcomplexity"}) private static String getAnnotationStringValue(JvmAnnotationValue value) { if (value instanceof JvmAnnotationAnnotationValue) { return ((JvmAnnotationAnnotationValue) value).getValues().get(0).getAnnotation().getIdentifier();
String _identifier = null; if (_annotation!=null) { _identifier=_annotation.getIdentifier();
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; }
String _identifier = null; if (_annotation!=null) { _identifier=_annotation.getIdentifier();
final String id = annotation.getAnnotation().getIdentifier(); if (!DefaultValueSource.class.getName().equals(id) && !DefaultValueUse.class.getName().equals(id)