/** 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; }
/** Extract the integer values of the given annotation, if they exist. * * @param reference the reference to the annotation. * @return the values of the annotation, never {@code null}. * @since 0.6 */ @SuppressWarnings("static-method") public List<Integer> findIntValues(JvmAnnotationReference reference) { assert reference != null; final List<Integer> values = new ArrayList<>(); for (final JvmAnnotationValue value : reference.getValues()) { if (value instanceof JvmIntAnnotationValue) { for (final Integer intValue : ((JvmIntAnnotationValue) value).getValues()) { if (intValue != null) { values.add(intValue); } } } } return values; }
/** 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; }
/** 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; }
/** Extract the type 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<JvmTypeReference> findTypeValues(JvmAnnotationReference reference) { assert reference != null; final List<JvmTypeReference> values = new ArrayList<>(); for (final JvmAnnotationValue value : reference.getValues()) { if (value instanceof JvmTypeAnnotationValue) { for (final JvmTypeReference strValue : ((JvmTypeAnnotationValue) value).getValues()) { if (strValue != null) { values.add(strValue); } } } } return values; }
/** Extract the boolean values of the given annotation, if they exist. * * @param reference the reference to the annotation. * @return the values of the annotation, never {@code null}. * @since 0.6 */ @SuppressWarnings("static-method") public List<Boolean> findBooleanValues(JvmAnnotationReference reference) { assert reference != null; final List<Boolean> values = new ArrayList<>(); for (final JvmAnnotationValue value : reference.getValues()) { if (value instanceof JvmBooleanAnnotationValue) { for (final Boolean boolValue : ((JvmBooleanAnnotationValue) value).getValues()) { if (boolValue != null) { values.add(boolValue); } } } } return values; }
/** Extract the boolean 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 Boolean findBooleanValue(JvmAnnotationReference reference) { assert reference != null; for (final JvmAnnotationValue value : reference.getValues()) { if (value instanceof JvmBooleanAnnotationValue) { for (final Boolean intValue : ((JvmBooleanAnnotationValue) value).getValues()) { if (intValue != null) { return intValue; } } } } return null; }
private static boolean isConstantExpression(JvmAnnotationReference reference) { for (final JvmAnnotationValue annotationValue: reference.getValues()) { if ("constantExpression".equals(annotationValue.getValueName())) { if (annotationValue instanceof JvmBooleanAnnotationValue) { return ((JvmBooleanAnnotationValue) annotationValue).getValues().get(0).booleanValue(); } else if (annotationValue instanceof JvmCustomAnnotationValue) { final EObject value = ((JvmCustomAnnotationValue) annotationValue).getValues().get(0); if (value instanceof XBooleanLiteral) { return ((XBooleanLiteral) value).isIsTrue(); } } } } 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(); }
/** Replies the type of the field that represents a SARL capacity buffer. * * @param resolvedTypes the resolver of types. * @param field the field. * @return the type, never {@code null}. */ protected LightweightTypeReference getSarlCapacityFieldType(IResolvedTypes resolvedTypes, JvmField field) { // For capacity call redirection LightweightTypeReference fieldType = resolvedTypes.getActualType(field); final JvmAnnotationReference capacityAnnotation = this.annotationLookup.findAnnotation(field, ImportedCapacityFeature.class); if (capacityAnnotation != null) { final JvmTypeReference ref = ((JvmTypeAnnotationValue) capacityAnnotation.getValues().get(0)).getValues().get(0); fieldType = resolvedTypes.getActualType(ref.getType()); } return fieldType; }
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; }
String formatString = null; List<JvmTypeReference> importedTypes = Lists.newArrayListWithCapacity(2); for(JvmAnnotationValue annotationValue: inlineAnnotation.getValues()) { if ("value".equals(annotationValue.getValueName()) || null == annotationValue.getValueName()) { if (annotationValue instanceof JvmStringAnnotationValue) {
@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; }
for (final JvmAnnotationValue annotationValue: inlineAnnotation.getValues()) { final String valueName = annotationValue.getValueName(); if (Strings.isEmpty(valueName)) {
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) {
@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; }
return Boolean.valueOf((Objects.equal(it.getValueName(), "constantExpression") && IterableExtensions.<Boolean>head(it.getValues()).booleanValue())); }; boolean _exists = IterableExtensions.<JvmBooleanAnnotationValue>exists(Iterables.<JvmBooleanAnnotationValue>filter(annotationReference.getValues(), JvmBooleanAnnotationValue.class), _function); if (_exists) { boolean _xifexpression = false;
for (JvmAnnotationValue value: inlineAnnotation.getValues()) { if (value instanceof JvmBooleanAnnotationValue && value.getValueName().equals("constantExpression")) { EList<Boolean> values = ((JvmBooleanAnnotationValue )value).getValues();