You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2019/09/05 17:20:09 UTC
[commons-lang] branch master updated: LANG-1485 : Add getters for
lhs and rhs objects in DiffResult (#451)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
The following commit(s) were added to refs/heads/master by this push:
new 9feaf9d LANG-1485 : Add getters for lhs and rhs objects in DiffResult (#451)
9feaf9d is described below
commit 9feaf9d7ffe3f4438ccdace378f49f1d4dadd418
Author: Nicolas <ni...@gmail.com>
AuthorDate: Thu Sep 5 19:20:04 2019 +0200
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
---
.../org/apache/commons/lang3/builder/DiffResult.java | 20 ++++++++++++++++++++
.../apache/commons/lang3/builder/DiffResultTest.java | 12 ++++++++++++
2 files changed, 32 insertions(+)
diff --git a/src/main/java/org/apache/commons/lang3/builder/DiffResult.java b/src/main/java/org/apache/commons/lang3/builder/DiffResult.java
index d6d031c..bb1ceec 100644
--- a/src/main/java/org/apache/commons/lang3/builder/DiffResult.java
+++ b/src/main/java/org/apache/commons/lang3/builder/DiffResult.java
@@ -89,6 +89,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
* there were no differences between the objects.
diff --git a/src/test/java/org/apache/commons/lang3/builder/DiffResultTest.java b/src/test/java/org/apache/commons/lang3/builder/DiffResultTest.java
index e321452..b92b34f 100644
--- a/src/test/java/org/apache/commons/lang3/builder/DiffResultTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/DiffResultTest.java
@@ -146,4 +146,16 @@ public class DiffResultTest {
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());
+ }
}