No need to nest in else.
This commit is contained in:
parent
a2b2b35ac3
commit
6b9964ff4b
|
@ -820,7 +820,8 @@ public class ArrayUtils {
|
|||
public static boolean[] addAll(final boolean[] array1, final boolean... array2) {
|
||||
if (array1 == null) {
|
||||
return clone(array2);
|
||||
} else if (array2 == null) {
|
||||
}
|
||||
if (array2 == null) {
|
||||
return clone(array1);
|
||||
}
|
||||
final boolean[] joinedArray = new boolean[array1.length + array2.length];
|
||||
|
@ -849,7 +850,8 @@ public class ArrayUtils {
|
|||
public static byte[] addAll(final byte[] array1, final byte... array2) {
|
||||
if (array1 == null) {
|
||||
return clone(array2);
|
||||
} else if (array2 == null) {
|
||||
}
|
||||
if (array2 == null) {
|
||||
return clone(array1);
|
||||
}
|
||||
final byte[] joinedArray = new byte[array1.length + array2.length];
|
||||
|
@ -878,7 +880,8 @@ public class ArrayUtils {
|
|||
public static char[] addAll(final char[] array1, final char... array2) {
|
||||
if (array1 == null) {
|
||||
return clone(array2);
|
||||
} else if (array2 == null) {
|
||||
}
|
||||
if (array2 == null) {
|
||||
return clone(array1);
|
||||
}
|
||||
final char[] joinedArray = new char[array1.length + array2.length];
|
||||
|
@ -907,7 +910,8 @@ public class ArrayUtils {
|
|||
public static double[] addAll(final double[] array1, final double... array2) {
|
||||
if (array1 == null) {
|
||||
return clone(array2);
|
||||
} else if (array2 == null) {
|
||||
}
|
||||
if (array2 == null) {
|
||||
return clone(array1);
|
||||
}
|
||||
final double[] joinedArray = new double[array1.length + array2.length];
|
||||
|
@ -936,7 +940,8 @@ public class ArrayUtils {
|
|||
public static float[] addAll(final float[] array1, final float... array2) {
|
||||
if (array1 == null) {
|
||||
return clone(array2);
|
||||
} else if (array2 == null) {
|
||||
}
|
||||
if (array2 == null) {
|
||||
return clone(array1);
|
||||
}
|
||||
final float[] joinedArray = new float[array1.length + array2.length];
|
||||
|
@ -965,7 +970,8 @@ public class ArrayUtils {
|
|||
public static int[] addAll(final int[] array1, final int... array2) {
|
||||
if (array1 == null) {
|
||||
return clone(array2);
|
||||
} else if (array2 == null) {
|
||||
}
|
||||
if (array2 == null) {
|
||||
return clone(array1);
|
||||
}
|
||||
final int[] joinedArray = new int[array1.length + array2.length];
|
||||
|
@ -994,7 +1000,8 @@ public class ArrayUtils {
|
|||
public static long[] addAll(final long[] array1, final long... array2) {
|
||||
if (array1 == null) {
|
||||
return clone(array2);
|
||||
} else if (array2 == null) {
|
||||
}
|
||||
if (array2 == null) {
|
||||
return clone(array1);
|
||||
}
|
||||
final long[] joinedArray = new long[array1.length + array2.length];
|
||||
|
@ -1023,7 +1030,8 @@ public class ArrayUtils {
|
|||
public static short[] addAll(final short[] array1, final short... array2) {
|
||||
if (array1 == null) {
|
||||
return clone(array2);
|
||||
} else if (array2 == null) {
|
||||
}
|
||||
if (array2 == null) {
|
||||
return clone(array1);
|
||||
}
|
||||
final short[] joinedArray = new short[array1.length + array2.length];
|
||||
|
@ -1059,7 +1067,8 @@ public class ArrayUtils {
|
|||
public static <T> T[] addAll(final T[] array1, @SuppressWarnings("unchecked") final T... array2) {
|
||||
if (array1 == null) {
|
||||
return clone(array2);
|
||||
} else if (array2 == null) {
|
||||
}
|
||||
if (array2 == null) {
|
||||
return clone(array1);
|
||||
}
|
||||
final Class<?> type1 = array1.getClass().getComponentType();
|
||||
|
@ -3781,7 +3790,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
}
|
||||
if (startIndex < 0) {
|
||||
return INDEX_NOT_FOUND;
|
||||
} else if (startIndex >= array.length) {
|
||||
}
|
||||
if (startIndex >= array.length) {
|
||||
startIndex = array.length - 1;
|
||||
}
|
||||
for (int i = startIndex; i >= 0; i--) {
|
||||
|
@ -3826,7 +3836,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
}
|
||||
if (startIndex < 0) {
|
||||
return INDEX_NOT_FOUND;
|
||||
} else if (startIndex >= array.length) {
|
||||
}
|
||||
if (startIndex >= array.length) {
|
||||
startIndex = array.length - 1;
|
||||
}
|
||||
for (int i = startIndex; i >= 0; i--) {
|
||||
|
@ -3873,7 +3884,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
}
|
||||
if (startIndex < 0) {
|
||||
return INDEX_NOT_FOUND;
|
||||
} else if (startIndex >= array.length) {
|
||||
}
|
||||
if (startIndex >= array.length) {
|
||||
startIndex = array.length - 1;
|
||||
}
|
||||
for (int i = startIndex; i >= 0; i--) {
|
||||
|
@ -3935,7 +3947,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
}
|
||||
if (startIndex < 0) {
|
||||
return INDEX_NOT_FOUND;
|
||||
} else if (startIndex >= array.length) {
|
||||
}
|
||||
if (startIndex >= array.length) {
|
||||
startIndex = array.length - 1;
|
||||
}
|
||||
for (int i = startIndex; i >= 0; i--) {
|
||||
|
@ -3969,7 +3982,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
}
|
||||
if (startIndex < 0) {
|
||||
return INDEX_NOT_FOUND;
|
||||
} else if (startIndex >= array.length) {
|
||||
}
|
||||
if (startIndex >= array.length) {
|
||||
startIndex = array.length - 1;
|
||||
}
|
||||
final double min = valueToFind - tolerance;
|
||||
|
@ -4017,7 +4031,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
}
|
||||
if (startIndex < 0) {
|
||||
return INDEX_NOT_FOUND;
|
||||
} else if (startIndex >= array.length) {
|
||||
}
|
||||
if (startIndex >= array.length) {
|
||||
startIndex = array.length - 1;
|
||||
}
|
||||
for (int i = startIndex; i >= 0; i--) {
|
||||
|
@ -4062,7 +4077,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
}
|
||||
if (startIndex < 0) {
|
||||
return INDEX_NOT_FOUND;
|
||||
} else if (startIndex >= array.length) {
|
||||
}
|
||||
if (startIndex >= array.length) {
|
||||
startIndex = array.length - 1;
|
||||
}
|
||||
for (int i = startIndex; i >= 0; i--) {
|
||||
|
@ -4107,7 +4123,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
}
|
||||
if (startIndex < 0) {
|
||||
return INDEX_NOT_FOUND;
|
||||
} else if (startIndex >= array.length) {
|
||||
}
|
||||
if (startIndex >= array.length) {
|
||||
startIndex = array.length - 1;
|
||||
}
|
||||
for (int i = startIndex; i >= 0; i--) {
|
||||
|
@ -4152,7 +4169,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
}
|
||||
if (startIndex < 0) {
|
||||
return INDEX_NOT_FOUND;
|
||||
} else if (startIndex >= array.length) {
|
||||
}
|
||||
if (startIndex >= array.length) {
|
||||
startIndex = array.length - 1;
|
||||
}
|
||||
if (objectToFind == null) {
|
||||
|
@ -4205,7 +4223,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
}
|
||||
if (startIndex < 0) {
|
||||
return INDEX_NOT_FOUND;
|
||||
} else if (startIndex >= array.length) {
|
||||
}
|
||||
if (startIndex >= array.length) {
|
||||
startIndex = array.length - 1;
|
||||
}
|
||||
for (int i = startIndex; i >= 0; i--) {
|
||||
|
@ -8978,7 +8997,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static Boolean[] toObject(final boolean[] array) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_BOOLEAN_OBJECT_ARRAY;
|
||||
}
|
||||
final Boolean[] result = new Boolean[array.length];
|
||||
|
@ -8999,7 +9019,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static Byte[] toObject(final byte[] array) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_BYTE_OBJECT_ARRAY;
|
||||
}
|
||||
final Byte[] result = new Byte[array.length];
|
||||
|
@ -9020,7 +9041,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static Character[] toObject(final char[] array) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_CHARACTER_OBJECT_ARRAY;
|
||||
}
|
||||
final Character[] result = new Character[array.length];
|
||||
|
@ -9041,7 +9063,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static Double[] toObject(final double[] array) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_DOUBLE_OBJECT_ARRAY;
|
||||
}
|
||||
final Double[] result = new Double[array.length];
|
||||
|
@ -9062,7 +9085,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static Float[] toObject(final float[] array) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_FLOAT_OBJECT_ARRAY;
|
||||
}
|
||||
final Float[] result = new Float[array.length];
|
||||
|
@ -9083,7 +9107,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static Integer[] toObject(final int[] array) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_INTEGER_OBJECT_ARRAY;
|
||||
}
|
||||
final Integer[] result = new Integer[array.length];
|
||||
|
@ -9104,7 +9129,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static Long[] toObject(final long[] array) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_LONG_OBJECT_ARRAY;
|
||||
}
|
||||
final Long[] result = new Long[array.length];
|
||||
|
@ -9125,7 +9151,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static Short[] toObject(final short[] array) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_SHORT_OBJECT_ARRAY;
|
||||
}
|
||||
final Short[] result = new Short[array.length];
|
||||
|
@ -9149,7 +9176,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static boolean[] toPrimitive(final Boolean[] array) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_BOOLEAN_ARRAY;
|
||||
}
|
||||
final boolean[] result = new boolean[array.length];
|
||||
|
@ -9171,7 +9199,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static boolean[] toPrimitive(final Boolean[] array, final boolean valueForNull) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_BOOLEAN_ARRAY;
|
||||
}
|
||||
final boolean[] result = new boolean[array.length];
|
||||
|
@ -9196,7 +9225,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static byte[] toPrimitive(final Byte[] array) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_BYTE_ARRAY;
|
||||
}
|
||||
final byte[] result = new byte[array.length];
|
||||
|
@ -9218,7 +9248,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static byte[] toPrimitive(final Byte[] array, final byte valueForNull) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_BYTE_ARRAY;
|
||||
}
|
||||
final byte[] result = new byte[array.length];
|
||||
|
@ -9243,7 +9274,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static char[] toPrimitive(final Character[] array) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_CHAR_ARRAY;
|
||||
}
|
||||
final char[] result = new char[array.length];
|
||||
|
@ -9265,7 +9297,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static char[] toPrimitive(final Character[] array, final char valueForNull) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_CHAR_ARRAY;
|
||||
}
|
||||
final char[] result = new char[array.length];
|
||||
|
@ -9290,7 +9323,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static double[] toPrimitive(final Double[] array) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_DOUBLE_ARRAY;
|
||||
}
|
||||
final double[] result = new double[array.length];
|
||||
|
@ -9312,7 +9346,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static double[] toPrimitive(final Double[] array, final double valueForNull) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_DOUBLE_ARRAY;
|
||||
}
|
||||
final double[] result = new double[array.length];
|
||||
|
@ -9337,7 +9372,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static float[] toPrimitive(final Float[] array) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_FLOAT_ARRAY;
|
||||
}
|
||||
final float[] result = new float[array.length];
|
||||
|
@ -9359,7 +9395,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static float[] toPrimitive(final Float[] array, final float valueForNull) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_FLOAT_ARRAY;
|
||||
}
|
||||
final float[] result = new float[array.length];
|
||||
|
@ -9384,7 +9421,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static int[] toPrimitive(final Integer[] array) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_INT_ARRAY;
|
||||
}
|
||||
final int[] result = new int[array.length];
|
||||
|
@ -9406,7 +9444,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static int[] toPrimitive(final Integer[] array, final int valueForNull) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_INT_ARRAY;
|
||||
}
|
||||
final int[] result = new int[array.length];
|
||||
|
@ -9431,7 +9470,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static long[] toPrimitive(final Long[] array) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_LONG_ARRAY;
|
||||
}
|
||||
final long[] result = new long[array.length];
|
||||
|
@ -9453,7 +9493,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static long[] toPrimitive(final Long[] array, final long valueForNull) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_LONG_ARRAY;
|
||||
}
|
||||
final long[] result = new long[array.length];
|
||||
|
@ -9520,7 +9561,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static short[] toPrimitive(final Short[] array) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_SHORT_ARRAY;
|
||||
}
|
||||
final short[] result = new short[array.length];
|
||||
|
@ -9542,7 +9584,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static short[] toPrimitive(final Short[] array, final short valueForNull) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_SHORT_ARRAY;
|
||||
}
|
||||
final short[] result = new short[array.length];
|
||||
|
@ -9603,7 +9646,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static String[] toStringArray(final Object[] array) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_STRING_ARRAY;
|
||||
}
|
||||
|
||||
|
@ -9629,7 +9673,8 @@ public static int indexOf(final int[] array, final int valueToFind, int startInd
|
|||
public static String[] toStringArray(final Object[] array, final String valueForNullElements) {
|
||||
if (null == array) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return EMPTY_STRING_ARRAY;
|
||||
}
|
||||
|
||||
|
|
|
@ -466,12 +466,15 @@ public class BooleanUtils {
|
|||
public static boolean toBoolean(final String str, final String trueString, final String falseString) {
|
||||
if (str == trueString) {
|
||||
return true;
|
||||
} else if (str == falseString) {
|
||||
}
|
||||
if (str == falseString) {
|
||||
return false;
|
||||
} else if (str != null) {
|
||||
}
|
||||
if (str != null) {
|
||||
if (str.equals(trueString)) {
|
||||
return true;
|
||||
} else if (str.equals(falseString)) {
|
||||
}
|
||||
if (str.equals(falseString)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,9 +52,11 @@ public class CharSequenceUtils {
|
|||
static int indexOf(final CharSequence cs, final CharSequence searchChar, final int start) {
|
||||
if (cs instanceof String) {
|
||||
return ((String) cs).indexOf(searchChar.toString(), start);
|
||||
} else if (cs instanceof StringBuilder) {
|
||||
}
|
||||
if (cs instanceof StringBuilder) {
|
||||
return ((StringBuilder) cs).indexOf(searchChar.toString(), start);
|
||||
} else if (cs instanceof StringBuffer) {
|
||||
}
|
||||
if (cs instanceof StringBuffer) {
|
||||
return ((StringBuffer) cs).indexOf(searchChar.toString(), start);
|
||||
}
|
||||
return cs.toString().indexOf(searchChar.toString(), start);
|
||||
|
@ -152,9 +154,11 @@ public class CharSequenceUtils {
|
|||
if (searchChar instanceof String) {
|
||||
if (cs instanceof String) {
|
||||
return ((String) cs).lastIndexOf((String) searchChar, start);
|
||||
} else if (cs instanceof StringBuilder) {
|
||||
}
|
||||
if (cs instanceof StringBuilder) {
|
||||
return ((StringBuilder) cs).lastIndexOf((String) searchChar, start);
|
||||
} else if (cs instanceof StringBuffer) {
|
||||
}
|
||||
if (cs instanceof StringBuffer) {
|
||||
return ((StringBuffer) cs).lastIndexOf((String) searchChar, start);
|
||||
}
|
||||
}
|
||||
|
@ -177,9 +181,11 @@ public class CharSequenceUtils {
|
|||
if (len2 <= TO_STRING_LIMIT) {
|
||||
if (cs instanceof String) {
|
||||
return ((String) cs).lastIndexOf(searchChar.toString(), start);
|
||||
} else if (cs instanceof StringBuilder) {
|
||||
}
|
||||
if (cs instanceof StringBuilder) {
|
||||
return ((StringBuilder) cs).lastIndexOf(searchChar.toString(), start);
|
||||
} else if (cs instanceof StringBuffer) {
|
||||
}
|
||||
if (cs instanceof StringBuffer) {
|
||||
return ((StringBuffer) cs).lastIndexOf(searchChar.toString(), start);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1228,7 +1228,8 @@ public class ClassUtils {
|
|||
public static Class<?>[] toClass(final Object... array) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else if (array.length == 0) {
|
||||
}
|
||||
if (array.length == 0) {
|
||||
return ArrayUtils.EMPTY_CLASS_ARRAY;
|
||||
}
|
||||
final Class<?>[] classes = new Class[array.length];
|
||||
|
|
|
@ -523,13 +523,14 @@ public class Functions {
|
|||
Objects.requireNonNull(throwable, "throwable");
|
||||
if (throwable instanceof RuntimeException) {
|
||||
throw (RuntimeException) throwable;
|
||||
} else if (throwable instanceof Error) {
|
||||
throw (Error) throwable;
|
||||
} else if (throwable instanceof IOException) {
|
||||
throw new UncheckedIOException((IOException) throwable);
|
||||
} else {
|
||||
throw new UndeclaredThrowableException(throwable);
|
||||
}
|
||||
if (throwable instanceof Error) {
|
||||
throw (Error) throwable;
|
||||
}
|
||||
if (throwable instanceof IOException) {
|
||||
throw new UncheckedIOException((IOException) throwable);
|
||||
}
|
||||
throw new UndeclaredThrowableException(throwable);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -311,14 +311,13 @@ public enum JavaVersion {
|
|||
*/
|
||||
private static float toFloatVersion(final String value) {
|
||||
final int defaultReturnValue = -1;
|
||||
if (value.contains(".")) {
|
||||
final String[] toParse = value.split("\\.");
|
||||
if (toParse.length >= 2) {
|
||||
return NumberUtils.toFloat(toParse[0] + '.' + toParse[1], defaultReturnValue);
|
||||
}
|
||||
} else {
|
||||
if (!value.contains(".")) {
|
||||
return NumberUtils.toFloat(value, defaultReturnValue);
|
||||
}
|
||||
final String[] toParse = value.split("\\.");
|
||||
if (toParse.length >= 2) {
|
||||
return NumberUtils.toFloat(toParse[0] + '.' + toParse[1], defaultReturnValue);
|
||||
}
|
||||
return defaultReturnValue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -329,9 +329,11 @@ public class ObjectUtils {
|
|||
public static <T extends Comparable<? super T>> int compare(final T c1, final T c2, final boolean nullGreater) {
|
||||
if (c1 == c2) {
|
||||
return 0;
|
||||
} else if (c1 == null) {
|
||||
}
|
||||
if (c1 == null) {
|
||||
return nullGreater ? 1 : -1;
|
||||
} else if (c2 == null) {
|
||||
}
|
||||
if (c2 == null) {
|
||||
return nullGreater ? -1 : 1;
|
||||
}
|
||||
return c1.compareTo(c2);
|
||||
|
|
|
@ -362,7 +362,8 @@ public class RandomStringUtils {
|
|||
final char[] chars, final Random random) {
|
||||
if (count == 0) {
|
||||
return StringUtils.EMPTY;
|
||||
} else if (count < 0) {
|
||||
}
|
||||
if (count < 0) {
|
||||
throw new IllegalArgumentException("Requested random string length " + count + " is less than 0.");
|
||||
}
|
||||
if (chars != null && chars.length == 0) {
|
||||
|
|
|
@ -226,11 +226,11 @@ public final class Range<T> implements Serializable {
|
|||
Validate.notNull(element, "element");
|
||||
if (isAfter(element)) {
|
||||
return -1;
|
||||
} else if (isBefore(element)) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
if (isBefore(element)) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Element tests
|
||||
|
@ -249,15 +249,15 @@ public final class Range<T> implements Serializable {
|
|||
public boolean equals(final Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
} else if (obj == null || obj.getClass() != getClass()) {
|
||||
return false;
|
||||
} else {
|
||||
@SuppressWarnings("unchecked") // OK because we checked the class above
|
||||
final
|
||||
Range<T> range = (Range<T>) obj;
|
||||
return minimum.equals(range.minimum) &&
|
||||
maximum.equals(range.maximum);
|
||||
}
|
||||
if (obj == null || obj.getClass() != getClass()) {
|
||||
return false;
|
||||
}
|
||||
@SuppressWarnings("unchecked") // OK because we checked the class above
|
||||
final
|
||||
Range<T> range = (Range<T>) obj;
|
||||
return minimum.equals(range.minimum) &&
|
||||
maximum.equals(range.maximum);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -471,11 +471,11 @@ public final class Range<T> implements Serializable {
|
|||
Validate.notNull(element, "element");
|
||||
if (isAfter(element)) {
|
||||
return minimum;
|
||||
} else if (isBefore(element)) {
|
||||
return maximum;
|
||||
} else {
|
||||
return element;
|
||||
}
|
||||
if (isBefore(element)) {
|
||||
return maximum;
|
||||
}
|
||||
return element;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -340,7 +340,8 @@ public class StringUtils {
|
|||
public static String abbreviate(final String str, final String abbrevMarker, int offset, final int maxWidth) {
|
||||
if (isNotEmpty(str) && EMPTY.equals(abbrevMarker) && maxWidth > 0) {
|
||||
return substring(str, 0, maxWidth);
|
||||
} else if (isAnyEmpty(str, abbrevMarker)) {
|
||||
}
|
||||
if (isAnyEmpty(str, abbrevMarker)) {
|
||||
return str;
|
||||
}
|
||||
final int abbrevMarkerLength = abbrevMarker.length();
|
||||
|
@ -1061,18 +1062,17 @@ public class StringUtils {
|
|||
final char ch = cs.charAt(i);
|
||||
for (int j = 0; j < searchLength; j++) {
|
||||
if (searchChars[j] == ch) {
|
||||
if (Character.isHighSurrogate(ch)) {
|
||||
if (j == searchLast) {
|
||||
// missing low surrogate, fine, like String.indexOf(String)
|
||||
return true;
|
||||
}
|
||||
if (i < csLast && searchChars[j + 1] == cs.charAt(i + 1)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (!Character.isHighSurrogate(ch)) {
|
||||
// ch is in the Basic Multilingual Plane
|
||||
return true;
|
||||
}
|
||||
if (j == searchLast) {
|
||||
// missing low surrogate, fine, like String.indexOf(String)
|
||||
return true;
|
||||
}
|
||||
if (i < csLast && searchChars[j + 1] == cs.charAt(i + 1)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1283,18 +1283,17 @@ public class StringUtils {
|
|||
final char ch = cs.charAt(i);
|
||||
for (int j = 0; j < searchLen; j++) {
|
||||
if (searchChars[j] == ch) {
|
||||
if (Character.isHighSurrogate(ch)) {
|
||||
if (j == searchLast) {
|
||||
// missing low surrogate, fine, like String.indexOf(String)
|
||||
return false;
|
||||
}
|
||||
if (i < csLast && searchChars[j + 1] == cs.charAt(i + 1)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (!Character.isHighSurrogate(ch)) {
|
||||
// ch is in the Basic Multilingual Plane
|
||||
return false;
|
||||
}
|
||||
if (j == searchLast) {
|
||||
// missing low surrogate, fine, like String.indexOf(String)
|
||||
return false;
|
||||
}
|
||||
if (i < csLast && searchChars[j + 1] == cs.charAt(i + 1)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2055,13 +2054,13 @@ public class StringUtils {
|
|||
return EMPTY;
|
||||
}
|
||||
return strs[0];
|
||||
} else if (smallestIndexOfDiff == 0) {
|
||||
}
|
||||
if (smallestIndexOfDiff == 0) {
|
||||
// there were no common initial characters
|
||||
return EMPTY;
|
||||
} else {
|
||||
// we found a common initial character sequence
|
||||
return strs[0].substring(0, smallestIndexOfDiff);
|
||||
}
|
||||
// we found a common initial character sequence
|
||||
return strs[0].substring(0, smallestIndexOfDiff);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2134,7 +2133,8 @@ public class StringUtils {
|
|||
public static int getFuzzyDistance(final CharSequence term, final CharSequence query, final Locale locale) {
|
||||
if (term == null || query == null) {
|
||||
throw new IllegalArgumentException("Strings must not be null");
|
||||
} else if (locale == null) {
|
||||
}
|
||||
if (locale == null) {
|
||||
throw new IllegalArgumentException("Locale must not be null");
|
||||
}
|
||||
|
||||
|
@ -2340,7 +2340,8 @@ public class StringUtils {
|
|||
|
||||
if (n == 0) {
|
||||
return m;
|
||||
} else if (m == 0) {
|
||||
}
|
||||
if (m == 0) {
|
||||
return n;
|
||||
}
|
||||
|
||||
|
@ -2478,9 +2479,11 @@ public class StringUtils {
|
|||
// if one string is empty, the edit distance is necessarily the length of the other
|
||||
if (n == 0) {
|
||||
return m <= threshold ? m : -1;
|
||||
} else if (m == 0) {
|
||||
}
|
||||
if (m == 0) {
|
||||
return n <= threshold ? n : -1;
|
||||
} else if (Math.abs(n - m) > threshold) {
|
||||
}
|
||||
if (Math.abs(n - m) > threshold) {
|
||||
// no need to calculate the distance if the length difference is greater than the threshold
|
||||
return -1;
|
||||
}
|
||||
|
@ -2762,12 +2765,11 @@ public class StringUtils {
|
|||
final char ch = cs.charAt(i);
|
||||
for (int j = 0; j < searchLen; j++) {
|
||||
if (searchChars[j] == ch) {
|
||||
if (i < csLast && j < searchLast && Character.isHighSurrogate(ch)) {
|
||||
// ch is a supplementary character
|
||||
if (searchChars[j + 1] == cs.charAt(i + 1)) {
|
||||
return i;
|
||||
}
|
||||
} else {
|
||||
if ((i >= csLast) || (j >= searchLast) || !Character.isHighSurrogate(ch)) {
|
||||
return i;
|
||||
}
|
||||
// ch is a supplementary character
|
||||
if (searchChars[j + 1] == cs.charAt(i + 1)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
@ -2896,11 +2898,10 @@ public class StringUtils {
|
|||
final char ch = cs.charAt(i);
|
||||
for (int j = 0; j < searchLen; j++) {
|
||||
if (searchChars[j] == ch) {
|
||||
if (i < csLast && j < searchLast && Character.isHighSurrogate(ch)) {
|
||||
if (searchChars[j + 1] == cs.charAt(i + 1)) {
|
||||
continue outer;
|
||||
}
|
||||
} else {
|
||||
if ((i >= csLast) || (j >= searchLast) || !Character.isHighSurrogate(ch)) {
|
||||
continue outer;
|
||||
}
|
||||
if (searchChars[j + 1] == cs.charAt(i + 1)) {
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
|
@ -3636,7 +3637,8 @@ public class StringUtils {
|
|||
for (int i = 0; i < sz; i++) {
|
||||
if (containsUppercase && containsLowercase) {
|
||||
return true;
|
||||
} else if (Character.isUpperCase(cs.charAt(i))) {
|
||||
}
|
||||
if (Character.isUpperCase(cs.charAt(i))) {
|
||||
containsUppercase = true;
|
||||
} else if (Character.isLowerCase(cs.charAt(i))) {
|
||||
containsLowercase = true;
|
||||
|
@ -5344,16 +5346,16 @@ public class StringUtils {
|
|||
|
||||
if (pads == padLen) {
|
||||
return padStr.concat(str);
|
||||
} else if (pads < padLen) {
|
||||
return padStr.substring(0, pads).concat(str);
|
||||
} else {
|
||||
final char[] padding = new char[pads];
|
||||
final char[] padChars = padStr.toCharArray();
|
||||
for (int i = 0; i < pads; i++) {
|
||||
padding[i] = padChars[i % padLen];
|
||||
}
|
||||
return new String(padding).concat(str);
|
||||
}
|
||||
if (pads < padLen) {
|
||||
return padStr.substring(0, pads).concat(str);
|
||||
}
|
||||
final char[] padding = new char[pads];
|
||||
final char[] padChars = padStr.toCharArray();
|
||||
for (int i = 0; i < pads; i++) {
|
||||
padding[i] = padChars[i % padLen];
|
||||
}
|
||||
return new String(padding).concat(str);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5468,11 +5470,10 @@ public class StringUtils {
|
|||
}
|
||||
int prefix = 0;
|
||||
for (int mi = 0; mi < min.length(); mi++) {
|
||||
if (first.charAt(mi) == second.charAt(mi)) {
|
||||
prefix++;
|
||||
} else {
|
||||
if (first.charAt(mi) != second.charAt(mi)) {
|
||||
break;
|
||||
}
|
||||
prefix++;
|
||||
}
|
||||
return new int[] { matches, transpositions / 2, prefix, max.length() };
|
||||
}
|
||||
|
@ -7269,16 +7270,16 @@ public class StringUtils {
|
|||
|
||||
if (pads == padLen) {
|
||||
return str.concat(padStr);
|
||||
} else if (pads < padLen) {
|
||||
return str.concat(padStr.substring(0, pads));
|
||||
} else {
|
||||
final char[] padding = new char[pads];
|
||||
final char[] padChars = padStr.toCharArray();
|
||||
for (int i = 0; i < pads; i++) {
|
||||
padding[i] = padChars[i % padLen];
|
||||
}
|
||||
return str.concat(new String(padding));
|
||||
}
|
||||
if (pads < padLen) {
|
||||
return str.concat(padStr.substring(0, pads));
|
||||
}
|
||||
final char[] padding = new char[pads];
|
||||
final char[] padChars = padStr.toCharArray();
|
||||
for (int i = 0; i < pads; i++) {
|
||||
padding[i] = padChars[i % padLen];
|
||||
}
|
||||
return str.concat(new String(padding));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -150,10 +150,10 @@ public class Memoizer<I, O> implements Computable<I, O> {
|
|||
private RuntimeException launderException(final Throwable throwable) {
|
||||
if (throwable instanceof RuntimeException) {
|
||||
return (RuntimeException) throwable;
|
||||
} else if (throwable instanceof Error) {
|
||||
throw (Error) throwable;
|
||||
} else {
|
||||
throw new IllegalStateException("Unchecked exception", throwable);
|
||||
}
|
||||
if (throwable instanceof Error) {
|
||||
throw (Error) throwable;
|
||||
}
|
||||
throw new IllegalStateException("Unchecked exception", throwable);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -410,13 +410,14 @@ public class Failable {
|
|||
Objects.requireNonNull(throwable, "throwable");
|
||||
if (throwable instanceof RuntimeException) {
|
||||
throw (RuntimeException) throwable;
|
||||
} else if (throwable instanceof Error) {
|
||||
throw (Error) throwable;
|
||||
} else if (throwable instanceof IOException) {
|
||||
throw new UncheckedIOException((IOException) throwable);
|
||||
} else {
|
||||
throw new UndeclaredThrowableException(throwable);
|
||||
}
|
||||
if (throwable instanceof Error) {
|
||||
throw (Error) throwable;
|
||||
}
|
||||
if (throwable instanceof IOException) {
|
||||
throw new UncheckedIOException((IOException) throwable);
|
||||
}
|
||||
throw new UndeclaredThrowableException(throwable);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -535,20 +535,21 @@ public final class Fraction extends Number implements Comparable<Fraction> {
|
|||
public Fraction pow(final int power) {
|
||||
if (power == 1) {
|
||||
return this;
|
||||
} else if (power == 0) {
|
||||
}
|
||||
if (power == 0) {
|
||||
return ONE;
|
||||
} else if (power < 0) {
|
||||
}
|
||||
if (power < 0) {
|
||||
if (power == Integer.MIN_VALUE) { // MIN_VALUE can't be negated.
|
||||
return this.invert().pow(2).pow(-(power / 2));
|
||||
}
|
||||
return this.invert().pow(-power);
|
||||
} else {
|
||||
final Fraction f = this.multiplyBy(this);
|
||||
if (power % 2 == 0) { // if even...
|
||||
return f.pow(power / 2);
|
||||
}
|
||||
return f.pow(power / 2).multiplyBy(this);
|
||||
}
|
||||
final Fraction f = this.multiplyBy(this);
|
||||
if (power % 2 == 0) { // if even...
|
||||
return f.pow(power / 2);
|
||||
}
|
||||
return f.pow(power / 2).multiplyBy(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -97,12 +97,11 @@ public class IEEE754rUtils {
|
|||
public static double min(final double a, final double b) {
|
||||
if (Double.isNaN(a)) {
|
||||
return b;
|
||||
} else
|
||||
}
|
||||
if (Double.isNaN(b)) {
|
||||
return a;
|
||||
} else {
|
||||
return Math.min(a, b);
|
||||
}
|
||||
return Math.min(a, b);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -131,12 +130,11 @@ public class IEEE754rUtils {
|
|||
public static float min(final float a, final float b) {
|
||||
if (Float.isNaN(a)) {
|
||||
return b;
|
||||
} else
|
||||
}
|
||||
if (Float.isNaN(b)) {
|
||||
return a;
|
||||
} else {
|
||||
return Math.min(a, b);
|
||||
}
|
||||
return Math.min(a, b);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -209,12 +207,11 @@ public class IEEE754rUtils {
|
|||
public static double max(final double a, final double b) {
|
||||
if (Double.isNaN(a)) {
|
||||
return b;
|
||||
} else
|
||||
}
|
||||
if (Double.isNaN(b)) {
|
||||
return a;
|
||||
} else {
|
||||
return Math.max(a, b);
|
||||
}
|
||||
return Math.max(a, b);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -243,12 +240,11 @@ public class IEEE754rUtils {
|
|||
public static float max(final float a, final float b) {
|
||||
if (Float.isNaN(a)) {
|
||||
return b;
|
||||
} else
|
||||
}
|
||||
if (Float.isNaN(b)) {
|
||||
return a;
|
||||
} else {
|
||||
return Math.max(a, b);
|
||||
}
|
||||
return Math.max(a, b);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -682,11 +682,10 @@ public class NumberUtils {
|
|||
char firstSigDigit = 0; // strip leading zeroes
|
||||
for (int i = pfxLen; i < length; i++) {
|
||||
firstSigDigit = str.charAt(i);
|
||||
if (firstSigDigit == '0') { // count leading zeroes
|
||||
pfxLen++;
|
||||
} else {
|
||||
if (firstSigDigit != '0') {
|
||||
break;
|
||||
}
|
||||
pfxLen++;
|
||||
}
|
||||
final int hexDigits = length - pfxLen;
|
||||
if (hexDigits > 16 || hexDigits == 16 && firstSigDigit > '7') { // too many for Long
|
||||
|
@ -1656,16 +1655,17 @@ public class NumberUtils {
|
|||
}
|
||||
}
|
||||
return true;
|
||||
} else if (Character.isDigit(chars[start + 1])) {
|
||||
// leading 0, but not hex, must be octal
|
||||
int i = start + 1;
|
||||
for (; i < chars.length; i++) {
|
||||
if (chars[i] < '0' || chars[i] > '7') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (Character.isDigit(chars[start + 1])) {
|
||||
// leading 0, but not hex, must be octal
|
||||
int i = start + 1;
|
||||
for (; i < chars.length; i++) {
|
||||
if (chars[i] < '0' || chars[i] > '7') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
sz--; // don't want to loop to the last char, check it afterwords
|
||||
// for type qualifiers
|
||||
|
|
|
@ -108,11 +108,10 @@ public class FieldUtils {
|
|||
// getDeclaredField checks for non-public scopes as well
|
||||
// and it returns accurate results
|
||||
if (!Modifier.isPublic(field.getModifiers())) {
|
||||
if (forceAccess) {
|
||||
field.setAccessible(true);
|
||||
} else {
|
||||
if (!forceAccess) {
|
||||
continue;
|
||||
}
|
||||
field.setAccessible(true);
|
||||
}
|
||||
return field;
|
||||
} catch (final NoSuchFieldException ex) { // NOPMD
|
||||
|
@ -174,11 +173,10 @@ public class FieldUtils {
|
|||
// only consider the specified class by using getDeclaredField()
|
||||
final Field field = cls.getDeclaredField(fieldName);
|
||||
if (!MemberUtils.isAccessible(field)) {
|
||||
if (forceAccess) {
|
||||
field.setAccessible(true);
|
||||
} else {
|
||||
if (!forceAccess) {
|
||||
return null;
|
||||
}
|
||||
field.setAccessible(true);
|
||||
}
|
||||
return field;
|
||||
} catch (final NoSuchFieldException e) { // NOPMD
|
||||
|
|
|
@ -807,7 +807,8 @@ public class MethodUtils {
|
|||
final Class<?> toClass = toClassArray[offset];
|
||||
if (aClass == null || aClass.equals(toClass)) {
|
||||
continue;
|
||||
} else if (ClassUtils.isAssignable(aClass, toClass, true)
|
||||
}
|
||||
if (ClassUtils.isAssignable(aClass, toClass, true)
|
||||
&& !ClassUtils.isAssignable(aClass, toClass, false)) {
|
||||
answer++;
|
||||
} else {
|
||||
|
|
|
@ -2312,11 +2312,11 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
|
|||
public String leftString(final int length) {
|
||||
if (length <= 0) {
|
||||
return StringUtils.EMPTY;
|
||||
} else if (length >= size) {
|
||||
return new String(buffer, 0, size);
|
||||
} else {
|
||||
return new String(buffer, 0, length);
|
||||
}
|
||||
if (length >= size) {
|
||||
return new String(buffer, 0, size);
|
||||
}
|
||||
return new String(buffer, 0, length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2334,11 +2334,11 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
|
|||
public String rightString(final int length) {
|
||||
if (length <= 0) {
|
||||
return StringUtils.EMPTY;
|
||||
} else if (length >= size) {
|
||||
return new String(buffer, 0, size);
|
||||
} else {
|
||||
return new String(buffer, size - length, length);
|
||||
}
|
||||
if (length >= size) {
|
||||
return new String(buffer, 0, size);
|
||||
}
|
||||
return new String(buffer, size - length, length);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -127,7 +127,7 @@ public class NumericEntityUnescaper extends CharSequenceTranslator {
|
|||
if (!semiNext) {
|
||||
if (isSet(OPTION.semiColonRequired)) {
|
||||
return 0;
|
||||
} else
|
||||
}
|
||||
if (isSet(OPTION.errorIfNoSemiColon)) {
|
||||
throw new IllegalArgumentException("Semi-colon required at end of numeric entity");
|
||||
}
|
||||
|
|
|
@ -786,11 +786,11 @@ public class DateUtils {
|
|||
}
|
||||
if (date instanceof Date) {
|
||||
return round((Date) date, field);
|
||||
} else if (date instanceof Calendar) {
|
||||
return round((Calendar) date, field).getTime();
|
||||
} else {
|
||||
throw new ClassCastException("Could not round " + date);
|
||||
}
|
||||
if (date instanceof Calendar) {
|
||||
return round((Calendar) date, field).getTime();
|
||||
}
|
||||
throw new ClassCastException("Could not round " + date);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
@ -863,11 +863,11 @@ public class DateUtils {
|
|||
}
|
||||
if (date instanceof Date) {
|
||||
return truncate((Date) date, field);
|
||||
} else if (date instanceof Calendar) {
|
||||
return truncate((Calendar) date, field).getTime();
|
||||
} else {
|
||||
throw new ClassCastException("Could not truncate " + date);
|
||||
}
|
||||
if (date instanceof Calendar) {
|
||||
return truncate((Calendar) date, field).getTime();
|
||||
}
|
||||
throw new ClassCastException("Could not truncate " + date);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
@ -943,11 +943,11 @@ public class DateUtils {
|
|||
}
|
||||
if (date instanceof Date) {
|
||||
return ceiling((Date) date, field);
|
||||
} else if (date instanceof Calendar) {
|
||||
return ceiling((Calendar) date, field).getTime();
|
||||
} else {
|
||||
throw new ClassCastException("Could not find ceiling of for type: " + date.getClass());
|
||||
}
|
||||
if (date instanceof Calendar) {
|
||||
return ceiling((Calendar) date, field).getTime();
|
||||
}
|
||||
throw new ClassCastException("Could not find ceiling of for type: " + date.getClass());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
@ -1251,11 +1251,11 @@ public class DateUtils {
|
|||
}
|
||||
if (focus instanceof Date) {
|
||||
return iterator((Date) focus, rangeStyle);
|
||||
} else if (focus instanceof Calendar) {
|
||||
return iterator((Calendar) focus, rangeStyle);
|
||||
} else {
|
||||
throw new ClassCastException("Could not iterate based on " + focus);
|
||||
}
|
||||
if (focus instanceof Calendar) {
|
||||
return iterator((Calendar) focus, rangeStyle);
|
||||
}
|
||||
throw new ClassCastException("Could not iterate based on " + focus);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -656,11 +656,11 @@ public class DurationFormatUtils {
|
|||
}
|
||||
if (this.value instanceof StringBuilder) {
|
||||
return this.value.toString().equals(tok2.value.toString());
|
||||
} else if (this.value instanceof Number) {
|
||||
return this.value.equals(tok2.value);
|
||||
} else {
|
||||
return this.value == tok2.value;
|
||||
}
|
||||
if (this.value instanceof Number) {
|
||||
return this.value.equals(tok2.value);
|
||||
}
|
||||
return this.value == tok2.value;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -242,7 +242,8 @@ public class FastDateParser implements DateParser, Serializable {
|
|||
final char c = pattern.charAt(currentIdx);
|
||||
if (!activeQuote && isFormatLetter(c)) {
|
||||
break;
|
||||
} else if (c == '\'' && (++currentIdx == pattern.length() || pattern.charAt(currentIdx) != '\'')) {
|
||||
}
|
||||
if (c == '\'' && (++currentIdx == pattern.length() || pattern.charAt(currentIdx) != '\'')) {
|
||||
activeQuote = !activeQuote;
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -338,12 +338,11 @@ public class FastDatePrinter implements DatePrinter, Serializable {
|
|||
|
||||
while (i + 1 < length) {
|
||||
final char peek = pattern.charAt(i + 1);
|
||||
if (peek == c) {
|
||||
buf.append(c);
|
||||
i++;
|
||||
} else {
|
||||
if (peek != c) {
|
||||
break;
|
||||
}
|
||||
buf.append(c);
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
// This will identify token as text.
|
||||
|
@ -410,14 +409,15 @@ public class FastDatePrinter implements DatePrinter, Serializable {
|
|||
public StringBuffer format(final Object obj, final StringBuffer toAppendTo, final FieldPosition pos) {
|
||||
if (obj instanceof Date) {
|
||||
return format((Date) obj, toAppendTo);
|
||||
} else if (obj instanceof Calendar) {
|
||||
return format((Calendar) obj, toAppendTo);
|
||||
} else if (obj instanceof Long) {
|
||||
return format(((Long) obj).longValue(), toAppendTo);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown class: " +
|
||||
(obj == null ? "<null>" : obj.getClass().getName()));
|
||||
}
|
||||
if (obj instanceof Calendar) {
|
||||
return format((Calendar) obj, toAppendTo);
|
||||
}
|
||||
if (obj instanceof Long) {
|
||||
return format(((Long) obj).longValue(), toAppendTo);
|
||||
}
|
||||
throw new IllegalArgumentException("Unknown class: " +
|
||||
(obj == null ? "<null>" : obj.getClass().getName()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -430,14 +430,15 @@ public class FastDatePrinter implements DatePrinter, Serializable {
|
|||
String format(final Object obj) {
|
||||
if (obj instanceof Date) {
|
||||
return format((Date) obj);
|
||||
} else if (obj instanceof Calendar) {
|
||||
return format((Calendar) obj);
|
||||
} else if (obj instanceof Long) {
|
||||
return format(((Long) obj).longValue());
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unknown class: " +
|
||||
(obj == null ? "<null>" : obj.getClass().getName()));
|
||||
}
|
||||
if (obj instanceof Calendar) {
|
||||
return format((Calendar) obj);
|
||||
}
|
||||
if (obj instanceof Long) {
|
||||
return format(((Long) obj).longValue());
|
||||
}
|
||||
throw new IllegalArgumentException("Unknown class: " +
|
||||
(obj == null ? "<null>" : obj.getClass().getName()));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -295,9 +295,11 @@ public class StopWatch {
|
|||
public long getNanoTime() {
|
||||
if (this.runningState == State.STOPPED || this.runningState == State.SUSPENDED) {
|
||||
return this.stopTimeNanos - this.startTimeNanos;
|
||||
} else if (this.runningState == State.UNSTARTED) {
|
||||
}
|
||||
if (this.runningState == State.UNSTARTED) {
|
||||
return 0;
|
||||
} else if (this.runningState == State.RUNNING) {
|
||||
}
|
||||
if (this.runningState == State.RUNNING) {
|
||||
return System.nanoTime() - this.startTimeNanos;
|
||||
}
|
||||
throw new IllegalStateException("Illegal running state has occurred.");
|
||||
|
|
Loading…
Reference in New Issue