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 2025/07/02 17:04:53 UTC

(commons-lang) 01/12: Sort members

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

commit 09430095a93ec3841dca47170f0a3b5ddad34bef
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jul 2 10:47:40 2025 -0400

    Sort members
---
 .../lang3/concurrent/EventCountCircuitBreaker.java | 84 +++++++++++-----------
 1 file changed, 42 insertions(+), 42 deletions(-)

diff --git a/src/main/java/org/apache/commons/lang3/concurrent/EventCountCircuitBreaker.java b/src/main/java/org/apache/commons/lang3/concurrent/EventCountCircuitBreaker.java
index 843a07d78..1139b3ed8 100644
--- a/src/main/java/org/apache/commons/lang3/concurrent/EventCountCircuitBreaker.java
+++ b/src/main/java/org/apache/commons/lang3/concurrent/EventCountCircuitBreaker.java
@@ -137,6 +137,48 @@
  */
 public class EventCountCircuitBreaker extends AbstractCircuitBreaker<Integer> {
 
+    /**
+     * Internally used class for executing check logic based on the current state of the
+     * circuit breaker. Having this logic extracted into special classes avoids complex
+     * if-then-else cascades.
+     */
+    private abstract static class AbstractStateStrategy {
+        /**
+         * Obtains the check interval to applied for the represented state from the given
+         * {@link CircuitBreaker}.
+         *
+         * @param breaker the {@link CircuitBreaker}
+         * @return the check interval to be applied
+         */
+        protected abstract long fetchCheckInterval(EventCountCircuitBreaker breaker);
+
+        /**
+         * Returns a flag whether the end of the current check interval is reached.
+         *
+         * @param breaker the {@link CircuitBreaker}
+         * @param currentData the current state object
+         * @param now the current time
+         * @return a flag whether the end of the current check interval is reached
+         */
+        public boolean isCheckIntervalFinished(final EventCountCircuitBreaker breaker,
+                final CheckIntervalData currentData, final long now) {
+            return now - currentData.getCheckIntervalStart() > fetchCheckInterval(breaker);
+        }
+
+        /**
+         * Checks whether the specified {@link CheckIntervalData} objects indicate that a
+         * state transition should occur. Here the logic which checks for thresholds
+         * depending on the current state is implemented.
+         *
+         * @param breaker the {@link CircuitBreaker}
+         * @param currentData the current {@link CheckIntervalData} object
+         * @param nextData the updated {@link CheckIntervalData} object
+         * @return a flag whether a state transition should be performed
+         */
+        public abstract boolean isStateTransition(EventCountCircuitBreaker breaker,
+                CheckIntervalData currentData, CheckIntervalData nextData);
+    }
+
     /**
      * An internally used data class holding information about the checks performed by
      * this class. Basically, the number of received events and the start time of the
@@ -191,48 +233,6 @@ public CheckIntervalData increment(final int delta) {
         }
     }
 
-    /**
-     * Internally used class for executing check logic based on the current state of the
-     * circuit breaker. Having this logic extracted into special classes avoids complex
-     * if-then-else cascades.
-     */
-    private abstract static class AbstractStateStrategy {
-        /**
-         * Obtains the check interval to applied for the represented state from the given
-         * {@link CircuitBreaker}.
-         *
-         * @param breaker the {@link CircuitBreaker}
-         * @return the check interval to be applied
-         */
-        protected abstract long fetchCheckInterval(EventCountCircuitBreaker breaker);
-
-        /**
-         * Returns a flag whether the end of the current check interval is reached.
-         *
-         * @param breaker the {@link CircuitBreaker}
-         * @param currentData the current state object
-         * @param now the current time
-         * @return a flag whether the end of the current check interval is reached
-         */
-        public boolean isCheckIntervalFinished(final EventCountCircuitBreaker breaker,
-                final CheckIntervalData currentData, final long now) {
-            return now - currentData.getCheckIntervalStart() > fetchCheckInterval(breaker);
-        }
-
-        /**
-         * Checks whether the specified {@link CheckIntervalData} objects indicate that a
-         * state transition should occur. Here the logic which checks for thresholds
-         * depending on the current state is implemented.
-         *
-         * @param breaker the {@link CircuitBreaker}
-         * @param currentData the current {@link CheckIntervalData} object
-         * @param nextData the updated {@link CheckIntervalData} object
-         * @return a flag whether a state transition should be performed
-         */
-        public abstract boolean isStateTransition(EventCountCircuitBreaker breaker,
-                CheckIntervalData currentData, CheckIntervalData nextData);
-    }
-
     /**
      * A specialized {@link AbstractStateStrategy} implementation for the state closed.
      */