removed ArrayUtils.get
Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/2cad60b6 Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/2cad60b6 Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/2cad60b6 Branch: refs/heads/master Commit: 2cad60b6c25c87a6a59d3d315ec7d72c552fbc58 Parents: ec2ec77 Author: MarkDacek <mark.da...@richmond.edu> Authored: Sat Jul 14 15:42:14 2018 -0400 Committer: MarkDacek <mark.da...@richmond.edu> Committed: Sat Jul 14 15:42:14 2018 -0400 ---------------------------------------------------------------------- .../org/apache/commons/lang3/ArrayUtils.java | 33 -------------------- .../apache/commons/lang3/ArrayUtilsTest.java | 16 ---------- 2 files changed, 49 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-lang/blob/2cad60b6/src/main/java/org/apache/commons/lang3/ArrayUtils.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/commons/lang3/ArrayUtils.java b/src/main/java/org/apache/commons/lang3/ArrayUtils.java index 9ed6b68..f6b1131 100644 --- a/src/main/java/org/apache/commons/lang3/ArrayUtils.java +++ b/src/main/java/org/apache/commons/lang3/ArrayUtils.java @@ -8674,39 +8674,6 @@ public class ArrayUtils { } /** - * Gets an element from the array if the array is non-null and appropriately long, otherwise returns null - * @param <T> the component type of the array, may be null - * @param array the array holding the desired element - * @param index the index of the element in the array - * @return The element in the array at the index, or null if the array is not sufficiently long for the index. May return null if the array contains null - * @since 3.8 - */ - public static <T> T get(T[] array, int index){ - return get(array, index, null); - } - - /** - * Gets an element from the array if the array is non-null and appropriately long, otherwise returns the specified value - * @param <T> the component type of the array - * @param array the array holding the desired element, may be null - * @param index the index of the element in the array - * @param defaultReturn the object to be returned if the array is null or shorter than the index - * @return The element in the array at the specified index, or the given argument if it the array is not sufficiently long for the index. May return null if the array contains null - * @since 3.8 - */ - public static <T> T get(T[] array, int index, T defaultReturn){ - if(getLength(array) == 0 || array.length <= index){ - return defaultReturn; - } - - if(index < 0 ){ - return defaultReturn; - } - - return array[index]; - } - - /** * Returns whether a given array can safely be accessed at the given index. * @param <T> the component type of the array * @param array the array to inspect http://git-wip-us.apache.org/repos/asf/commons-lang/blob/2cad60b6/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java index 0121473..335b9a4 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java @@ -5113,22 +5113,6 @@ public class ArrayUtilsTest { } @Test - public void testGet(){ - assertNull(ArrayUtils.get(null, 0)); - String[] array = new String[1]; - assertNull(ArrayUtils.get(array, 1)); - array[0] = "Hello World"; - //test with happy path - assertNotNull(ArrayUtils.get(array, 0)); - - //test with default getter - assertEquals("Test", ArrayUtils.get(array, 10, "Test")); - - //negative index - assertEquals("Default", ArrayUtils.get(array, -1, "Default")); - } - - @Test public void testIsArrayIndexValid(){ assertFalse(ArrayUtils.isArrayIndexValid(null, 0)); String[] array = new String[1];