You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2005/10/05 02:01:44 UTC
DO NOT REPLY [Bug 36925] -
[lang] Using ReflectionToStringBuilder and excluding secure fields
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=36925>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=36925
------- Additional Comments From ggregory@seagullsw.com 2005-10-05 02:01 -------
-----Original Message-----
From: Gary Gregory [mailto:ggregory@seagullsoftware.com]
Sent: Thursday, August 04, 2005 11:33 AM
To: Jakarta Commons Developers List
Subject: [lang] Using ReflectionToStringBuilder and excluding secure fields
Hello:
Right now, I use the code below to exclude password fields from output.
/**
* Builds a String for a toString method excluding the given field
name.
*
* @param obj
* The object to "toString".
* @param excludeFieldName
* The field name to exclude
* @return The toString String.
*/
public static String toStringExcluding(Object obj, final String
excludeFieldName) {
return (new ReflectionToStringBuilder(obj) {
protected boolean accept(Field f) {
return super.accept(f) &&
!f.getName().equals(excludeFieldName);
}
}).toString();
}
I could imagine writing my call sites like this instead:
new ReflectionToStringBuilder(obj).setExcludeFields(new
String[]{"password"}).toString();
Which means adding the set/getExcludeFields() feature.
Any thoughts?
Gary
--
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org