mirror of
https://github.com/apache/commons-lang.git
synced 2025-02-10 12:05:06 +00:00
LANG-1485 : Add getters for lhs and rhs objects in DiffResult (#451)
* LANG-1485 : Add getters for lhs and rhs objects in DiffResult * add @since and rename getters to getLeft and getRight * fix typo on @since tag
This commit is contained in:
parent
3c44319a17
commit
9feaf9d7ff
@ -88,6 +88,26 @@ public class DiffResult implements Iterable<Diff<?>> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns the object the right object has been compared to.</p>
|
||||
*
|
||||
* @return the left object of the diff
|
||||
* @since 3.10
|
||||
*/
|
||||
public Object getLeft() {
|
||||
return this.lhs;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns the object the left object has been compared to.</p>
|
||||
*
|
||||
* @return the right object of the diff
|
||||
* @since 3.10
|
||||
*/
|
||||
public Object getRight() {
|
||||
return this.rhs;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Returns an unmodifiable list of {@code Diff}s. The list may be empty if
|
||||
|
@ -146,4 +146,16 @@ public void testNoDifferencesString() {
|
||||
SHORT_STYLE).build();
|
||||
assertEquals(DiffResult.OBJECTS_SAME_STRING, diffResult.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLeftAndRightGetters() {
|
||||
final SimpleClass left = new SimpleClass(true);
|
||||
final SimpleClass right = new SimpleClass(false);
|
||||
|
||||
final List<Diff<?>> diffs = left.diff(right).getDiffs();
|
||||
final DiffResult diffResult = new DiffResult(left, right, diffs, SHORT_STYLE);
|
||||
|
||||
assertEquals(left, diffResult.getLeft());
|
||||
assertEquals(right, diffResult.getRight());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user