Cloning the output from getExcludeFieldNames, adjusting the code to use the attribute directly so it doesn't pay the clone() cost every time and changing the attribute from private to protected to let subclasses retain the ability to modify the field names (if that is why a getExcludeFieldNames method existed). Document in LANG-489
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@775432 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
58178ddfd8
commit
f38cdfbf8c
|
@ -378,7 +378,7 @@ public class ReflectionToStringBuilder<T> extends ToStringBuilder<T> {
|
|||
/**
|
||||
* Which field names to exclude from output. Intended for fields like <code>"password"</code>.
|
||||
*/
|
||||
private String[] excludeFieldNames;
|
||||
protected String[] excludeFieldNames;
|
||||
|
||||
/**
|
||||
* The last super class to stop appending fields for.
|
||||
|
@ -496,11 +496,11 @@ public class ReflectionToStringBuilder<T> extends ToStringBuilder<T> {
|
|||
return false;
|
||||
}
|
||||
if (Modifier.isStatic(field.getModifiers()) && !this.isAppendStatics()) {
|
||||
// Rject static fields.
|
||||
// Reject static fields.
|
||||
return false;
|
||||
}
|
||||
if (this.getExcludeFieldNames() != null
|
||||
&& Arrays.binarySearch(this.getExcludeFieldNames(), field.getName()) >= 0) {
|
||||
if (this.excludeFieldNames != null
|
||||
&& Arrays.binarySearch(this.excludeFieldNames, field.getName()) >= 0) {
|
||||
// Reject fields from the getExcludeFieldNames list.
|
||||
return false;
|
||||
}
|
||||
|
@ -550,7 +550,7 @@ public class ReflectionToStringBuilder<T> extends ToStringBuilder<T> {
|
|||
* @return Returns the excludeFieldNames.
|
||||
*/
|
||||
public String[] getExcludeFieldNames() {
|
||||
return this.excludeFieldNames;
|
||||
return this.excludeFieldNames.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue