mirror of
https://github.com/apache/commons-lang.git
synced 2025-02-09 03:24:58 +00:00
javadoc corrections:
- corrected name of append method in code example - changed <code> tag to <pre> tag around code examples for better formatting - corrected reflection method name in explanation text git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137080 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9380c2fdd6
commit
48281f8ffb
@ -72,37 +72,37 @@
|
||||
* code must be used in the equals method, and vice versa.
|
||||
* <p>
|
||||
* Typical use for the code is as follows:
|
||||
* <code>
|
||||
* <pre>
|
||||
* public boolean equals(Object o) {
|
||||
* if (!o instanceof MyClass) {
|
||||
* return false;
|
||||
* }
|
||||
* MyClass rhs = (MyClass) o;
|
||||
* return new EqualsBuilder()
|
||||
* .test(field1, rhs.field1)
|
||||
* .test(field2, rhs.field2)
|
||||
* .test(field3, rhs.field3)
|
||||
* .append(field1, rhs.field1)
|
||||
* .append(field2, rhs.field2)
|
||||
* .append(field3, rhs.field3)
|
||||
* .isEquals();
|
||||
* }
|
||||
* </code>
|
||||
* </pre>
|
||||
* <p>
|
||||
* Alternatively, there is a method that uses reflection to determine
|
||||
* the fields to test. Because these fields are usually private, the method,
|
||||
* <code>reflectionTest</code>, uses <code>Field.setAccessible</code> to change
|
||||
* <code>reflectionEquals</code>, uses <code>Field.setAccessible</code> to change
|
||||
* the visibility of the fields. This will fail under a security manager,
|
||||
* unless the appropriate permissions are set. It is also slower than testing
|
||||
* explicitly.
|
||||
* <p>
|
||||
* A typical invocation for this method would look like:
|
||||
* <code>
|
||||
* <pre>
|
||||
* public boolean equals(Object o) {
|
||||
* return EqualsBuilder.reflectionEquals(this, obj);
|
||||
* }
|
||||
* </code>
|
||||
* </pre>
|
||||
*
|
||||
* @author <a href="mailto:steve.downey@netfolio.com">Steve Downey</a>
|
||||
* @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
|
||||
* @version $Id: EqualsBuilder.java,v 1.3 2002/09/22 09:18:32 scolebourne Exp $
|
||||
* @version $Id: EqualsBuilder.java,v 1.4 2002/10/01 20:00:43 stevencaswell Exp $
|
||||
*/
|
||||
public class EqualsBuilder {
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user