mirror of
https://github.com/apache/commons-lang.git
synced 2025-02-08 19:14:52 +00:00
No need to nest in else.
This commit is contained in:
parent
a2b2b35ac3
commit
6b9964ff4b
@ -820,7 +820,8 @@ public static <T> T[] add(final T[] array, final T element) {
|
|||||||
public static boolean[] addAll(final boolean[] array1, final boolean... array2) {
|
public static boolean[] addAll(final boolean[] array1, final boolean... array2) {
|
||||||
if (array1 == null) {
|
if (array1 == null) {
|
||||||
return clone(array2);
|
return clone(array2);
|
||||||
} else if (array2 == null) {
|
}
|
||||||
|
if (array2 == null) {
|
||||||
return clone(array1);
|
return clone(array1);
|
||||||
}
|
}
|
||||||
final boolean[] joinedArray = new boolean[array1.length + array2.length];
|
final boolean[] joinedArray = new boolean[array1.length + array2.length];
|
||||||
@ -849,7 +850,8 @@ public static boolean[] addAll(final boolean[] array1, final boolean... array2)
|
|||||||
public static byte[] addAll(final byte[] array1, final byte... array2) {
|
public static byte[] addAll(final byte[] array1, final byte... array2) {
|
||||||
if (array1 == null) {
|
if (array1 == null) {
|
||||||
return clone(array2);
|
return clone(array2);
|
||||||
} else if (array2 == null) {
|
}
|
||||||
|
if (array2 == null) {
|
||||||
return clone(array1);
|
return clone(array1);
|
||||||
}
|
}
|
||||||
final byte[] joinedArray = new byte[array1.length + array2.length];
|
final byte[] joinedArray = new byte[array1.length + array2.length];
|
||||||
@ -878,7 +880,8 @@ public static byte[] addAll(final byte[] array1, final byte... array2) {
|
|||||||
public static char[] addAll(final char[] array1, final char... array2) {
|
public static char[] addAll(final char[] array1, final char... array2) {
|
||||||
if (array1 == null) {
|
if (array1 == null) {
|
||||||
return clone(array2);
|
return clone(array2);
|
||||||
} else if (array2 == null) {
|
}
|
||||||
|
if (array2 == null) {
|
||||||
return clone(array1);
|
return clone(array1);
|
||||||
}
|
}
|
||||||
final char[] joinedArray = new char[array1.length + array2.length];
|
final char[] joinedArray = new char[array1.length + array2.length];
|
||||||
@ -907,7 +910,8 @@ public static char[] addAll(final char[] array1, final char... array2) {
|
|||||||
public static double[] addAll(final double[] array1, final double... array2) {
|
public static double[] addAll(final double[] array1, final double... array2) {
|
||||||
if (array1 == null) {
|
if (array1 == null) {
|
||||||
return clone(array2);
|
return clone(array2);
|
||||||
} else if (array2 == null) {
|
}
|
||||||
|
if (array2 == null) {
|
||||||
return clone(array1);
|
return clone(array1);
|
||||||
}
|
}
|
||||||
final double[] joinedArray = new double[array1.length + array2.length];
|
final double[] joinedArray = new double[array1.length + array2.length];
|
||||||
@ -936,7 +940,8 @@ public static double[] addAll(final double[] array1, final double... array2) {
|
|||||||
public static float[] addAll(final float[] array1, final float... array2) {
|
public static float[] addAll(final float[] array1, final float... array2) {
|
||||||
if (array1 == null) {
|
if (array1 == null) {
|
||||||
return clone(array2);
|
return clone(array2);
|
||||||
} else if (array2 == null) {
|
}
|
||||||
|
if (array2 == null) {
|
||||||
return clone(array1);
|
return clone(array1);
|
||||||
}
|
}
|
||||||
final float[] joinedArray = new float[array1.length + array2.length];
|
final float[] joinedArray = new float[array1.length + array2.length];
|
||||||
@ -965,7 +970,8 @@ public static float[] addAll(final float[] array1, final float... array2) {
|
|||||||
public static int[] addAll(final int[] array1, final int... array2) {
|
public static int[] addAll(final int[] array1, final int... array2) {
|
||||||
if (array1 == null) {
|
if (array1 == null) {
|
||||||
return clone(array2);
|
return clone(array2);
|
||||||
} else if (array2 == null) {
|
}
|
||||||
|
if (array2 == null) {
|
||||||
return clone(array1);
|
return clone(array1);
|
||||||
}
|
}
|
||||||
final int[] joinedArray = new int[array1.length + array2.length];
|
final int[] joinedArray = new int[array1.length + array2.length];
|
||||||
@ -994,7 +1000,8 @@ public static int[] addAll(final int[] array1, final int... array2) {
|
|||||||
public static long[] addAll(final long[] array1, final long... array2) {
|
public static long[] addAll(final long[] array1, final long... array2) {
|
||||||
if (array1 == null) {
|
if (array1 == null) {
|
||||||
return clone(array2);
|
return clone(array2);
|
||||||
} else if (array2 == null) {
|
}
|
||||||
|
if (array2 == null) {
|
||||||
return clone(array1);
|
return clone(array1);
|
||||||
}
|
}
|
||||||
final long[] joinedArray = new long[array1.length + array2.length];
|
final long[] joinedArray = new long[array1.length + array2.length];
|
||||||
@ -1023,7 +1030,8 @@ public static long[] addAll(final long[] array1, final long... array2) {
|
|||||||
public static short[] addAll(final short[] array1, final short... array2) {
|
public static short[] addAll(final short[] array1, final short... array2) {
|
||||||
if (array1 == null) {
|
if (array1 == null) {
|
||||||
return clone(array2);
|
return clone(array2);
|
||||||
} else if (array2 == null) {
|
}
|
||||||
|
if (array2 == null) {
|
||||||
return clone(array1);
|
return clone(array1);
|
||||||
}
|
}
|
||||||
final short[] joinedArray = new short[array1.length + array2.length];
|
final short[] joinedArray = new short[array1.length + array2.length];
|
||||||
@ -1059,7 +1067,8 @@ public static short[] addAll(final short[] array1, final short... array2) {
|
|||||||
public static <T> T[] addAll(final T[] array1, @SuppressWarnings("unchecked") final T... array2) {
|
public static <T> T[] addAll(final T[] array1, @SuppressWarnings("unchecked") final T... array2) {
|
||||||
if (array1 == null) {
|
if (array1 == null) {
|
||||||
return clone(array2);
|
return clone(array2);
|
||||||
} else if (array2 == null) {
|
}
|
||||||
|
if (array2 == null) {
|
||||||
return clone(array1);
|
return clone(array1);
|
||||||
}
|
}
|
||||||
final Class<?> type1 = array1.getClass().getComponentType();
|
final Class<?> type1 = array1.getClass().getComponentType();
|
||||||
@ -3781,7 +3790,8 @@ public static int lastIndexOf(final boolean[] array, final boolean valueToFind,
|
|||||||
}
|
}
|
||||||
if (startIndex < 0) {
|
if (startIndex < 0) {
|
||||||
return INDEX_NOT_FOUND;
|
return INDEX_NOT_FOUND;
|
||||||
} else if (startIndex >= array.length) {
|
}
|
||||||
|
if (startIndex >= array.length) {
|
||||||
startIndex = array.length - 1;
|
startIndex = array.length - 1;
|
||||||
}
|
}
|
||||||
for (int i = startIndex; i >= 0; i--) {
|
for (int i = startIndex; i >= 0; i--) {
|
||||||
@ -3826,7 +3836,8 @@ public static int lastIndexOf(final byte[] array, final byte valueToFind, int st
|
|||||||
}
|
}
|
||||||
if (startIndex < 0) {
|
if (startIndex < 0) {
|
||||||
return INDEX_NOT_FOUND;
|
return INDEX_NOT_FOUND;
|
||||||
} else if (startIndex >= array.length) {
|
}
|
||||||
|
if (startIndex >= array.length) {
|
||||||
startIndex = array.length - 1;
|
startIndex = array.length - 1;
|
||||||
}
|
}
|
||||||
for (int i = startIndex; i >= 0; i--) {
|
for (int i = startIndex; i >= 0; i--) {
|
||||||
@ -3873,7 +3884,8 @@ public static int lastIndexOf(final char[] array, final char valueToFind, int st
|
|||||||
}
|
}
|
||||||
if (startIndex < 0) {
|
if (startIndex < 0) {
|
||||||
return INDEX_NOT_FOUND;
|
return INDEX_NOT_FOUND;
|
||||||
} else if (startIndex >= array.length) {
|
}
|
||||||
|
if (startIndex >= array.length) {
|
||||||
startIndex = array.length - 1;
|
startIndex = array.length - 1;
|
||||||
}
|
}
|
||||||
for (int i = startIndex; i >= 0; i--) {
|
for (int i = startIndex; i >= 0; i--) {
|
||||||
@ -3935,7 +3947,8 @@ public static int lastIndexOf(final double[] array, final double valueToFind, in
|
|||||||
}
|
}
|
||||||
if (startIndex < 0) {
|
if (startIndex < 0) {
|
||||||
return INDEX_NOT_FOUND;
|
return INDEX_NOT_FOUND;
|
||||||
} else if (startIndex >= array.length) {
|
}
|
||||||
|
if (startIndex >= array.length) {
|
||||||
startIndex = array.length - 1;
|
startIndex = array.length - 1;
|
||||||
}
|
}
|
||||||
for (int i = startIndex; i >= 0; i--) {
|
for (int i = startIndex; i >= 0; i--) {
|
||||||
@ -3969,7 +3982,8 @@ public static int lastIndexOf(final double[] array, final double valueToFind, in
|
|||||||
}
|
}
|
||||||
if (startIndex < 0) {
|
if (startIndex < 0) {
|
||||||
return INDEX_NOT_FOUND;
|
return INDEX_NOT_FOUND;
|
||||||
} else if (startIndex >= array.length) {
|
}
|
||||||
|
if (startIndex >= array.length) {
|
||||||
startIndex = array.length - 1;
|
startIndex = array.length - 1;
|
||||||
}
|
}
|
||||||
final double min = valueToFind - tolerance;
|
final double min = valueToFind - tolerance;
|
||||||
@ -4017,7 +4031,8 @@ public static int lastIndexOf(final float[] array, final float valueToFind, int
|
|||||||
}
|
}
|
||||||
if (startIndex < 0) {
|
if (startIndex < 0) {
|
||||||
return INDEX_NOT_FOUND;
|
return INDEX_NOT_FOUND;
|
||||||
} else if (startIndex >= array.length) {
|
}
|
||||||
|
if (startIndex >= array.length) {
|
||||||
startIndex = array.length - 1;
|
startIndex = array.length - 1;
|
||||||
}
|
}
|
||||||
for (int i = startIndex; i >= 0; i--) {
|
for (int i = startIndex; i >= 0; i--) {
|
||||||
@ -4062,7 +4077,8 @@ public static int lastIndexOf(final int[] array, final int valueToFind, int star
|
|||||||
}
|
}
|
||||||
if (startIndex < 0) {
|
if (startIndex < 0) {
|
||||||
return INDEX_NOT_FOUND;
|
return INDEX_NOT_FOUND;
|
||||||
} else if (startIndex >= array.length) {
|
}
|
||||||
|
if (startIndex >= array.length) {
|
||||||
startIndex = array.length - 1;
|
startIndex = array.length - 1;
|
||||||
}
|
}
|
||||||
for (int i = startIndex; i >= 0; i--) {
|
for (int i = startIndex; i >= 0; i--) {
|
||||||
@ -4107,7 +4123,8 @@ public static int lastIndexOf(final long[] array, final long valueToFind, int st
|
|||||||
}
|
}
|
||||||
if (startIndex < 0) {
|
if (startIndex < 0) {
|
||||||
return INDEX_NOT_FOUND;
|
return INDEX_NOT_FOUND;
|
||||||
} else if (startIndex >= array.length) {
|
}
|
||||||
|
if (startIndex >= array.length) {
|
||||||
startIndex = array.length - 1;
|
startIndex = array.length - 1;
|
||||||
}
|
}
|
||||||
for (int i = startIndex; i >= 0; i--) {
|
for (int i = startIndex; i >= 0; i--) {
|
||||||
@ -4152,7 +4169,8 @@ public static int lastIndexOf(final Object[] array, final Object objectToFind, i
|
|||||||
}
|
}
|
||||||
if (startIndex < 0) {
|
if (startIndex < 0) {
|
||||||
return INDEX_NOT_FOUND;
|
return INDEX_NOT_FOUND;
|
||||||
} else if (startIndex >= array.length) {
|
}
|
||||||
|
if (startIndex >= array.length) {
|
||||||
startIndex = array.length - 1;
|
startIndex = array.length - 1;
|
||||||
}
|
}
|
||||||
if (objectToFind == null) {
|
if (objectToFind == null) {
|
||||||
@ -4205,7 +4223,8 @@ public static int lastIndexOf(final short[] array, final short valueToFind, int
|
|||||||
}
|
}
|
||||||
if (startIndex < 0) {
|
if (startIndex < 0) {
|
||||||
return INDEX_NOT_FOUND;
|
return INDEX_NOT_FOUND;
|
||||||
} else if (startIndex >= array.length) {
|
}
|
||||||
|
if (startIndex >= array.length) {
|
||||||
startIndex = array.length - 1;
|
startIndex = array.length - 1;
|
||||||
}
|
}
|
||||||
for (int i = startIndex; i >= 0; i--) {
|
for (int i = startIndex; i >= 0; i--) {
|
||||||
@ -8978,7 +8997,8 @@ public static Map<Object, Object> toMap(final Object[] array) {
|
|||||||
public static Boolean[] toObject(final boolean[] array) {
|
public static Boolean[] toObject(final boolean[] array) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_BOOLEAN_OBJECT_ARRAY;
|
return EMPTY_BOOLEAN_OBJECT_ARRAY;
|
||||||
}
|
}
|
||||||
final Boolean[] result = new Boolean[array.length];
|
final Boolean[] result = new Boolean[array.length];
|
||||||
@ -8999,7 +9019,8 @@ public static Boolean[] toObject(final boolean[] array) {
|
|||||||
public static Byte[] toObject(final byte[] array) {
|
public static Byte[] toObject(final byte[] array) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_BYTE_OBJECT_ARRAY;
|
return EMPTY_BYTE_OBJECT_ARRAY;
|
||||||
}
|
}
|
||||||
final Byte[] result = new Byte[array.length];
|
final Byte[] result = new Byte[array.length];
|
||||||
@ -9020,7 +9041,8 @@ public static Byte[] toObject(final byte[] array) {
|
|||||||
public static Character[] toObject(final char[] array) {
|
public static Character[] toObject(final char[] array) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_CHARACTER_OBJECT_ARRAY;
|
return EMPTY_CHARACTER_OBJECT_ARRAY;
|
||||||
}
|
}
|
||||||
final Character[] result = new Character[array.length];
|
final Character[] result = new Character[array.length];
|
||||||
@ -9041,7 +9063,8 @@ public static Character[] toObject(final char[] array) {
|
|||||||
public static Double[] toObject(final double[] array) {
|
public static Double[] toObject(final double[] array) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_DOUBLE_OBJECT_ARRAY;
|
return EMPTY_DOUBLE_OBJECT_ARRAY;
|
||||||
}
|
}
|
||||||
final Double[] result = new Double[array.length];
|
final Double[] result = new Double[array.length];
|
||||||
@ -9062,7 +9085,8 @@ public static Double[] toObject(final double[] array) {
|
|||||||
public static Float[] toObject(final float[] array) {
|
public static Float[] toObject(final float[] array) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_FLOAT_OBJECT_ARRAY;
|
return EMPTY_FLOAT_OBJECT_ARRAY;
|
||||||
}
|
}
|
||||||
final Float[] result = new Float[array.length];
|
final Float[] result = new Float[array.length];
|
||||||
@ -9083,7 +9107,8 @@ public static Float[] toObject(final float[] array) {
|
|||||||
public static Integer[] toObject(final int[] array) {
|
public static Integer[] toObject(final int[] array) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_INTEGER_OBJECT_ARRAY;
|
return EMPTY_INTEGER_OBJECT_ARRAY;
|
||||||
}
|
}
|
||||||
final Integer[] result = new Integer[array.length];
|
final Integer[] result = new Integer[array.length];
|
||||||
@ -9104,7 +9129,8 @@ public static Integer[] toObject(final int[] array) {
|
|||||||
public static Long[] toObject(final long[] array) {
|
public static Long[] toObject(final long[] array) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_LONG_OBJECT_ARRAY;
|
return EMPTY_LONG_OBJECT_ARRAY;
|
||||||
}
|
}
|
||||||
final Long[] result = new Long[array.length];
|
final Long[] result = new Long[array.length];
|
||||||
@ -9125,7 +9151,8 @@ public static Long[] toObject(final long[] array) {
|
|||||||
public static Short[] toObject(final short[] array) {
|
public static Short[] toObject(final short[] array) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_SHORT_OBJECT_ARRAY;
|
return EMPTY_SHORT_OBJECT_ARRAY;
|
||||||
}
|
}
|
||||||
final Short[] result = new Short[array.length];
|
final Short[] result = new Short[array.length];
|
||||||
@ -9149,7 +9176,8 @@ public static Short[] toObject(final short[] array) {
|
|||||||
public static boolean[] toPrimitive(final Boolean[] array) {
|
public static boolean[] toPrimitive(final Boolean[] array) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_BOOLEAN_ARRAY;
|
return EMPTY_BOOLEAN_ARRAY;
|
||||||
}
|
}
|
||||||
final boolean[] result = new boolean[array.length];
|
final boolean[] result = new boolean[array.length];
|
||||||
@ -9171,7 +9199,8 @@ public static boolean[] toPrimitive(final Boolean[] array) {
|
|||||||
public static boolean[] toPrimitive(final Boolean[] array, final boolean valueForNull) {
|
public static boolean[] toPrimitive(final Boolean[] array, final boolean valueForNull) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_BOOLEAN_ARRAY;
|
return EMPTY_BOOLEAN_ARRAY;
|
||||||
}
|
}
|
||||||
final boolean[] result = new boolean[array.length];
|
final boolean[] result = new boolean[array.length];
|
||||||
@ -9196,7 +9225,8 @@ public static boolean[] toPrimitive(final Boolean[] array, final boolean valueFo
|
|||||||
public static byte[] toPrimitive(final Byte[] array) {
|
public static byte[] toPrimitive(final Byte[] array) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_BYTE_ARRAY;
|
return EMPTY_BYTE_ARRAY;
|
||||||
}
|
}
|
||||||
final byte[] result = new byte[array.length];
|
final byte[] result = new byte[array.length];
|
||||||
@ -9218,7 +9248,8 @@ public static byte[] toPrimitive(final Byte[] array) {
|
|||||||
public static byte[] toPrimitive(final Byte[] array, final byte valueForNull) {
|
public static byte[] toPrimitive(final Byte[] array, final byte valueForNull) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_BYTE_ARRAY;
|
return EMPTY_BYTE_ARRAY;
|
||||||
}
|
}
|
||||||
final byte[] result = new byte[array.length];
|
final byte[] result = new byte[array.length];
|
||||||
@ -9243,7 +9274,8 @@ public static byte[] toPrimitive(final Byte[] array, final byte valueForNull) {
|
|||||||
public static char[] toPrimitive(final Character[] array) {
|
public static char[] toPrimitive(final Character[] array) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_CHAR_ARRAY;
|
return EMPTY_CHAR_ARRAY;
|
||||||
}
|
}
|
||||||
final char[] result = new char[array.length];
|
final char[] result = new char[array.length];
|
||||||
@ -9265,7 +9297,8 @@ public static char[] toPrimitive(final Character[] array) {
|
|||||||
public static char[] toPrimitive(final Character[] array, final char valueForNull) {
|
public static char[] toPrimitive(final Character[] array, final char valueForNull) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_CHAR_ARRAY;
|
return EMPTY_CHAR_ARRAY;
|
||||||
}
|
}
|
||||||
final char[] result = new char[array.length];
|
final char[] result = new char[array.length];
|
||||||
@ -9290,7 +9323,8 @@ public static char[] toPrimitive(final Character[] array, final char valueForNul
|
|||||||
public static double[] toPrimitive(final Double[] array) {
|
public static double[] toPrimitive(final Double[] array) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_DOUBLE_ARRAY;
|
return EMPTY_DOUBLE_ARRAY;
|
||||||
}
|
}
|
||||||
final double[] result = new double[array.length];
|
final double[] result = new double[array.length];
|
||||||
@ -9312,7 +9346,8 @@ public static double[] toPrimitive(final Double[] array) {
|
|||||||
public static double[] toPrimitive(final Double[] array, final double valueForNull) {
|
public static double[] toPrimitive(final Double[] array, final double valueForNull) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_DOUBLE_ARRAY;
|
return EMPTY_DOUBLE_ARRAY;
|
||||||
}
|
}
|
||||||
final double[] result = new double[array.length];
|
final double[] result = new double[array.length];
|
||||||
@ -9337,7 +9372,8 @@ public static double[] toPrimitive(final Double[] array, final double valueForNu
|
|||||||
public static float[] toPrimitive(final Float[] array) {
|
public static float[] toPrimitive(final Float[] array) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_FLOAT_ARRAY;
|
return EMPTY_FLOAT_ARRAY;
|
||||||
}
|
}
|
||||||
final float[] result = new float[array.length];
|
final float[] result = new float[array.length];
|
||||||
@ -9359,7 +9395,8 @@ public static float[] toPrimitive(final Float[] array) {
|
|||||||
public static float[] toPrimitive(final Float[] array, final float valueForNull) {
|
public static float[] toPrimitive(final Float[] array, final float valueForNull) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_FLOAT_ARRAY;
|
return EMPTY_FLOAT_ARRAY;
|
||||||
}
|
}
|
||||||
final float[] result = new float[array.length];
|
final float[] result = new float[array.length];
|
||||||
@ -9384,7 +9421,8 @@ public static float[] toPrimitive(final Float[] array, final float valueForNull)
|
|||||||
public static int[] toPrimitive(final Integer[] array) {
|
public static int[] toPrimitive(final Integer[] array) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_INT_ARRAY;
|
return EMPTY_INT_ARRAY;
|
||||||
}
|
}
|
||||||
final int[] result = new int[array.length];
|
final int[] result = new int[array.length];
|
||||||
@ -9406,7 +9444,8 @@ public static int[] toPrimitive(final Integer[] array) {
|
|||||||
public static int[] toPrimitive(final Integer[] array, final int valueForNull) {
|
public static int[] toPrimitive(final Integer[] array, final int valueForNull) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_INT_ARRAY;
|
return EMPTY_INT_ARRAY;
|
||||||
}
|
}
|
||||||
final int[] result = new int[array.length];
|
final int[] result = new int[array.length];
|
||||||
@ -9431,7 +9470,8 @@ public static int[] toPrimitive(final Integer[] array, final int valueForNull) {
|
|||||||
public static long[] toPrimitive(final Long[] array) {
|
public static long[] toPrimitive(final Long[] array) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_LONG_ARRAY;
|
return EMPTY_LONG_ARRAY;
|
||||||
}
|
}
|
||||||
final long[] result = new long[array.length];
|
final long[] result = new long[array.length];
|
||||||
@ -9453,7 +9493,8 @@ public static long[] toPrimitive(final Long[] array) {
|
|||||||
public static long[] toPrimitive(final Long[] array, final long valueForNull) {
|
public static long[] toPrimitive(final Long[] array, final long valueForNull) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_LONG_ARRAY;
|
return EMPTY_LONG_ARRAY;
|
||||||
}
|
}
|
||||||
final long[] result = new long[array.length];
|
final long[] result = new long[array.length];
|
||||||
@ -9520,7 +9561,8 @@ public static Object toPrimitive(final Object array) {
|
|||||||
public static short[] toPrimitive(final Short[] array) {
|
public static short[] toPrimitive(final Short[] array) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_SHORT_ARRAY;
|
return EMPTY_SHORT_ARRAY;
|
||||||
}
|
}
|
||||||
final short[] result = new short[array.length];
|
final short[] result = new short[array.length];
|
||||||
@ -9542,7 +9584,8 @@ public static short[] toPrimitive(final Short[] array) {
|
|||||||
public static short[] toPrimitive(final Short[] array, final short valueForNull) {
|
public static short[] toPrimitive(final Short[] array, final short valueForNull) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_SHORT_ARRAY;
|
return EMPTY_SHORT_ARRAY;
|
||||||
}
|
}
|
||||||
final short[] result = new short[array.length];
|
final short[] result = new short[array.length];
|
||||||
@ -9603,7 +9646,8 @@ public static String toString(final Object array, final String stringIfNull) {
|
|||||||
public static String[] toStringArray(final Object[] array) {
|
public static String[] toStringArray(final Object[] array) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_STRING_ARRAY;
|
return EMPTY_STRING_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -9629,7 +9673,8 @@ public static String[] toStringArray(final Object[] array) {
|
|||||||
public static String[] toStringArray(final Object[] array, final String valueForNullElements) {
|
public static String[] toStringArray(final Object[] array, final String valueForNullElements) {
|
||||||
if (null == array) {
|
if (null == array) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return EMPTY_STRING_ARRAY;
|
return EMPTY_STRING_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -466,12 +466,15 @@ public static boolean toBoolean(final String str) {
|
|||||||
public static boolean toBoolean(final String str, final String trueString, final String falseString) {
|
public static boolean toBoolean(final String str, final String trueString, final String falseString) {
|
||||||
if (str == trueString) {
|
if (str == trueString) {
|
||||||
return true;
|
return true;
|
||||||
} else if (str == falseString) {
|
}
|
||||||
|
if (str == falseString) {
|
||||||
return false;
|
return false;
|
||||||
} else if (str != null) {
|
}
|
||||||
|
if (str != null) {
|
||||||
if (str.equals(trueString)) {
|
if (str.equals(trueString)) {
|
||||||
return true;
|
return true;
|
||||||
} else if (str.equals(falseString)) {
|
}
|
||||||
|
if (str.equals(falseString)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,9 +52,11 @@ private static boolean checkLaterThan1(final CharSequence cs, final CharSequence
|
|||||||
static int indexOf(final CharSequence cs, final CharSequence searchChar, final int start) {
|
static int indexOf(final CharSequence cs, final CharSequence searchChar, final int start) {
|
||||||
if (cs instanceof String) {
|
if (cs instanceof String) {
|
||||||
return ((String) cs).indexOf(searchChar.toString(), start);
|
return ((String) cs).indexOf(searchChar.toString(), start);
|
||||||
} else if (cs instanceof StringBuilder) {
|
}
|
||||||
|
if (cs instanceof StringBuilder) {
|
||||||
return ((StringBuilder) cs).indexOf(searchChar.toString(), start);
|
return ((StringBuilder) cs).indexOf(searchChar.toString(), start);
|
||||||
} else if (cs instanceof StringBuffer) {
|
}
|
||||||
|
if (cs instanceof StringBuffer) {
|
||||||
return ((StringBuffer) cs).indexOf(searchChar.toString(), start);
|
return ((StringBuffer) cs).indexOf(searchChar.toString(), start);
|
||||||
}
|
}
|
||||||
return cs.toString().indexOf(searchChar.toString(), start);
|
return cs.toString().indexOf(searchChar.toString(), start);
|
||||||
@ -152,9 +154,11 @@ static int lastIndexOf(final CharSequence cs, final CharSequence searchChar, int
|
|||||||
if (searchChar instanceof String) {
|
if (searchChar instanceof String) {
|
||||||
if (cs instanceof String) {
|
if (cs instanceof String) {
|
||||||
return ((String) cs).lastIndexOf((String) searchChar, start);
|
return ((String) cs).lastIndexOf((String) searchChar, start);
|
||||||
} else if (cs instanceof StringBuilder) {
|
}
|
||||||
|
if (cs instanceof StringBuilder) {
|
||||||
return ((StringBuilder) cs).lastIndexOf((String) searchChar, start);
|
return ((StringBuilder) cs).lastIndexOf((String) searchChar, start);
|
||||||
} else if (cs instanceof StringBuffer) {
|
}
|
||||||
|
if (cs instanceof StringBuffer) {
|
||||||
return ((StringBuffer) cs).lastIndexOf((String) searchChar, start);
|
return ((StringBuffer) cs).lastIndexOf((String) searchChar, start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -177,9 +181,11 @@ static int lastIndexOf(final CharSequence cs, final CharSequence searchChar, int
|
|||||||
if (len2 <= TO_STRING_LIMIT) {
|
if (len2 <= TO_STRING_LIMIT) {
|
||||||
if (cs instanceof String) {
|
if (cs instanceof String) {
|
||||||
return ((String) cs).lastIndexOf(searchChar.toString(), start);
|
return ((String) cs).lastIndexOf(searchChar.toString(), start);
|
||||||
} else if (cs instanceof StringBuilder) {
|
}
|
||||||
|
if (cs instanceof StringBuilder) {
|
||||||
return ((StringBuilder) cs).lastIndexOf(searchChar.toString(), start);
|
return ((StringBuilder) cs).lastIndexOf(searchChar.toString(), start);
|
||||||
} else if (cs instanceof StringBuffer) {
|
}
|
||||||
|
if (cs instanceof StringBuffer) {
|
||||||
return ((StringBuffer) cs).lastIndexOf(searchChar.toString(), start);
|
return ((StringBuffer) cs).lastIndexOf(searchChar.toString(), start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1228,7 +1228,8 @@ private static String toCanonicalName(String className) {
|
|||||||
public static Class<?>[] toClass(final Object... array) {
|
public static Class<?>[] toClass(final Object... array) {
|
||||||
if (array == null) {
|
if (array == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (array.length == 0) {
|
}
|
||||||
|
if (array.length == 0) {
|
||||||
return ArrayUtils.EMPTY_CLASS_ARRAY;
|
return ArrayUtils.EMPTY_CLASS_ARRAY;
|
||||||
}
|
}
|
||||||
final Class<?>[] classes = new Class[array.length];
|
final Class<?>[] classes = new Class[array.length];
|
||||||
|
@ -523,13 +523,14 @@ public static RuntimeException rethrow(final Throwable throwable) {
|
|||||||
Objects.requireNonNull(throwable, "throwable");
|
Objects.requireNonNull(throwable, "throwable");
|
||||||
if (throwable instanceof RuntimeException) {
|
if (throwable instanceof RuntimeException) {
|
||||||
throw (RuntimeException) throwable;
|
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 @@ private static float maxVersion() {
|
|||||||
*/
|
*/
|
||||||
private static float toFloatVersion(final String value) {
|
private static float toFloatVersion(final String value) {
|
||||||
final int defaultReturnValue = -1;
|
final int defaultReturnValue = -1;
|
||||||
if (value.contains(".")) {
|
if (!value.contains(".")) {
|
||||||
|
return NumberUtils.toFloat(value, defaultReturnValue);
|
||||||
|
}
|
||||||
final String[] toParse = value.split("\\.");
|
final String[] toParse = value.split("\\.");
|
||||||
if (toParse.length >= 2) {
|
if (toParse.length >= 2) {
|
||||||
return NumberUtils.toFloat(toParse[0] + '.' + toParse[1], defaultReturnValue);
|
return NumberUtils.toFloat(toParse[0] + '.' + toParse[1], defaultReturnValue);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return NumberUtils.toFloat(value, defaultReturnValue);
|
|
||||||
}
|
|
||||||
return defaultReturnValue;
|
return defaultReturnValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -329,9 +329,11 @@ public static <T extends Comparable<? super T>> int compare(final T c1, final T
|
|||||||
public static <T extends Comparable<? super T>> int compare(final T c1, final T c2, final boolean nullGreater) {
|
public static <T extends Comparable<? super T>> int compare(final T c1, final T c2, final boolean nullGreater) {
|
||||||
if (c1 == c2) {
|
if (c1 == c2) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (c1 == null) {
|
}
|
||||||
|
if (c1 == null) {
|
||||||
return nullGreater ? 1 : -1;
|
return nullGreater ? 1 : -1;
|
||||||
} else if (c2 == null) {
|
}
|
||||||
|
if (c2 == null) {
|
||||||
return nullGreater ? -1 : 1;
|
return nullGreater ? -1 : 1;
|
||||||
}
|
}
|
||||||
return c1.compareTo(c2);
|
return c1.compareTo(c2);
|
||||||
|
@ -362,7 +362,8 @@ public static String random(int count, int start, int end, final boolean letters
|
|||||||
final char[] chars, final Random random) {
|
final char[] chars, final Random random) {
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
return StringUtils.EMPTY;
|
return StringUtils.EMPTY;
|
||||||
} else if (count < 0) {
|
}
|
||||||
|
if (count < 0) {
|
||||||
throw new IllegalArgumentException("Requested random string length " + count + " is less than 0.");
|
throw new IllegalArgumentException("Requested random string length " + count + " is less than 0.");
|
||||||
}
|
}
|
||||||
if (chars != null && chars.length == 0) {
|
if (chars != null && chars.length == 0) {
|
||||||
|
@ -226,11 +226,11 @@ public int elementCompareTo(final T element) {
|
|||||||
Validate.notNull(element, "element");
|
Validate.notNull(element, "element");
|
||||||
if (isAfter(element)) {
|
if (isAfter(element)) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (isBefore(element)) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
if (isBefore(element)) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Element tests
|
// Element tests
|
||||||
@ -249,16 +249,16 @@ public int elementCompareTo(final T element) {
|
|||||||
public boolean equals(final Object obj) {
|
public boolean equals(final Object obj) {
|
||||||
if (obj == this) {
|
if (obj == this) {
|
||||||
return true;
|
return true;
|
||||||
} else if (obj == null || obj.getClass() != getClass()) {
|
}
|
||||||
|
if (obj == null || obj.getClass() != getClass()) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
}
|
||||||
@SuppressWarnings("unchecked") // OK because we checked the class above
|
@SuppressWarnings("unchecked") // OK because we checked the class above
|
||||||
final
|
final
|
||||||
Range<T> range = (Range<T>) obj;
|
Range<T> range = (Range<T>) obj;
|
||||||
return minimum.equals(range.minimum) &&
|
return minimum.equals(range.minimum) &&
|
||||||
maximum.equals(range.maximum);
|
maximum.equals(range.maximum);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Gets the comparator being used to determine if objects are within the range.</p>
|
* <p>Gets the comparator being used to determine if objects are within the range.</p>
|
||||||
@ -471,11 +471,11 @@ public T fit(final T element) {
|
|||||||
Validate.notNull(element, "element");
|
Validate.notNull(element, "element");
|
||||||
if (isAfter(element)) {
|
if (isAfter(element)) {
|
||||||
return minimum;
|
return minimum;
|
||||||
} else if (isBefore(element)) {
|
|
||||||
return maximum;
|
|
||||||
} else {
|
|
||||||
return element;
|
|
||||||
}
|
}
|
||||||
|
if (isBefore(element)) {
|
||||||
|
return maximum;
|
||||||
|
}
|
||||||
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -340,7 +340,8 @@ public static String abbreviate(final String str, final String abbrevMarker, fin
|
|||||||
public static String abbreviate(final String str, final String abbrevMarker, int offset, final int maxWidth) {
|
public static String abbreviate(final String str, final String abbrevMarker, int offset, final int maxWidth) {
|
||||||
if (isNotEmpty(str) && EMPTY.equals(abbrevMarker) && maxWidth > 0) {
|
if (isNotEmpty(str) && EMPTY.equals(abbrevMarker) && maxWidth > 0) {
|
||||||
return substring(str, 0, maxWidth);
|
return substring(str, 0, maxWidth);
|
||||||
} else if (isAnyEmpty(str, abbrevMarker)) {
|
}
|
||||||
|
if (isAnyEmpty(str, abbrevMarker)) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
final int abbrevMarkerLength = abbrevMarker.length();
|
final int abbrevMarkerLength = abbrevMarker.length();
|
||||||
@ -1061,7 +1062,10 @@ public static boolean containsAny(final CharSequence cs, final char... searchCha
|
|||||||
final char ch = cs.charAt(i);
|
final char ch = cs.charAt(i);
|
||||||
for (int j = 0; j < searchLength; j++) {
|
for (int j = 0; j < searchLength; j++) {
|
||||||
if (searchChars[j] == ch) {
|
if (searchChars[j] == ch) {
|
||||||
if (Character.isHighSurrogate(ch)) {
|
if (!Character.isHighSurrogate(ch)) {
|
||||||
|
// ch is in the Basic Multilingual Plane
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (j == searchLast) {
|
if (j == searchLast) {
|
||||||
// missing low surrogate, fine, like String.indexOf(String)
|
// missing low surrogate, fine, like String.indexOf(String)
|
||||||
return true;
|
return true;
|
||||||
@ -1069,10 +1073,6 @@ public static boolean containsAny(final CharSequence cs, final char... searchCha
|
|||||||
if (i < csLast && searchChars[j + 1] == cs.charAt(i + 1)) {
|
if (i < csLast && searchChars[j + 1] == cs.charAt(i + 1)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// ch is in the Basic Multilingual Plane
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1283,7 +1283,10 @@ public static boolean containsNone(final CharSequence cs, final char... searchCh
|
|||||||
final char ch = cs.charAt(i);
|
final char ch = cs.charAt(i);
|
||||||
for (int j = 0; j < searchLen; j++) {
|
for (int j = 0; j < searchLen; j++) {
|
||||||
if (searchChars[j] == ch) {
|
if (searchChars[j] == ch) {
|
||||||
if (Character.isHighSurrogate(ch)) {
|
if (!Character.isHighSurrogate(ch)) {
|
||||||
|
// ch is in the Basic Multilingual Plane
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (j == searchLast) {
|
if (j == searchLast) {
|
||||||
// missing low surrogate, fine, like String.indexOf(String)
|
// missing low surrogate, fine, like String.indexOf(String)
|
||||||
return false;
|
return false;
|
||||||
@ -1291,10 +1294,6 @@ public static boolean containsNone(final CharSequence cs, final char... searchCh
|
|||||||
if (i < csLast && searchChars[j + 1] == cs.charAt(i + 1)) {
|
if (i < csLast && searchChars[j + 1] == cs.charAt(i + 1)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// ch is in the Basic Multilingual Plane
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2055,14 +2054,14 @@ public static String getCommonPrefix(final String... strs) {
|
|||||||
return EMPTY;
|
return EMPTY;
|
||||||
}
|
}
|
||||||
return strs[0];
|
return strs[0];
|
||||||
} else if (smallestIndexOfDiff == 0) {
|
}
|
||||||
|
if (smallestIndexOfDiff == 0) {
|
||||||
// there were no common initial characters
|
// there were no common initial characters
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
} else {
|
}
|
||||||
// we found a common initial character sequence
|
// we found a common initial character sequence
|
||||||
return strs[0].substring(0, smallestIndexOfDiff);
|
return strs[0].substring(0, smallestIndexOfDiff);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Checks if a String {@code str} contains Unicode digits,
|
* <p>Checks if a String {@code str} contains Unicode digits,
|
||||||
@ -2134,7 +2133,8 @@ public static String getDigits(final String str) {
|
|||||||
public static int getFuzzyDistance(final CharSequence term, final CharSequence query, final Locale locale) {
|
public static int getFuzzyDistance(final CharSequence term, final CharSequence query, final Locale locale) {
|
||||||
if (term == null || query == null) {
|
if (term == null || query == null) {
|
||||||
throw new IllegalArgumentException("Strings must not be null");
|
throw new IllegalArgumentException("Strings must not be null");
|
||||||
} else if (locale == null) {
|
}
|
||||||
|
if (locale == null) {
|
||||||
throw new IllegalArgumentException("Locale must not be null");
|
throw new IllegalArgumentException("Locale must not be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2340,7 +2340,8 @@ public static int getLevenshteinDistance(CharSequence s, CharSequence t) {
|
|||||||
|
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
return m;
|
return m;
|
||||||
} else if (m == 0) {
|
}
|
||||||
|
if (m == 0) {
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2478,9 +2479,11 @@ distance is O(nm), but a bound of k allows us to reduce it to O(km) time by only
|
|||||||
// if one string is empty, the edit distance is necessarily the length of the other
|
// if one string is empty, the edit distance is necessarily the length of the other
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
return m <= threshold ? m : -1;
|
return m <= threshold ? m : -1;
|
||||||
} else if (m == 0) {
|
}
|
||||||
|
if (m == 0) {
|
||||||
return n <= threshold ? n : -1;
|
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
|
// no need to calculate the distance if the length difference is greater than the threshold
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -2762,12 +2765,11 @@ public static int indexOfAny(final CharSequence cs, final char... searchChars) {
|
|||||||
final char ch = cs.charAt(i);
|
final char ch = cs.charAt(i);
|
||||||
for (int j = 0; j < searchLen; j++) {
|
for (int j = 0; j < searchLen; j++) {
|
||||||
if (searchChars[j] == ch) {
|
if (searchChars[j] == ch) {
|
||||||
if (i < csLast && j < searchLast && Character.isHighSurrogate(ch)) {
|
if ((i >= csLast) || (j >= searchLast) || !Character.isHighSurrogate(ch)) {
|
||||||
// ch is a supplementary character
|
|
||||||
if (searchChars[j + 1] == cs.charAt(i + 1)) {
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
} else {
|
// ch is a supplementary character
|
||||||
|
if (searchChars[j + 1] == cs.charAt(i + 1)) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2896,11 +2898,10 @@ public static int indexOfAnyBut(final CharSequence cs, final char... searchChars
|
|||||||
final char ch = cs.charAt(i);
|
final char ch = cs.charAt(i);
|
||||||
for (int j = 0; j < searchLen; j++) {
|
for (int j = 0; j < searchLen; j++) {
|
||||||
if (searchChars[j] == ch) {
|
if (searchChars[j] == ch) {
|
||||||
if (i < csLast && j < searchLast && Character.isHighSurrogate(ch)) {
|
if ((i >= csLast) || (j >= searchLast) || !Character.isHighSurrogate(ch)) {
|
||||||
if (searchChars[j + 1] == cs.charAt(i + 1)) {
|
|
||||||
continue outer;
|
continue outer;
|
||||||
}
|
}
|
||||||
} else {
|
if (searchChars[j + 1] == cs.charAt(i + 1)) {
|
||||||
continue outer;
|
continue outer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3636,7 +3637,8 @@ public static boolean isMixedCase(final CharSequence cs) {
|
|||||||
for (int i = 0; i < sz; i++) {
|
for (int i = 0; i < sz; i++) {
|
||||||
if (containsUppercase && containsLowercase) {
|
if (containsUppercase && containsLowercase) {
|
||||||
return true;
|
return true;
|
||||||
} else if (Character.isUpperCase(cs.charAt(i))) {
|
}
|
||||||
|
if (Character.isUpperCase(cs.charAt(i))) {
|
||||||
containsUppercase = true;
|
containsUppercase = true;
|
||||||
} else if (Character.isLowerCase(cs.charAt(i))) {
|
} else if (Character.isLowerCase(cs.charAt(i))) {
|
||||||
containsLowercase = true;
|
containsLowercase = true;
|
||||||
@ -5344,9 +5346,10 @@ public static String leftPad(final String str, final int size, String padStr) {
|
|||||||
|
|
||||||
if (pads == padLen) {
|
if (pads == padLen) {
|
||||||
return padStr.concat(str);
|
return padStr.concat(str);
|
||||||
} else if (pads < padLen) {
|
}
|
||||||
|
if (pads < padLen) {
|
||||||
return padStr.substring(0, pads).concat(str);
|
return padStr.substring(0, pads).concat(str);
|
||||||
} else {
|
}
|
||||||
final char[] padding = new char[pads];
|
final char[] padding = new char[pads];
|
||||||
final char[] padChars = padStr.toCharArray();
|
final char[] padChars = padStr.toCharArray();
|
||||||
for (int i = 0; i < pads; i++) {
|
for (int i = 0; i < pads; i++) {
|
||||||
@ -5354,7 +5357,6 @@ public static String leftPad(final String str, final int size, String padStr) {
|
|||||||
}
|
}
|
||||||
return new String(padding).concat(str);
|
return new String(padding).concat(str);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a CharSequence length or {@code 0} if the CharSequence is
|
* Gets a CharSequence length or {@code 0} if the CharSequence is
|
||||||
@ -5468,11 +5470,10 @@ private static int[] matches(final CharSequence first, final CharSequence second
|
|||||||
}
|
}
|
||||||
int prefix = 0;
|
int prefix = 0;
|
||||||
for (int mi = 0; mi < min.length(); mi++) {
|
for (int mi = 0; mi < min.length(); mi++) {
|
||||||
if (first.charAt(mi) == second.charAt(mi)) {
|
if (first.charAt(mi) != second.charAt(mi)) {
|
||||||
prefix++;
|
|
||||||
} else {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
prefix++;
|
||||||
}
|
}
|
||||||
return new int[] { matches, transpositions / 2, prefix, max.length() };
|
return new int[] { matches, transpositions / 2, prefix, max.length() };
|
||||||
}
|
}
|
||||||
@ -7269,9 +7270,10 @@ public static String rightPad(final String str, final int size, String padStr) {
|
|||||||
|
|
||||||
if (pads == padLen) {
|
if (pads == padLen) {
|
||||||
return str.concat(padStr);
|
return str.concat(padStr);
|
||||||
} else if (pads < padLen) {
|
}
|
||||||
|
if (pads < padLen) {
|
||||||
return str.concat(padStr.substring(0, pads));
|
return str.concat(padStr.substring(0, pads));
|
||||||
} else {
|
}
|
||||||
final char[] padding = new char[pads];
|
final char[] padding = new char[pads];
|
||||||
final char[] padChars = padStr.toCharArray();
|
final char[] padChars = padStr.toCharArray();
|
||||||
for (int i = 0; i < pads; i++) {
|
for (int i = 0; i < pads; i++) {
|
||||||
@ -7279,7 +7281,6 @@ public static String rightPad(final String str, final int size, String padStr) {
|
|||||||
}
|
}
|
||||||
return str.concat(new String(padding));
|
return str.concat(new String(padding));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Rotate (circular shift) a String of {@code shift} characters.</p>
|
* <p>Rotate (circular shift) a String of {@code shift} characters.</p>
|
||||||
|
@ -150,10 +150,10 @@ public O compute(final I arg) throws InterruptedException {
|
|||||||
private RuntimeException launderException(final Throwable throwable) {
|
private RuntimeException launderException(final Throwable throwable) {
|
||||||
if (throwable instanceof RuntimeException) {
|
if (throwable instanceof RuntimeException) {
|
||||||
return (RuntimeException) throwable;
|
return (RuntimeException) throwable;
|
||||||
} else if (throwable instanceof Error) {
|
}
|
||||||
|
if (throwable instanceof Error) {
|
||||||
throw (Error) throwable;
|
throw (Error) throwable;
|
||||||
} else {
|
}
|
||||||
throw new IllegalStateException("Unchecked exception", throwable);
|
throw new IllegalStateException("Unchecked exception", throwable);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -410,13 +410,14 @@ public static RuntimeException rethrow(final Throwable throwable) {
|
|||||||
Objects.requireNonNull(throwable, "throwable");
|
Objects.requireNonNull(throwable, "throwable");
|
||||||
if (throwable instanceof RuntimeException) {
|
if (throwable instanceof RuntimeException) {
|
||||||
throw (RuntimeException) throwable;
|
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,21 +535,22 @@ public Fraction abs() {
|
|||||||
public Fraction pow(final int power) {
|
public Fraction pow(final int power) {
|
||||||
if (power == 1) {
|
if (power == 1) {
|
||||||
return this;
|
return this;
|
||||||
} else if (power == 0) {
|
}
|
||||||
|
if (power == 0) {
|
||||||
return ONE;
|
return ONE;
|
||||||
} else if (power < 0) {
|
}
|
||||||
|
if (power < 0) {
|
||||||
if (power == Integer.MIN_VALUE) { // MIN_VALUE can't be negated.
|
if (power == Integer.MIN_VALUE) { // MIN_VALUE can't be negated.
|
||||||
return this.invert().pow(2).pow(-(power / 2));
|
return this.invert().pow(2).pow(-(power / 2));
|
||||||
}
|
}
|
||||||
return this.invert().pow(-power);
|
return this.invert().pow(-power);
|
||||||
} else {
|
}
|
||||||
final Fraction f = this.multiplyBy(this);
|
final Fraction f = this.multiplyBy(this);
|
||||||
if (power % 2 == 0) { // if even...
|
if (power % 2 == 0) { // if even...
|
||||||
return f.pow(power / 2);
|
return f.pow(power / 2);
|
||||||
}
|
}
|
||||||
return f.pow(power / 2).multiplyBy(this);
|
return f.pow(power / 2).multiplyBy(this);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Gets the greatest common divisor of the absolute value of
|
* <p>Gets the greatest common divisor of the absolute value of
|
||||||
|
@ -97,12 +97,11 @@ public static double min(final double a, final double b, final double c) {
|
|||||||
public static double min(final double a, final double b) {
|
public static double min(final double a, final double b) {
|
||||||
if (Double.isNaN(a)) {
|
if (Double.isNaN(a)) {
|
||||||
return b;
|
return b;
|
||||||
} else
|
}
|
||||||
if (Double.isNaN(b)) {
|
if (Double.isNaN(b)) {
|
||||||
return a;
|
return a;
|
||||||
} else {
|
|
||||||
return Math.min(a, b);
|
|
||||||
}
|
}
|
||||||
|
return Math.min(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -131,12 +130,11 @@ public static float min(final float a, final float b, final float c) {
|
|||||||
public static float min(final float a, final float b) {
|
public static float min(final float a, final float b) {
|
||||||
if (Float.isNaN(a)) {
|
if (Float.isNaN(a)) {
|
||||||
return b;
|
return b;
|
||||||
} else
|
}
|
||||||
if (Float.isNaN(b)) {
|
if (Float.isNaN(b)) {
|
||||||
return a;
|
return a;
|
||||||
} else {
|
|
||||||
return Math.min(a, b);
|
|
||||||
}
|
}
|
||||||
|
return Math.min(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -209,12 +207,11 @@ public static double max(final double a, final double b, final double c) {
|
|||||||
public static double max(final double a, final double b) {
|
public static double max(final double a, final double b) {
|
||||||
if (Double.isNaN(a)) {
|
if (Double.isNaN(a)) {
|
||||||
return b;
|
return b;
|
||||||
} else
|
}
|
||||||
if (Double.isNaN(b)) {
|
if (Double.isNaN(b)) {
|
||||||
return a;
|
return a;
|
||||||
} else {
|
|
||||||
return Math.max(a, b);
|
|
||||||
}
|
}
|
||||||
|
return Math.max(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -243,12 +240,11 @@ public static float max(final float a, final float b, final float c) {
|
|||||||
public static float max(final float a, final float b) {
|
public static float max(final float a, final float b) {
|
||||||
if (Float.isNaN(a)) {
|
if (Float.isNaN(a)) {
|
||||||
return b;
|
return b;
|
||||||
} else
|
}
|
||||||
if (Float.isNaN(b)) {
|
if (Float.isNaN(b)) {
|
||||||
return a;
|
return a;
|
||||||
} else {
|
|
||||||
return Math.max(a, b);
|
|
||||||
}
|
}
|
||||||
|
return Math.max(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -682,11 +682,10 @@ public static Number createNumber(final String str) {
|
|||||||
char firstSigDigit = 0; // strip leading zeroes
|
char firstSigDigit = 0; // strip leading zeroes
|
||||||
for (int i = pfxLen; i < length; i++) {
|
for (int i = pfxLen; i < length; i++) {
|
||||||
firstSigDigit = str.charAt(i);
|
firstSigDigit = str.charAt(i);
|
||||||
if (firstSigDigit == '0') { // count leading zeroes
|
if (firstSigDigit != '0') {
|
||||||
pfxLen++;
|
|
||||||
} else {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
pfxLen++;
|
||||||
}
|
}
|
||||||
final int hexDigits = length - pfxLen;
|
final int hexDigits = length - pfxLen;
|
||||||
if (hexDigits > 16 || hexDigits == 16 && firstSigDigit > '7') { // too many for Long
|
if (hexDigits > 16 || hexDigits == 16 && firstSigDigit > '7') { // too many for Long
|
||||||
@ -1656,7 +1655,8 @@ public static boolean isCreatable(final String str) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (Character.isDigit(chars[start + 1])) {
|
}
|
||||||
|
if (Character.isDigit(chars[start + 1])) {
|
||||||
// leading 0, but not hex, must be octal
|
// leading 0, but not hex, must be octal
|
||||||
int i = start + 1;
|
int i = start + 1;
|
||||||
for (; i < chars.length; i++) {
|
for (; i < chars.length; i++) {
|
||||||
|
@ -108,11 +108,10 @@ public static Field getField(final Class<?> cls, final String fieldName, final b
|
|||||||
// getDeclaredField checks for non-public scopes as well
|
// getDeclaredField checks for non-public scopes as well
|
||||||
// and it returns accurate results
|
// and it returns accurate results
|
||||||
if (!Modifier.isPublic(field.getModifiers())) {
|
if (!Modifier.isPublic(field.getModifiers())) {
|
||||||
if (forceAccess) {
|
if (!forceAccess) {
|
||||||
field.setAccessible(true);
|
|
||||||
} else {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
field.setAccessible(true);
|
||||||
}
|
}
|
||||||
return field;
|
return field;
|
||||||
} catch (final NoSuchFieldException ex) { // NOPMD
|
} catch (final NoSuchFieldException ex) { // NOPMD
|
||||||
@ -174,11 +173,10 @@ public static Field getDeclaredField(final Class<?> cls, final String fieldName,
|
|||||||
// only consider the specified class by using getDeclaredField()
|
// only consider the specified class by using getDeclaredField()
|
||||||
final Field field = cls.getDeclaredField(fieldName);
|
final Field field = cls.getDeclaredField(fieldName);
|
||||||
if (!MemberUtils.isAccessible(field)) {
|
if (!MemberUtils.isAccessible(field)) {
|
||||||
if (forceAccess) {
|
if (!forceAccess) {
|
||||||
field.setAccessible(true);
|
|
||||||
} else {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
field.setAccessible(true);
|
||||||
}
|
}
|
||||||
return field;
|
return field;
|
||||||
} catch (final NoSuchFieldException e) { // NOPMD
|
} catch (final NoSuchFieldException e) { // NOPMD
|
||||||
|
@ -807,7 +807,8 @@ private static int distance(final Class<?>[] fromClassArray, final Class<?>[] to
|
|||||||
final Class<?> toClass = toClassArray[offset];
|
final Class<?> toClass = toClassArray[offset];
|
||||||
if (aClass == null || aClass.equals(toClass)) {
|
if (aClass == null || aClass.equals(toClass)) {
|
||||||
continue;
|
continue;
|
||||||
} else if (ClassUtils.isAssignable(aClass, toClass, true)
|
}
|
||||||
|
if (ClassUtils.isAssignable(aClass, toClass, true)
|
||||||
&& !ClassUtils.isAssignable(aClass, toClass, false)) {
|
&& !ClassUtils.isAssignable(aClass, toClass, false)) {
|
||||||
answer++;
|
answer++;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2312,11 +2312,11 @@ public String substring(final int startIndex, int endIndex) {
|
|||||||
public String leftString(final int length) {
|
public String leftString(final int length) {
|
||||||
if (length <= 0) {
|
if (length <= 0) {
|
||||||
return StringUtils.EMPTY;
|
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 String leftString(final int length) {
|
|||||||
public String rightString(final int length) {
|
public String rightString(final int length) {
|
||||||
if (length <= 0) {
|
if (length <= 0) {
|
||||||
return StringUtils.EMPTY;
|
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 int translate(final CharSequence input, final int index, final Writer out
|
|||||||
if (!semiNext) {
|
if (!semiNext) {
|
||||||
if (isSet(OPTION.semiColonRequired)) {
|
if (isSet(OPTION.semiColonRequired)) {
|
||||||
return 0;
|
return 0;
|
||||||
} else
|
}
|
||||||
if (isSet(OPTION.errorIfNoSemiColon)) {
|
if (isSet(OPTION.errorIfNoSemiColon)) {
|
||||||
throw new IllegalArgumentException("Semi-colon required at end of numeric entity");
|
throw new IllegalArgumentException("Semi-colon required at end of numeric entity");
|
||||||
}
|
}
|
||||||
|
@ -786,11 +786,11 @@ public static Date round(final Object date, final int field) {
|
|||||||
}
|
}
|
||||||
if (date instanceof Date) {
|
if (date instanceof Date) {
|
||||||
return round((Date) date, field);
|
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 static Date truncate(final Object date, final int field) {
|
|||||||
}
|
}
|
||||||
if (date instanceof Date) {
|
if (date instanceof Date) {
|
||||||
return truncate((Date) date, field);
|
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 static Date ceiling(final Object date, final int field) {
|
|||||||
}
|
}
|
||||||
if (date instanceof Date) {
|
if (date instanceof Date) {
|
||||||
return ceiling((Date) date, field);
|
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 static Iterator<?> iterator(final Object focus, final int rangeStyle) {
|
|||||||
}
|
}
|
||||||
if (focus instanceof Date) {
|
if (focus instanceof Date) {
|
||||||
return iterator((Date) focus, rangeStyle);
|
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 boolean equals(final Object obj2) {
|
|||||||
}
|
}
|
||||||
if (this.value instanceof StringBuilder) {
|
if (this.value instanceof StringBuilder) {
|
||||||
return this.value.toString().equals(tok2.value.toString());
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,8 @@ private StrategyAndWidth literal() {
|
|||||||
final char c = pattern.charAt(currentIdx);
|
final char c = pattern.charAt(currentIdx);
|
||||||
if (!activeQuote && isFormatLetter(c)) {
|
if (!activeQuote && isFormatLetter(c)) {
|
||||||
break;
|
break;
|
||||||
} else if (c == '\'' && (++currentIdx == pattern.length() || pattern.charAt(currentIdx) != '\'')) {
|
}
|
||||||
|
if (c == '\'' && (++currentIdx == pattern.length() || pattern.charAt(currentIdx) != '\'')) {
|
||||||
activeQuote = !activeQuote;
|
activeQuote = !activeQuote;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -338,12 +338,11 @@ protected String parseToken(final String pattern, final int[] indexRef) {
|
|||||||
|
|
||||||
while (i + 1 < length) {
|
while (i + 1 < length) {
|
||||||
final char peek = pattern.charAt(i + 1);
|
final char peek = pattern.charAt(i + 1);
|
||||||
if (peek == c) {
|
if (peek != c) {
|
||||||
buf.append(c);
|
|
||||||
i++;
|
|
||||||
} else {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
buf.append(c);
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// This will identify token as text.
|
// This will identify token as text.
|
||||||
@ -410,15 +409,16 @@ protected NumberRule selectNumberRule(final int field, final int padding) {
|
|||||||
public StringBuffer format(final Object obj, final StringBuffer toAppendTo, final FieldPosition pos) {
|
public StringBuffer format(final Object obj, final StringBuffer toAppendTo, final FieldPosition pos) {
|
||||||
if (obj instanceof Date) {
|
if (obj instanceof Date) {
|
||||||
return format((Date) obj, toAppendTo);
|
return format((Date) obj, toAppendTo);
|
||||||
} else if (obj instanceof Calendar) {
|
}
|
||||||
|
if (obj instanceof Calendar) {
|
||||||
return format((Calendar) obj, toAppendTo);
|
return format((Calendar) obj, toAppendTo);
|
||||||
} else if (obj instanceof Long) {
|
}
|
||||||
|
if (obj instanceof Long) {
|
||||||
return format(((Long) obj).longValue(), toAppendTo);
|
return format(((Long) obj).longValue(), toAppendTo);
|
||||||
} else {
|
}
|
||||||
throw new IllegalArgumentException("Unknown class: " +
|
throw new IllegalArgumentException("Unknown class: " +
|
||||||
(obj == null ? "<null>" : obj.getClass().getName()));
|
(obj == null ? "<null>" : obj.getClass().getName()));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Formats a {@code Date}, {@code Calendar} or
|
* <p>Formats a {@code Date}, {@code Calendar} or
|
||||||
@ -430,15 +430,16 @@ public StringBuffer format(final Object obj, final StringBuffer toAppendTo, fina
|
|||||||
String format(final Object obj) {
|
String format(final Object obj) {
|
||||||
if (obj instanceof Date) {
|
if (obj instanceof Date) {
|
||||||
return format((Date) obj);
|
return format((Date) obj);
|
||||||
} else if (obj instanceof Calendar) {
|
}
|
||||||
|
if (obj instanceof Calendar) {
|
||||||
return format((Calendar) obj);
|
return format((Calendar) obj);
|
||||||
} else if (obj instanceof Long) {
|
}
|
||||||
|
if (obj instanceof Long) {
|
||||||
return format(((Long) obj).longValue());
|
return format(((Long) obj).longValue());
|
||||||
} else {
|
}
|
||||||
throw new IllegalArgumentException("Unknown class: " +
|
throw new IllegalArgumentException("Unknown class: " +
|
||||||
(obj == null ? "<null>" : obj.getClass().getName()));
|
(obj == null ? "<null>" : obj.getClass().getName()));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.apache.commons.lang3.time.DatePrinter#format(long)
|
* @see org.apache.commons.lang3.time.DatePrinter#format(long)
|
||||||
|
@ -295,9 +295,11 @@ public String getMessage() {
|
|||||||
public long getNanoTime() {
|
public long getNanoTime() {
|
||||||
if (this.runningState == State.STOPPED || this.runningState == State.SUSPENDED) {
|
if (this.runningState == State.STOPPED || this.runningState == State.SUSPENDED) {
|
||||||
return this.stopTimeNanos - this.startTimeNanos;
|
return this.stopTimeNanos - this.startTimeNanos;
|
||||||
} else if (this.runningState == State.UNSTARTED) {
|
}
|
||||||
|
if (this.runningState == State.UNSTARTED) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (this.runningState == State.RUNNING) {
|
}
|
||||||
|
if (this.runningState == State.RUNNING) {
|
||||||
return System.nanoTime() - this.startTimeNanos;
|
return System.nanoTime() - this.startTimeNanos;
|
||||||
}
|
}
|
||||||
throw new IllegalStateException("Illegal running state has occurred.");
|
throw new IllegalStateException("Illegal running state has occurred.");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user