Java Code Examples for org.eclipse.xtend.lib.annotations.ToString

The following examples show how to use org.eclipse.xtend.lib.annotations.ToString. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: xtext-lib   Source File: ToStringProcessor.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public ToStringConfiguration getToStringConfig(final ClassDeclaration it) {
  ToStringConfiguration _xblockexpression = null;
  {
    final AnnotationReference anno = it.findAnnotation(this.context.findTypeGlobally(ToString.class));
    ToStringConfiguration _xifexpression = null;
    if ((anno == null)) {
      _xifexpression = null;
    } else {
      _xifexpression = new ToStringConfiguration(anno);
    }
    _xblockexpression = _xifexpression;
  }
  return _xblockexpression;
}
 
Example 2
Source Project: xtext-lib   Source File: ToStringProcessor.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void doTransform(final MutableClassDeclaration it, @Extension final TransformationContext context) {
  AnnotationReference _findAnnotation = it.findAnnotation(context.findTypeGlobally(Data.class));
  boolean _tripleNotEquals = (_findAnnotation != null);
  if (_tripleNotEquals) {
    return;
  }
  @Extension
  final ToStringProcessor.Util util = new ToStringProcessor.Util(context);
  final AnnotationReference annotation = it.findAnnotation(context.findTypeGlobally(ToString.class));
  final ToStringConfiguration configuration = new ToStringConfiguration(annotation);
  boolean _hasToString = util.hasToString(it);
  if (_hasToString) {
    context.addWarning(annotation, "toString is already defined, this annotation has no effect.");
  } else {
    TypeReference _extendedClass = it.getExtendedClass();
    TypeReference _object = context.getObject();
    boolean _notEquals = (!Objects.equal(_extendedClass, _object));
    if (_notEquals) {
      util.addReflectiveToString(it, configuration);
    } else {
      final Function1<MutableFieldDeclaration, Boolean> _function = (MutableFieldDeclaration it_1) -> {
        return Boolean.valueOf(((context.isThePrimaryGeneratedJavaElement(it_1) && (!it_1.isStatic())) && (!it_1.isTransient())));
      };
      util.addToString(it, IterableExtensions.filter(it.getDeclaredFields(), _function), configuration);
    }
  }
}
 
Example 3
Source Project: sarl   Source File: SARLValidator.java    License: Apache License 2.0 5 votes vote down vote up
/** Replies if the given annotation is an active annotation for object-oriented elements.
 *
 * @param annotation the annotation.
 * @return {@code true} if the annotation should be used only for OO elements.
 * @see #isAOActiveAnnotation(XAnnotation)
 */
@SuppressWarnings("static-method")
protected boolean isOOActiveAnnotation(XAnnotation annotation) {
	final String name = annotation.getAnnotationType().getQualifiedName();
	return Strings.equal(Accessors.class.getName(), name)
			|| Strings.equal(Data.class.getName(), name)
			|| Strings.equal(Delegate.class.getName(), name)
			|| Strings.equal(ToString.class.getName(), name);
}