You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Liran Mendelovich (Jira)" <ji...@apache.org> on 2021/06/29 09:43:00 UTC
[jira] [Commented] (LANG-1466) new property "omitNullValues"
ToStringBuilder
[ https://issues.apache.org/jira/browse/LANG-1466?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17371267#comment-17371267 ]
Liran Mendelovich commented on LANG-1466:
-----------------------------------------
Out of the box implementation exists:
_ReflectionToStringBuilder.toString(new Pojo(), ToStringStyle.DEFAULT_STYLE, true, false, *true*, null)_
Output is as requested:
{{general.Pojo@3532ec19[description=Manchester,id=1]}}
Using:
_public static String toString( final T object, final ToStringStyle style, final boolean outputTransients, final boolean outputStatics, final boolean *excludeNullValues*, final Class<? super T> reflectUpToClass)_
> new property "omitNullValues" ToStringBuilder
> ---------------------------------------------
>
> Key: LANG-1466
> URL: https://issues.apache.org/jira/browse/LANG-1466
> Project: Commons Lang
> Issue Type: Improvement
> Components: lang.builder.*
> Affects Versions: 3.9
> Reporter: nimo mayr
> Priority: Major
> Time Spent: 40m
> Remaining Estimate: 0h
>
> Actually, commons lang "{{ReflectionToStringBuilder"}} *cannot exclude null values*{{:}}
>
> {code:java}
> return ToStringBuilder.reflectionToString(object, ToStringStyle.MULTI_LINE_STYLE);{code}
> Please provide a new property "omitNullValues" to exclude null values from the "object"-string.
>
> {code:java}
> boolean omitNullValues = true;
> return ToStringBuilder.reflectionToString(object, ToStringStyle.MULTI_LINE_STYLE, omitNullValues);
> {code}
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)