use of org.eclipse.xtend.lib.annotations.ToString in project xtext-lib by eclipse.
the class ToStringProcessor method doTransform.
@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);
}
}
}
Aggregations