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 2021/12/06 13:50:39 UTC

[commons-vfs] branch master updated: Checkstyle and internal refactoring.

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-vfs.git


The following commit(s) were added to refs/heads/master by this push:
     new a07a5e4  Checkstyle and internal refactoring.
a07a5e4 is described below

commit a07a5e4abf79e902089924baa13ef1aaf8cf4d81
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Dec 6 08:50:36 2021 -0500

    Checkstyle and internal refactoring.
---
 .../org/apache/commons/vfs2/util/RandomAccessMode.java  | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/RandomAccessMode.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/RandomAccessMode.java
index 4e485e7..f550896 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/RandomAccessMode.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/util/RandomAccessMode.java
@@ -20,6 +20,8 @@ import java.nio.file.AccessMode;
 import java.util.Arrays;
 import java.util.Objects;
 
+import org.apache.commons.lang3.ArraySorter;
+
 /**
  * An enumerated type representing the modes of a random access content.
  * <p>
@@ -54,12 +56,7 @@ public enum RandomAccessMode {
      * @since 2.10.0
      */
     public static RandomAccessMode from(final AccessMode... accessModes) {
-        Objects.requireNonNull(accessModes, "accessModes");
-        if (accessModes.length == 0) {
-            throw new IllegalArgumentException("Empty AccessMode[].");
-        }
-        final AccessMode modes[] = accessModes.clone();
-        Arrays.sort(modes);
+        final AccessMode[] modes = sort(accessModes);
         if (Arrays.binarySearch(modes, AccessMode.WRITE) >= 0) {
             return READWRITE;
         }
@@ -69,6 +66,14 @@ public enum RandomAccessMode {
         throw new IllegalArgumentException(Arrays.toString(accessModes));
     }
 
+    private static AccessMode[] sort(final AccessMode... accessModes) {
+        Objects.requireNonNull(accessModes, "accessModes");
+        if (accessModes.length == 0) {
+            throw new IllegalArgumentException("Empty AccessMode[].");
+        }
+        return ArraySorter.sort(accessModes.clone());
+    }
+
     /**
      * @return The mode String.
      * @since 2.0