diff --git a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java index bc3fdbb1a..efed58c3b 100644 --- a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java +++ b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,34 +32,34 @@ import org.apache.commons.lang3.ClassUtils; *
* Assists in implementing {@link Object#toString()} methods using reflection. *
- * + * ** This class uses reflection to determine the fields to append. Because these fields are usually private, the class * uses {@link java.lang.reflect.AccessibleObject#setAccessible(java.lang.reflect.AccessibleObject[], boolean)} to * change the visibility of the fields. This will fail under a security manager, unless the appropriate permissions are * set up correctly. *
- * + * ** A typical invocation for this method would look like: *
- * + * ** public String toString() { * return ReflectionToStringBuilder.toString(this); * }- * - * - * + * + * + * *
* You can also use the builder to debug 3rd party objects: *
- * + * ** System.out.println("An object: " + ReflectionToStringBuilder.toString(anObject));- * - * - * + * + * + * *
* A subclass can control field output by overriding the methods: *
password
field in the returned
* String
:
*
- *
+ *
* * public String toString() { * return (new ReflectionToStringBuilder(this) { @@ -80,14 +80,14 @@ import org.apache.commons.lang3.ClassUtils; * } * }).toString(); * }- * - * - * + * + * + * *
* The exact format of the toString
is determined by the {@link ToStringStyle} passed into the
* constructor.
*
* Builds a toString
value using the default ToStringStyle
through reflection.
*
* It uses AccessibleObject.setAccessible
to gain access to private fields. This means that it will
* throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
* also not as efficient as testing explicitly.
*
* Transient members will be not be included, as they are likely derived. Static fields will not be included. * Superclass fields will be appended. *
- * + * * @param object * the Object to be output * @return the String result @@ -126,22 +126,22 @@ public class ReflectionToStringBuilder extends ToStringBuilder { *
* Builds a toString
value through reflection.
*
* It uses AccessibleObject.setAccessible
to gain access to private fields. This means that it will
* throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
* also not as efficient as testing explicitly.
*
* Transient members will be not be included, as they are likely derived. Static fields will not be included. * Superclass fields will be appended. *
- * + * *
* If the style is null
, the default ToStringStyle
is used.
*
* Builds a toString
value through reflection.
*
* It uses AccessibleObject.setAccessible
to gain access to private fields. This means that it will
* throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
* also not as efficient as testing explicitly.
*
* If the outputTransients
is true
, transient members will be output, otherwise they
* are ignored, as they are likely derived fields, and not part of the value of the Object.
*
* Static fields will not be included. Superclass fields will be appended. *
- * + * *
* If the style is null
, the default ToStringStyle
is used.
*
* Builds a toString
value through reflection.
*
* It uses AccessibleObject.setAccessible
to gain access to private fields. This means that it will
* throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
* also not as efficient as testing explicitly.
*
* If the outputTransients
is true
, transient fields will be output, otherwise they
* are ignored, as they are likely derived fields, and not part of the value of the Object.
*
* If the outputStatics
is true
, static fields will be output, otherwise they are
* ignored.
*
* Static fields will not be included. Superclass fields will be appended. *
- * + * *
* If the style is null
, the default ToStringStyle
is used.
*
* Builds a toString
value through reflection.
*
* It uses AccessibleObject.setAccessible
to gain access to private fields. This means that it will
* throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
* also not as efficient as testing explicitly.
*
* If the outputTransients
is true
, transient fields will be output, otherwise they
* are ignored, as they are likely derived fields, and not part of the value of the Object.
*
* If the outputStatics
is true
, static fields will be output, otherwise they are
* ignored.
*
* Superclass fields will be appended up to and including the specified superclass. A null superclass is treated as
* java.lang.Object
.
*
* If the style is null
, the default ToStringStyle
is used.
*
null
- * entries. Note that {@link Arrays#sort(Object[])} will throw an {@link NullPointerException} if an array element
+ * entries. Note that {@link Arrays#sort(Object[])} will throw an {@link NullPointerException} if an array element
* is null
.
- *
+ *
* @param collection
* The collection to convert
* @return A new array of Strings.
@@ -334,9 +336,9 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
/**
* Returns a new array of Strings without null elements. Internal method used to normalize exclude lists
- * (arrays and collections). Note that {@link Arrays#sort(Object[])} will throw an {@link NullPointerException}
+ * (arrays and collections). Note that {@link Arrays#sort(Object[])} will throw an {@link NullPointerException}
* if an array element is null
.
- *
+ *
* @param array
* The array to check
* @return The given array or a new array without null.
@@ -350,11 +352,11 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
}
return list.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
}
-
+
/**
* Builds a String for a toString method excluding the given field names.
- *
+ *
* @param object
* The object to "toString".
* @param excludeFieldNames
@@ -391,11 +393,11 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
* * Constructor. *
- * + * *
* This constructor outputs using the default style set with setDefaultStyle
.
*
toString
for, must not be null
* @throws IllegalArgumentException
@@ -409,11 +411,11 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
* * Constructor. *
- * + * *
* If the style is null
, the default style is used.
*
toString
for, must not be null
* @param style
@@ -429,15 +431,15 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
* * Constructor. *
- * + * *
* If the style is null
, the default style is used.
*
* If the buffer is null
, a new one is created.
*
toString
for
* @param style
@@ -453,7 +455,9 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
/**
* Constructor.
- *
+ *
+ * @param toString
for
* @param style
@@ -484,7 +488,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
* true
.
* Field
.
@@ -514,12 +518,12 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
* * Appends the fields and values defined by the given object of the given Class. *
- * + * *
* If a cycle is detected as an object is "toString()'ed", such an object is rendered as if
* Object.toString()
had been called and not implemented by the object.
*
* Gets the last super class to stop appending fields for. *
- * + * * @return The last super class to stop appending fields for. */ public Class> getUpToClass() { @@ -571,16 +575,16 @@ public class ReflectionToStringBuilder extends ToStringBuilder { *
* Calls java.lang.reflect.Field.get(Object)
.
*
* Gets whether or not to append static fields. *
- * + * * @return Whether or not to append static fields. * @since 2.1 */ @@ -603,7 +607,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { ** Gets whether or not to append transient fields. *
- * + * * @return Whether or not to append transient fields. */ public boolean isAppendTransients() { @@ -614,7 +618,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { *
* Append to the toString
an Object
array.
*
toString
* @return this
@@ -628,7 +632,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
* * Sets whether or not to append static fields. *
- * + * * @param appendStatics * Whether or not to append static fields. * @since 2.1 @@ -641,7 +645,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { ** Sets whether or not to append transient fields. *
- * + * * @param appendTransients * Whether or not to append transient fields. */ @@ -651,7 +655,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { /** * Sets the field names to exclude. - * + * * @param excludeFieldNamesParam * The excludeFieldNames to excluding from toString ornull
.
* @return this
@@ -670,7 +674,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
* * Sets the last super class to stop appending fields for. *
- * + * * @param clazz * The last super class to stop appending fields for. */ @@ -688,7 +692,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { ** Gets the String built by this builder. *
- * + * * @return the built string */ @Override