Use ArrayUtils::isArrayIndexValid method in ArrayUtils::get. (#552)

This commit is contained in:
Edgar Asatryan 2020-06-13 22:05:33 +04:00 committed by GitHub
parent 553a3a75df
commit 496eb10372
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 7 deletions

View File

@ -1679,13 +1679,7 @@ public class ArrayUtils {
* @since 3.11
*/
public static <T> T get(final T[] array, final int index, final T defaultValue) {
if (array == null) {
return defaultValue;
}
if (index >= 0 && index < array.length) {
return array[index];
}
return defaultValue;
return isArrayIndexValid(array, index) ? array[index] : defaultValue;
}
//-----------------------------------------------------------------------