I would like to see Lombok auto trimming strings. Perhaps as an
attribute to the data annotation, or @Trim or as an attribute to the
@Getter and @Setter.
That would be useful.
--
You received this message because you are subscribed to the Google
Groups group for http://projectlombok.org/
To post to this group, send email to project...@googlegroups.com
To unsubscribe from this group, send email to
project-lombo...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/project-lombok?hl=en
To unsubscribe, reply using "remove me" as the subject.
I'll put down a strawman lombok-based version first:
@Data
@FieldAccessModifiers({StringTrimmer.class},
{UnicodeNormalizer.class})
public class Movie {
private final String name;
private final int year;
private final String director;
@Getter @FieldAccessModifiers(Normal.class)
private final String id;
}
Readable? At first look this doesn't really strike me as fantastic.
Let's contrast it to something like this:
@Data
public class Movie {
private final String name;
private final int year;
private final String director;
private final String id;
public String getName() {
return unicodeNormalize(name.trim());
}
public String getDirector() {
return unicodeNormalize(name.trim());
}
}
This presumes that equals and hashCode and toString get rewritten to
use getters and not the raw fields. I doubt the considerable
complexity of the first example is worth it; it's barely shorter.
NB: Go Ki, that looks awesome. Roel and I are explicitly holding back
on adding features to @Data and friends until we assess what a
property-based system can do.