Use ArrayUtils::isArrayIndexValid method in ArrayUtils::get. (#552)
This commit is contained in:
parent
553a3a75df
commit
496eb10372
|
@ -1679,13 +1679,7 @@ public class ArrayUtils {
|
||||||
* @since 3.11
|
* @since 3.11
|
||||||
*/
|
*/
|
||||||
public static <T> T get(final T[] array, final int index, final T defaultValue) {
|
public static <T> T get(final T[] array, final int index, final T defaultValue) {
|
||||||
if (array == null) {
|
return isArrayIndexValid(array, index) ? array[index] : defaultValue;
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
if (index >= 0 && index < array.length) {
|
|
||||||
return array[index];
|
|
||||||
}
|
|
||||||
return defaultValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue