This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 4116edbe084709898cdee3f1d9b147631f3ad86f
Author: Otavio Rodolfo Piske <angusyo...@gmail.com>
AuthorDate: Fri May 10 14:25:01 2024 +0200

    (chores) camel-mock: code cleanup
    
    - break large and complex methods
---
 .../apache/camel/component/mock/TimeClause.java    | 43 ++++++++++++----------
 1 file changed, 24 insertions(+), 19 deletions(-)

diff --git 
a/components/camel-mock/src/main/java/org/apache/camel/component/mock/TimeClause.java
 
b/components/camel-mock/src/main/java/org/apache/camel/component/mock/TimeClause.java
index 2328e39cdc4..4350990d1a1 100644
--- 
a/components/camel-mock/src/main/java/org/apache/camel/component/mock/TimeClause.java
+++ 
b/components/camel-mock/src/main/java/org/apache/camel/component/mock/TimeClause.java
@@ -153,25 +153,7 @@ public class TimeClause implements BinaryPredicate {
 
         Date currentDate = exchange.getProperty(Exchange.RECEIVED_TIMESTAMP, 
Date.class);
 
-        // the other date is either the previous or the next
-        Date otherDate;
-        if (beforeNext) {
-            // grab the previous value (left)
-            if (leftValue != null) {
-                otherDate = (Date) leftValue;
-            } else {
-                // we hit a boundary so grab the other
-                otherDate = (Date) rightValue;
-            }
-        } else {
-            // grab the next value (right)
-            if (rightValue != null) {
-                otherDate = (Date) rightValue;
-            } else {
-                // we hit a boundary so grab the other
-                otherDate = (Date) leftValue;
-            }
-        }
+        final Date otherDate = getOtherDate(leftValue, rightValue);
 
         // if we could not grab the value, we hit a boundary (ie. either 0 
message or last message)
         if (otherDate == null) {
@@ -202,6 +184,29 @@ public class TimeClause implements BinaryPredicate {
         return answer;
     }
 
+    private Date getOtherDate(Object leftValue, Object rightValue) {
+        // the other date is either the previous or the next
+        Date otherDate;
+        if (beforeNext) {
+            // grab the previous value (left)
+            if (leftValue != null) {
+                otherDate = (Date) leftValue;
+            } else {
+                // we hit a boundary so grab the other
+                otherDate = (Date) rightValue;
+            }
+        } else {
+            // grab the next value (right)
+            if (rightValue != null) {
+                otherDate = (Date) rightValue;
+            } else {
+                // we hit a boundary so grab the other
+                otherDate = (Date) leftValue;
+            }
+        }
+        return otherDate;
+    }
+
     @Override
     public String getOperator() {
         return getOperationText();

Reply via email to