shashankrnr32 commented on PR #1082:
URL: https://github.com/apache/commons-lang/pull/1082#issuecomment-1656086372

   Adding a small example for more clarity. In the below example, lets say the 
usecase is to print "******" in place of the actual username (to mask the 
personally identifable information), this will help include the outputs of the 
methods by calling reflection invoke on the methods that are annotated with 
`@ToStringInclude`
   
   ```java
   
   package org.apache.commons.lang3.builder;
   
   import org.apache.commons.lang3.StringUtils;
   
   class TestFixture {
       @ToStringExclude
       private String username;
   
       @ToStringExclude
       private String phoneNumber;
   
       @ToStringInclude
       private String toStringUsername() {
           return StringUtils.repeat("*", StringUtils.length(username));
       }
   
       @ToStringInclude
       private String toStringPhoneNumber() {
           return StringUtils.repeat("*", StringUtils.length(phoneNumber));
       }
   
       @Override
       public String toString() {
           return new ReflectionToStringBuilder(this).build();
       }
   }
   ```


-- 
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]

Reply via email to