[
https://issues.apache.org/jira/browse/LANG-1662?focusedWorklogId=737160&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-737160
]
ASF GitHub Bot logged work on LANG-1662:
----------------------------------------
Author: ASF GitHub Bot
Created on: 05/Mar/22 18:44
Start Date: 05/Mar/22 18:44
Worklog Time Spent: 10m
Work Description: garydgregory commented on pull request #849:
URL: https://github.com/apache/commons-lang/pull/849#issuecomment-1059813450
Hello @GutoVeronezi
Thank you for your PR.
The name `setSelectedFieldNames1 is confusing because it is not symmetric
(for lack of a better word) with `setExcludeFieldNames`, I think it would be
best as `setIncludeFieldNames` which then is a bit odd since ALL fields are
included by default, so there should be _clear_ documentation that using
`setIncludeFieldNames` overrides this default behavior.
The following behavior should throw an `IllegalStateException` IMO:
```
ReflectionToStringBuilder reflectionToStringBuilder = new
ReflectionToStringBuilder(example, ToStringStyle.JSON_STYLE);
reflectionToStringBuilder.setIncludedFieldNames("a", "b", "e");
reflectionToStringBuilder.setExcludedFieldNames("a", "b", "e"); //
throws IllegalStateException?
System.out.println(reflectionToStringBuilder.build()); // throws
IllegalStateException?
```
IOW what does it mean to set a field as both included and excluded, does the
"last API call win" or, does the code simply throw an `IllegalStateException`
if the include and exclude set intersect?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 737160)
Remaining Estimate: 4h 40m (was: 4h 50m)
Time Spent: 1h 20m (was: 1h 10m)
> Create methods on ReflectionToStringBuilder to reflect only select fields
> -------------------------------------------------------------------------
>
> Key: LANG-1662
> URL: https://issues.apache.org/jira/browse/LANG-1662
> Project: Commons Lang
> Issue Type: Improvement
> Components: lang.builder.*
> Reporter: Daniel Augusto Veronezi Salvador
> Priority: Minor
> Original Estimate: 6h
> Time Spent: 1h 20m
> Remaining Estimate: 4h 40m
>
> *ReflectionToStringBuilder* has methods to exclude fields from *toString*; If
> we have an object with several fields and want to reflect only a fews, we
> have to list all the fields that we don't want to reflect and pass to
> *excludeFieldNames*.
> Would be valid implement a way to pass the fields that we want and reflect
> only the selected fields?
>
>
--
This message was sent by Atlassian Jira
(v8.20.1#820001)