Annotation Type ToPrettyString
-
@Documented @Target(METHOD) public @interface ToPrettyString
Annotates instance methods that return an easy-to-readStringrepresenting the instance. When the method isabstractand enclosed in anAutoValueclass, an implementation of the method will be automatically generated.When generating an implementation of an
@ToPrettyStringmethod, each property of the@AutoValuetype is individually printed in an easy-to-read format. If the type of the property itself has a@ToPrettyStringmethod, that method will be called in assistance of computing the pretty string. Non-@AutoValueclasses can contribute a pretty string representation by annotating a method with@ToPrettyString.CollectionandCollection-like types have special representations in generated pretty strings.If no
@ToPrettyStringmethod is found on a type and the type is not one with a built in rendering, theObject.toString()value will be used instead.@ToPrettyStringis valid on overriddentoString()and other methods alike.Example
@AutoValueabstract class Pretty { abstractList<String>property();@ToPrettyStringabstract String toPrettyString(); } System.out.println(new AutoValue_Pretty(List.of("abc", "def", "has\nnewline)).toPrettyString()) // Pretty{ // property = [ // abc, // def, // has // newline, // ] // } }