@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)); } };
public JvmAnnotationReferenceBuilder(InternalEList<JvmAnnotationReference> target, String desc, Proxies proxies) { super(Opcodes.ASM7); this.proxies = proxies; this.target = target; this.annotationType = BinarySignatures.createTypeSignature(desc); result = TypesFactory.eINSTANCE.createJvmAnnotationReference(); result.setAnnotation(proxies.createAnnotationProxy(annotationType)); values = (InternalEList<JvmAnnotationValue>) result.getExplicitValues(); }
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 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; }
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); }
/** Extract the string values of the given annotation, if they exist. * * @param reference the reference to the annotation. * @return the values of the annotation, never {@code null}. */ @SuppressWarnings("static-method") public List<String> findStringValues(JvmAnnotationReference reference) { assert reference != null; final List<String> values = new ArrayList<>(); for (final JvmAnnotationValue value : reference.getValues()) { if (value instanceof JvmStringAnnotationValue) { for (final String strValue : ((JvmStringAnnotationValue) value).getValues()) { if (strValue != null) { values.add(strValue); } } } } return values; }
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 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; }
protected JvmAnnotationReference createJvmAnnotationReference(final JvmType type) { JvmAnnotationReference _switchResult = null; boolean _matched = false; if (type instanceof JvmAnnotationType) { _matched=true; JvmAnnotationReference _createJvmAnnotationReference = TypesFactory.eINSTANCE.createJvmAnnotationReference(); final Procedure1<JvmAnnotationReference> _function = (JvmAnnotationReference it) -> { it.setAnnotation(((JvmAnnotationType)type)); }; _switchResult = ObjectExtensions.<JvmAnnotationReference>operator_doubleArrow(_createJvmAnnotationReference, _function); } if (!_matched) { _switchResult = null; } return _switchResult; } }
String _qualifiedName = it.getAnnotation().getQualifiedName(); String _name = AggregatorType.class.getName(); return Boolean.valueOf(Objects.equal(_qualifiedName, _name)); EList<JvmAnnotationValue> _explicitValues = null; if (annotationType!=null) { _explicitValues=annotationType.getExplicitValues();
/** Extract the integer value of the given annotation, if it exists. * * @param reference the reference to the annotation. * @return the value of the annotation, or {@code null} if no annotation or no * value. * @since 0.6 */ @SuppressWarnings("static-method") public Integer findIntValue(JvmAnnotationReference reference) { assert reference != null; for (final JvmAnnotationValue value : reference.getValues()) { if (value instanceof JvmIntAnnotationValue) { for (final Integer intValue : ((JvmIntAnnotationValue) value).getValues()) { if (intValue != null) { return intValue; } } } } return null; }
protected void recordAnnotationExpressions(List<JvmAnnotationReference> annotations) { for(JvmAnnotationReference annotation: annotations) { EObject sourceElement = getSourceElement(annotation); if (sourceElement != annotation) { rootedInstances.add(sourceElement); } else { for(JvmAnnotationValue value: annotation.getExplicitValues()) { if (value instanceof JvmCustomAnnotationValue) { JvmCustomAnnotationValue custom = (JvmCustomAnnotationValue) value; for(Object object: custom.getValues()) { if (object instanceof XExpression) { rootedInstances.add(sourceElement); } } } else if (value instanceof JvmAnnotationAnnotationValue) { recordAnnotationExpressions(((JvmAnnotationAnnotationValue) value).getValues()); } } } } }
public JvmAnnotationReference findOrAddAnnotation(/* @NonNull */ JvmAnnotationTarget annotationTarget, /* @NonNull */ Notifier context, /* @NonNull */ Class<? extends Annotation> type) { JvmAnnotationReference result = findAnnotation(annotationTarget, type); if (result != null) return result; JvmAnnotationType annotationType = findAnnotationType(type, context); if (annotationType != null) { result = typesFactory.createJvmAnnotationReference(); result.setAnnotation(annotationType); return result; } return null; }
protected boolean isRelevant(JvmAnnotationReference annotationReference) { if (annotationReference == null || annotationReference.getAnnotation() == null || annotationReference.getAnnotation().getIdentifier() == null) return false; return getRelevantAnnotations().contains(annotationReference.getAnnotation().getIdentifier()); }
final JvmAnnotationReference baseJvmAnnotationReference = ((JvmAnnotationReferenceImpl)annotationReference).getDelegate(); ConditionUtils.notRemoved(baseJvmAnnotationReference, "annotationReference"); final JvmAnnotationReference newJvmAnnotationReference = this.createJvmAnnotationReference(baseJvmAnnotationReference.getAnnotation()); AnnotationReferenceBuildContextImpl _annotationReferenceBuildContextImpl = new AnnotationReferenceBuildContextImpl(); final Procedure1<AnnotationReferenceBuildContextImpl> _function = (AnnotationReferenceBuildContextImpl it) -> { List<String> _map = ListExtensions.<JvmAnnotationValue, String>map(baseJvmAnnotationReference.getExplicitValues(), _function_1); for (final String valueName : _map) {
throw new IllegalArgumentException("The given class " + annotationTypeName + " is not an annotation type."); result.setAnnotation((JvmAnnotationType) jvmType); if (value != null) { if (value instanceof String) { JvmStringAnnotationValue annotationValue = typesFactory.createJvmStringAnnotationValue(); annotationValue.getValues().add((String) value); result.getExplicitValues().add(annotationValue);
public JvmType getProcessorType(final JvmAnnotationType it) { final Function1<JvmAnnotationReference, Boolean> _function = (JvmAnnotationReference it_1) -> { JvmAnnotationType _annotation = it_1.getAnnotation(); String _identifier = null; if (_annotation!=null) { return Boolean.valueOf(((it_1.getOperation() == null) || Objects.equal(it_1.getOperation().getSimpleName(), "value"))); }; final JvmAnnotationValue annoVal = IterableExtensions.<JvmAnnotationValue>findFirst(activeAnnotation.getValues(), _function_1); boolean _matched = false; if (annoVal instanceof JvmTypeAnnotationValue) {
/** Extract the string value of the given annotation, if it exists. * * @param reference the reference to the annotation. * @return the value of the annotation, or {@code null} if no annotation or no * value. */ @SuppressWarnings("static-method") public String findStringValue(JvmAnnotationReference reference) { assert reference != null; for (final JvmAnnotationValue value : reference.getValues()) { if (value instanceof JvmStringAnnotationValue) { for (final String strValue : ((JvmStringAnnotationValue) value).getValues()) { if (strValue != null) { return strValue; } } } } return null; }
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); }
@Nullable public JvmAnnotationReference findOrAddAnnotation(@NonNull JvmAnnotationTarget annotationTarget, @NonNull Notifier context, @NonNull Class<? extends Annotation> type) { JvmAnnotationReference result = findAnnotation(annotationTarget, type); if (result != null) return result; JvmAnnotationType annotationType = findAnnotationType(type, context); if (annotationType != null) { result = typesFactory.createJvmAnnotationReference(); result.setAnnotation(annotationType); return result; } return null; }