diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2018-04-23 23:43:15 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2018-05-14 22:03:46 +0200 |
commit | ad21a1573bab57c63ffd5b9867f8e19ac7f0c94b (patch) | |
tree | 6aeb4aff3490999ff799374cf9cbbbc33a5d03c5 /src/core/lombok/ToString.java | |
parent | 82a7354a848a26021afd3a889cefd65db7693eb9 (diff) | |
download | lombok-ad21a1573bab57c63ffd5b9867f8e19ac7f0c94b.tar.gz lombok-ad21a1573bab57c63ffd5b9867f8e19ac7f0c94b.tar.bz2 lombok-ad21a1573bab57c63ffd5b9867f8e19ac7f0c94b.zip |
[annotation based ToString] hey.. we have annotation based ToString now, where you can include/exclude fields by annotating the fields.
Diffstat (limited to 'src/core/lombok/ToString.java')
-rw-r--r-- | src/core/lombok/ToString.java | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/core/lombok/ToString.java b/src/core/lombok/ToString.java index 0c43c40b..218e4c00 100644 --- a/src/core/lombok/ToString.java +++ b/src/core/lombok/ToString.java @@ -45,6 +45,8 @@ public @interface ToString { /** * Any fields listed here will not be printed in the generated {@code toString} implementation. * Mutually exclusive with {@link #of()}. + * <p> + * Will soon be marked {@code @Deprecated}; use the {@code @ToString.Exclude} annotation instead. * * @return A list of fields to exclude. */ @@ -55,6 +57,8 @@ public @interface ToString { * Normally, all non-static fields are printed. * <p> * Mutually exclusive with {@link #exclude()}. + * <p> + * Will soon be marked {@code @Deprecated}; use the {@code @ToString.Only} annotation instead. * * @return A list of fields to use (<em>default</em>: all of them). */ @@ -75,4 +79,33 @@ public @interface ToString { * @return If {@code true}, always use direct field access instead of calling the getter method. */ boolean doNotUseGetters() default false; + + /** + * Only include fields and methods explicitly marked with {@code @ToString.Include}. + * Normally, all (non-static) fields are included by default. + */ + boolean onlyExplicitlyIncluded() default false; + + /** + * If present, do not include this field in the generated {@code toString}. + */ + @Target(ElementType.FIELD) + @Retention(RetentionPolicy.SOURCE) + public @interface Exclude {} + + /** + * Configure the behaviour of how this member is rendered in the {@code toString}; if on a method, include the method's return value in the output. + */ + @Target({ElementType.FIELD, ElementType.METHOD}) + @Retention(RetentionPolicy.SOURCE) + public @interface Include { +// /** If true and the return value is {@code null}, omit this member entirely from the {@code toString} output. */ +// boolean skipNull() default false; // -- We'll add it later, it requires a complete rework on the toString code we generate. + + /** Higher ranks are printed first. Members of the same rank are printed in the order they appear in the source file. */ + int rank() default 0; + + /** Defaults to the field / method name of the annotated member. If the name equals the name of a default-included field, this member takes its place. */ + String name() default ""; + } } |