Using ArrayUtils.isEmpty() when testing arrays.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137758 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6903e5e8aa
commit
a9d8e8770a
|
@ -82,7 +82,7 @@ import org.apache.commons.lang.builder.ToStringStyle;
|
||||||
* @author <a href="mailto:equinus100@hotmail.com">Ashwin S</a>
|
* @author <a href="mailto:equinus100@hotmail.com">Ashwin S</a>
|
||||||
* @author Fredrik Westermarck
|
* @author Fredrik Westermarck
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
* @version $Id: ArrayUtils.java,v 1.32 2004/01/19 21:50:06 fredrik Exp $
|
* @version $Id: ArrayUtils.java,v 1.33 2004/01/19 23:24:07 fredrik Exp $
|
||||||
*/
|
*/
|
||||||
public class ArrayUtils {
|
public class ArrayUtils {
|
||||||
|
|
||||||
|
@ -1765,7 +1765,7 @@ public class ArrayUtils {
|
||||||
* <code>-1</code> if not found or <code>null</code> array input
|
* <code>-1</code> if not found or <code>null</code> array input
|
||||||
*/
|
*/
|
||||||
public static int indexOf(final double[] array, final double valueToFind, int startIndex) {
|
public static int indexOf(final double[] array, final double valueToFind, int startIndex) {
|
||||||
if (array == null || array.length == 0) {
|
if (ArrayUtils.isEmpty(array)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (startIndex < 0) {
|
if (startIndex < 0) {
|
||||||
|
@ -1797,7 +1797,7 @@ public class ArrayUtils {
|
||||||
* <code>-1</code> if not found or <code>null</code> array input
|
* <code>-1</code> if not found or <code>null</code> array input
|
||||||
*/
|
*/
|
||||||
public static int indexOf(final double[] array, final double valueToFind, int startIndex, double tolerance) {
|
public static int indexOf(final double[] array, final double valueToFind, int startIndex, double tolerance) {
|
||||||
if (array == null || array.length == 0) {
|
if (ArrayUtils.isEmpty(array)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (startIndex < 0) {
|
if (startIndex < 0) {
|
||||||
|
@ -1859,7 +1859,7 @@ public class ArrayUtils {
|
||||||
* <code>-1</code> if not found or <code>null</code> array input
|
* <code>-1</code> if not found or <code>null</code> array input
|
||||||
*/
|
*/
|
||||||
public static int lastIndexOf(final double[] array, final double valueToFind, int startIndex) {
|
public static int lastIndexOf(final double[] array, final double valueToFind, int startIndex) {
|
||||||
if (array == null || array.length == 0) {
|
if (ArrayUtils.isEmpty(array)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (startIndex < 0) {
|
if (startIndex < 0) {
|
||||||
|
@ -1893,7 +1893,7 @@ public class ArrayUtils {
|
||||||
* <code>-1</code> if not found or <code>null</code> array input
|
* <code>-1</code> if not found or <code>null</code> array input
|
||||||
*/
|
*/
|
||||||
public static int lastIndexOf(final double[] array, final double valueToFind, int startIndex, double tolerance) {
|
public static int lastIndexOf(final double[] array, final double valueToFind, int startIndex, double tolerance) {
|
||||||
if (array == null || array.length == 0) {
|
if (ArrayUtils.isEmpty(array)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (startIndex < 0) {
|
if (startIndex < 0) {
|
||||||
|
@ -1972,7 +1972,7 @@ public class ArrayUtils {
|
||||||
* <code>-1</code> if not found or <code>null</code> array input
|
* <code>-1</code> if not found or <code>null</code> array input
|
||||||
*/
|
*/
|
||||||
public static int indexOf(final float[] array, final float valueToFind, int startIndex) {
|
public static int indexOf(final float[] array, final float valueToFind, int startIndex) {
|
||||||
if (array == null || array.length == 0) {
|
if (ArrayUtils.isEmpty(array)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (startIndex < 0) {
|
if (startIndex < 0) {
|
||||||
|
@ -2015,7 +2015,7 @@ public class ArrayUtils {
|
||||||
* <code>-1</code> if not found or <code>null</code> array input
|
* <code>-1</code> if not found or <code>null</code> array input
|
||||||
*/
|
*/
|
||||||
public static int lastIndexOf(final float[] array, final float valueToFind, int startIndex) {
|
public static int lastIndexOf(final float[] array, final float valueToFind, int startIndex) {
|
||||||
if (array == null || array.length == 0) {
|
if (ArrayUtils.isEmpty(array)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (startIndex < 0) {
|
if (startIndex < 0) {
|
||||||
|
@ -2075,7 +2075,7 @@ public class ArrayUtils {
|
||||||
* <code>-1</code> if not found or <code>null</code> array input
|
* <code>-1</code> if not found or <code>null</code> array input
|
||||||
*/
|
*/
|
||||||
public static int indexOf(final boolean[] array, final boolean valueToFind, int startIndex) {
|
public static int indexOf(final boolean[] array, final boolean valueToFind, int startIndex) {
|
||||||
if (array == null || array.length == 0) {
|
if (ArrayUtils.isEmpty(array)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (startIndex < 0) {
|
if (startIndex < 0) {
|
||||||
|
@ -2118,7 +2118,7 @@ public class ArrayUtils {
|
||||||
* <code>-1</code> if not found or <code>null</code> array input
|
* <code>-1</code> if not found or <code>null</code> array input
|
||||||
*/
|
*/
|
||||||
public static int lastIndexOf(final boolean[] array, final boolean valueToFind, int startIndex) {
|
public static int lastIndexOf(final boolean[] array, final boolean valueToFind, int startIndex) {
|
||||||
if (array == null || array.length == 0) {
|
if (ArrayUtils.isEmpty(array)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (startIndex < 0) {
|
if (startIndex < 0) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
* The Apache Software License, Version 1.1
|
* The Apache Software License, Version 1.1
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights
|
* Copyright (c) 2002-2004 The Apache Software Foundation. All rights
|
||||||
* reserved.
|
* reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -66,7 +66,7 @@ package org.apache.commons.lang;
|
||||||
* @author Phil Steitz
|
* @author Phil Steitz
|
||||||
* @author Gary Gregory
|
* @author Gary Gregory
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
* @version $Id: CharSetUtils.java,v 1.29 2003/11/04 21:16:34 fredrik Exp $
|
* @version $Id: CharSetUtils.java,v 1.30 2004/01/19 23:24:07 fredrik Exp $
|
||||||
*/
|
*/
|
||||||
public class CharSetUtils {
|
public class CharSetUtils {
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ public class CharSetUtils {
|
||||||
* @return modified String, <code>null</code> if null string input
|
* @return modified String, <code>null</code> if null string input
|
||||||
*/
|
*/
|
||||||
public static String squeeze(String str, String[] set) {
|
public static String squeeze(String str, String[] set) {
|
||||||
if (StringUtils.isEmpty(str) || set == null || set.length == 0) {
|
if (StringUtils.isEmpty(str) || ArrayUtils.isEmpty(set)) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
CharSet chars = evaluateSet(set);
|
CharSet chars = evaluateSet(set);
|
||||||
|
@ -220,7 +220,7 @@ public class CharSetUtils {
|
||||||
* @return character count, zero if null string input
|
* @return character count, zero if null string input
|
||||||
*/
|
*/
|
||||||
public static int count(String str, String[] set) {
|
public static int count(String str, String[] set) {
|
||||||
if (StringUtils.isEmpty(str) || set == null || set.length == 0) {
|
if (StringUtils.isEmpty(str) || ArrayUtils.isEmpty(set)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
CharSet chars = evaluateSet(set);
|
CharSet chars = evaluateSet(set);
|
||||||
|
@ -288,7 +288,7 @@ public class CharSetUtils {
|
||||||
if (str == null) {
|
if (str == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (str.length() == 0 || set == null || set.length == 0) {
|
if (str.length() == 0 || ArrayUtils.isEmpty(set)) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return modify(str, set, true);
|
return modify(str, set, true);
|
||||||
|
@ -339,7 +339,7 @@ public class CharSetUtils {
|
||||||
* @return modified String, <code>null</code> if null string input
|
* @return modified String, <code>null</code> if null string input
|
||||||
*/
|
*/
|
||||||
public static String delete(String str, String[] set) {
|
public static String delete(String str, String[] set) {
|
||||||
if (StringUtils.isEmpty(str) || set == null || set.length == 0) {
|
if (StringUtils.isEmpty(str) || ArrayUtils.isEmpty(set)) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
return modify(str, set, false);
|
return modify(str, set, false);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* ====================================================================
|
/* ====================================================================
|
||||||
* The Apache Software License, Version 1.1
|
* The Apache Software License, Version 1.1
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002-2003 The Apache Software Foundation. All rights
|
* Copyright (c) 2002-2004 The Apache Software Foundation. All rights
|
||||||
* reserved.
|
* reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
@ -72,7 +72,7 @@ import java.util.Map;
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
* @author Gary Gregory
|
* @author Gary Gregory
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
* @version $Id: Validate.java,v 1.6 2003/08/23 10:39:20 scolebourne Exp $
|
* @version $Id: Validate.java,v 1.7 2004/01/19 23:24:07 fredrik Exp $
|
||||||
*/
|
*/
|
||||||
public class Validate {
|
public class Validate {
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ public class Validate {
|
||||||
* @throws IllegalArgumentException if the array is empty
|
* @throws IllegalArgumentException if the array is empty
|
||||||
*/
|
*/
|
||||||
public static void notEmpty(Object[] array, String message) {
|
public static void notEmpty(Object[] array, String message) {
|
||||||
if (array == null || array.length == 0) {
|
if (ArrayUtils.isEmpty(array)) {
|
||||||
throw new IllegalArgumentException(message);
|
throw new IllegalArgumentException(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,7 +292,7 @@ public class Validate {
|
||||||
* @throws IllegalArgumentException if the array is empty
|
* @throws IllegalArgumentException if the array is empty
|
||||||
*/
|
*/
|
||||||
public static void notEmpty(Object[] array) {
|
public static void notEmpty(Object[] array) {
|
||||||
if (array == null || array.length == 0) {
|
if (ArrayUtils.isEmpty(array)) {
|
||||||
throw new IllegalArgumentException("The validated array is empty");
|
throw new IllegalArgumentException("The validated array is empty");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue