Make whitespace use after tokens consistent and add a checkstyle rule to enforce it.
This commit is contained in:
parent
c4d0dbcb56
commit
89cbfa54b0
|
@ -55,5 +55,6 @@ limitations under the License.
|
|||
<module name="LeftCurly"/>
|
||||
<module name="NeedBraces"/>
|
||||
<module name="RightCurly"/>
|
||||
<module name="WhitespaceAfter"/>
|
||||
</module>
|
||||
</module>
|
||||
|
|
|
@ -244,7 +244,7 @@ public class ArrayUtils {
|
|||
for (int i = 0; i < array.length; i++) {
|
||||
final Object object = array[i];
|
||||
if (object instanceof Map.Entry<?, ?>) {
|
||||
final Map.Entry<?,?> entry = (Map.Entry<?,?>) object;
|
||||
final Map.Entry<?, ?> entry = (Map.Entry<?, ?>) object;
|
||||
map.put(entry.getKey(), entry.getValue());
|
||||
} else if (object instanceof Object[]) {
|
||||
final Object[] entry = (Object[]) object;
|
||||
|
@ -275,7 +275,7 @@ public class ArrayUtils {
|
|||
return new T[size]; // compiler error here
|
||||
}
|
||||
public static <T> T[] createAnArray(int size) {
|
||||
return (T[])new Object[size]; // ClassCastException at runtime
|
||||
return (T[]) new Object[size]; // ClassCastException at runtime
|
||||
}
|
||||
* </pre>
|
||||
*
|
||||
|
@ -877,7 +877,7 @@ public class ArrayUtils {
|
|||
* {@code Date}, the following usage is envisaged:
|
||||
*
|
||||
* <pre>
|
||||
* Date[] someDates = (Date[])ArrayUtils.subarray(allDates, 2, 5);
|
||||
* Date[] someDates = (Date[]) ArrayUtils.subarray(allDates, 2, 5);
|
||||
* </pre>
|
||||
*
|
||||
* @param <T> the component type of the array
|
||||
|
@ -4748,19 +4748,19 @@ public class ArrayUtils {
|
|||
}
|
||||
final Class<?> ct = array.getClass().getComponentType();
|
||||
final Class<?> pt = ClassUtils.wrapperToPrimitive(ct);
|
||||
if(Integer.TYPE.equals(pt)) {
|
||||
if (Integer.TYPE.equals(pt)) {
|
||||
return toPrimitive((Integer[]) array);
|
||||
}
|
||||
if(Long.TYPE.equals(pt)) {
|
||||
if (Long.TYPE.equals(pt)) {
|
||||
return toPrimitive((Long[]) array);
|
||||
}
|
||||
if(Short.TYPE.equals(pt)) {
|
||||
if (Short.TYPE.equals(pt)) {
|
||||
return toPrimitive((Short[]) array);
|
||||
}
|
||||
if(Double.TYPE.equals(pt)) {
|
||||
if (Double.TYPE.equals(pt)) {
|
||||
return toPrimitive((Double[]) array);
|
||||
}
|
||||
if(Float.TYPE.equals(pt)) {
|
||||
if (Float.TYPE.equals(pt)) {
|
||||
return toPrimitive((Float[]) array);
|
||||
}
|
||||
return array;
|
||||
|
@ -5387,7 +5387,7 @@ public class ArrayUtils {
|
|||
* @since 2.1
|
||||
*/
|
||||
public static boolean[] add(final boolean[] array, final boolean element) {
|
||||
final boolean[] newArray = (boolean[])copyArrayGrow1(array, Boolean.TYPE);
|
||||
final boolean[] newArray = (boolean[]) copyArrayGrow1(array, Boolean.TYPE);
|
||||
newArray[newArray.length - 1] = element;
|
||||
return newArray;
|
||||
}
|
||||
|
@ -5414,7 +5414,7 @@ public class ArrayUtils {
|
|||
* @since 2.1
|
||||
*/
|
||||
public static byte[] add(final byte[] array, final byte element) {
|
||||
final byte[] newArray = (byte[])copyArrayGrow1(array, Byte.TYPE);
|
||||
final byte[] newArray = (byte[]) copyArrayGrow1(array, Byte.TYPE);
|
||||
newArray[newArray.length - 1] = element;
|
||||
return newArray;
|
||||
}
|
||||
|
@ -5441,7 +5441,7 @@ public class ArrayUtils {
|
|||
* @since 2.1
|
||||
*/
|
||||
public static char[] add(final char[] array, final char element) {
|
||||
final char[] newArray = (char[])copyArrayGrow1(array, Character.TYPE);
|
||||
final char[] newArray = (char[]) copyArrayGrow1(array, Character.TYPE);
|
||||
newArray[newArray.length - 1] = element;
|
||||
return newArray;
|
||||
}
|
||||
|
@ -5468,7 +5468,7 @@ public class ArrayUtils {
|
|||
* @since 2.1
|
||||
*/
|
||||
public static double[] add(final double[] array, final double element) {
|
||||
final double[] newArray = (double[])copyArrayGrow1(array, Double.TYPE);
|
||||
final double[] newArray = (double[]) copyArrayGrow1(array, Double.TYPE);
|
||||
newArray[newArray.length - 1] = element;
|
||||
return newArray;
|
||||
}
|
||||
|
@ -5495,7 +5495,7 @@ public class ArrayUtils {
|
|||
* @since 2.1
|
||||
*/
|
||||
public static float[] add(final float[] array, final float element) {
|
||||
final float[] newArray = (float[])copyArrayGrow1(array, Float.TYPE);
|
||||
final float[] newArray = (float[]) copyArrayGrow1(array, Float.TYPE);
|
||||
newArray[newArray.length - 1] = element;
|
||||
return newArray;
|
||||
}
|
||||
|
@ -5522,7 +5522,7 @@ public class ArrayUtils {
|
|||
* @since 2.1
|
||||
*/
|
||||
public static int[] add(final int[] array, final int element) {
|
||||
final int[] newArray = (int[])copyArrayGrow1(array, Integer.TYPE);
|
||||
final int[] newArray = (int[]) copyArrayGrow1(array, Integer.TYPE);
|
||||
newArray[newArray.length - 1] = element;
|
||||
return newArray;
|
||||
}
|
||||
|
@ -5549,7 +5549,7 @@ public class ArrayUtils {
|
|||
* @since 2.1
|
||||
*/
|
||||
public static long[] add(final long[] array, final long element) {
|
||||
final long[] newArray = (long[])copyArrayGrow1(array, Long.TYPE);
|
||||
final long[] newArray = (long[]) copyArrayGrow1(array, Long.TYPE);
|
||||
newArray[newArray.length - 1] = element;
|
||||
return newArray;
|
||||
}
|
||||
|
@ -8681,8 +8681,8 @@ public class ArrayUtils {
|
|||
* @return Whether the given index is safely-accessible in the given array
|
||||
* @since 3.8
|
||||
*/
|
||||
public static <T> boolean isArrayIndexValid(T[] array, int index){
|
||||
if(getLength(array) == 0 || array.length <= index){
|
||||
public static <T> boolean isArrayIndexValid(T[] array, int index) {
|
||||
if (getLength(array) == 0 || array.length <= index) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ public class CharSet implements Serializable {
|
|||
* <p>There are two ways to add a literal negation character ({@code ^}):</p>
|
||||
* <ul>
|
||||
* <li>As the last character in a string, e.g. {@code CharSet.getInstance("a-z^")}</li>
|
||||
* <li>As a separate element, e.g. {@code CharSet.getInstance("^","a-z")}</li>
|
||||
* <li>As a separate element, e.g. {@code CharSet.getInstance("^", "a-z")}</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p>Examples using the negation character:</p>
|
||||
|
|
|
@ -359,7 +359,7 @@ public class Conversion {
|
|||
* ordering.
|
||||
* </p>
|
||||
* <p>
|
||||
* (1, 0, 0, 0) is converted as follow: '8' (1,0,0,1,1,0,1,0) with srcPos = 3 is converted
|
||||
* (1, 0, 0, 0) is converted as follow: '8' (1, 0, 0, 1, 1, 0, 1, 0) with srcPos = 3 is converted
|
||||
* to 'D'
|
||||
* </p>
|
||||
*
|
||||
|
@ -407,7 +407,7 @@ public class Conversion {
|
|||
* bit ordering to a hexadecimal digit.
|
||||
* </p>
|
||||
* <p>
|
||||
* (1, 0, 0, 0) is converted as follow: '8' (1,0,0,0,0,0,0,0, 0,0,0,0,0,1,0,0) is converted
|
||||
* (1, 0, 0, 0) is converted as follow: '8' (1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0) is converted
|
||||
* to '4'
|
||||
* </p>
|
||||
*
|
||||
|
@ -426,8 +426,8 @@ public class Conversion {
|
|||
* hexadecimal digit.
|
||||
* </p>
|
||||
* <p>
|
||||
* (1, 0, 0, 0) with srcPos = 0 is converted as follow: '8' (1,0,0,0,0,0,0,0,
|
||||
* 0,0,0,1,0,1,0,0) with srcPos = 2 is converted to '5'
|
||||
* (1, 0, 0, 0) with srcPos = 0 is converted as follow: '8' (1, 0, 0, 0, 0, 0, 0, 0,
|
||||
* 0, 0, 0, 1, 0, 1, 0, 0) with srcPos = 2 is converted to '5'
|
||||
* </p>
|
||||
*
|
||||
* @param src the binary to convert
|
||||
|
|
|
@ -194,8 +194,8 @@ public class LocaleUtils {
|
|||
* a locale search.</p>
|
||||
*
|
||||
* <pre>
|
||||
* localeLookupList(Locale("fr","CA","xxx"))
|
||||
* = [Locale("fr","CA","xxx"), Locale("fr","CA"), Locale("fr")]
|
||||
* localeLookupList(Locale("fr", "CA", "xxx"))
|
||||
* = [Locale("fr", "CA", "xxx"), Locale("fr", "CA"), Locale("fr")]
|
||||
* </pre>
|
||||
*
|
||||
* @param locale the locale to start from
|
||||
|
@ -212,7 +212,7 @@ public class LocaleUtils {
|
|||
*
|
||||
* <pre>
|
||||
* localeLookupList(Locale("fr", "CA", "xxx"), Locale("en"))
|
||||
* = [Locale("fr","CA","xxx"), Locale("fr","CA"), Locale("fr"), Locale("en"]
|
||||
* = [Locale("fr", "CA", "xxx"), Locale("fr", "CA"), Locale("fr"), Locale("en"]
|
||||
* </pre>
|
||||
*
|
||||
* <p>The result list begins with the most specific locale, then the
|
||||
|
|
|
@ -134,7 +134,7 @@ public class SerializationUtils {
|
|||
*/
|
||||
public static void serialize(final Serializable obj, final OutputStream outputStream) {
|
||||
Validate.isTrue(outputStream != null, "The OutputStream must not be null");
|
||||
try (ObjectOutputStream out = new ObjectOutputStream(outputStream)){
|
||||
try (ObjectOutputStream out = new ObjectOutputStream(outputStream)) {
|
||||
out.writeObject(obj);
|
||||
} catch (final IOException ex) {
|
||||
throw new SerializationException(ex);
|
||||
|
|
|
@ -260,7 +260,7 @@ public class StringEscapeUtils {
|
|||
@Override
|
||||
public int translate(final CharSequence input, final int index, final Writer out) throws IOException {
|
||||
|
||||
if(index != 0) {
|
||||
if (index != 0) {
|
||||
throw new IllegalStateException("CsvEscaper should never reach the [1] index");
|
||||
}
|
||||
|
||||
|
@ -393,7 +393,7 @@ public class StringEscapeUtils {
|
|||
@Override
|
||||
public int translate(final CharSequence input, final int index, final Writer out) throws IOException {
|
||||
|
||||
if(index != 0) {
|
||||
if (index != 0) {
|
||||
throw new IllegalStateException("CsvUnescaper should never reach the [1] index");
|
||||
}
|
||||
|
||||
|
|
|
@ -256,7 +256,7 @@ public class StringUtils {
|
|||
if (ArrayUtils.isEmpty(css)) {
|
||||
return false;
|
||||
}
|
||||
for (final CharSequence cs : css){
|
||||
for (final CharSequence cs : css) {
|
||||
if (isEmpty(cs)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ public class StringUtils {
|
|||
if (ArrayUtils.isEmpty(css)) {
|
||||
return false;
|
||||
}
|
||||
for (final CharSequence cs : css){
|
||||
for (final CharSequence cs : css) {
|
||||
if (isBlank(cs)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -952,10 +952,10 @@ public class StringUtils {
|
|||
*/
|
||||
// See also Lucene's ASCIIFoldingFilter (Lucene 2.9) that replaces accented characters by their unaccented equivalent (and uncommitted bug fix: https://issues.apache.org/jira/browse/LUCENE-1343?focusedCommentId=12858907&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#action_12858907).
|
||||
public static String stripAccents(final String input) {
|
||||
if(input == null) {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
final Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+");//$NON-NLS-1$
|
||||
final Pattern pattern = Pattern.compile("\\p{InCombiningDiacriticalMarks}+"); //$NON-NLS-1$
|
||||
final StringBuilder decomposed = new StringBuilder(Normalizer.normalize(input, Normalizer.Form.NFD));
|
||||
convertRemainingAccentCharacters(decomposed);
|
||||
// Note that this doesn't correctly remove ligatures...
|
||||
|
@ -1488,9 +1488,9 @@ public class StringUtils {
|
|||
*
|
||||
* <p>Matches may overlap:</p>
|
||||
* <pre>
|
||||
* StringUtils.ordinalIndexOf("ababab","aba", 1) = 0
|
||||
* StringUtils.ordinalIndexOf("ababab","aba", 2) = 2
|
||||
* StringUtils.ordinalIndexOf("ababab","aba", 3) = -1
|
||||
* StringUtils.ordinalIndexOf("ababab", "aba", 1) = 0
|
||||
* StringUtils.ordinalIndexOf("ababab", "aba", 2) = 2
|
||||
* StringUtils.ordinalIndexOf("ababab", "aba", 3) = -1
|
||||
*
|
||||
* StringUtils.ordinalIndexOf("abababab", "abab", 1) = 0
|
||||
* StringUtils.ordinalIndexOf("abababab", "abab", 2) = 2
|
||||
|
@ -1530,7 +1530,7 @@ public class StringUtils {
|
|||
* @return the n-th index of the search CharSequence,
|
||||
* {@code -1} ({@code INDEX_NOT_FOUND}) if no match or {@code null} string input
|
||||
*/
|
||||
// Shared code between ordinalIndexOf(String,String,int) and lastOrdinalIndexOf(String,String,int)
|
||||
// Shared code between ordinalIndexOf(String, String, int) and lastOrdinalIndexOf(String, String, int)
|
||||
private static int ordinalIndexOf(final CharSequence str, final CharSequence searchStr, final int ordinal, final boolean lastIndex) {
|
||||
if (str == null || searchStr == null || ordinal <= 0) {
|
||||
return INDEX_NOT_FOUND;
|
||||
|
@ -2057,13 +2057,13 @@ public class StringUtils {
|
|||
* A {@code null} or zero length search array will return {@code -1}.</p>
|
||||
*
|
||||
* <pre>
|
||||
* StringUtils.indexOfAny(null, *) = -1
|
||||
* StringUtils.indexOfAny("", *) = -1
|
||||
* StringUtils.indexOfAny(*, null) = -1
|
||||
* StringUtils.indexOfAny(*, []) = -1
|
||||
* StringUtils.indexOfAny("zzabyycdxx",['z','a']) = 0
|
||||
* StringUtils.indexOfAny("zzabyycdxx",['b','y']) = 3
|
||||
* StringUtils.indexOfAny("aba", ['z']) = -1
|
||||
* StringUtils.indexOfAny(null, *) = -1
|
||||
* StringUtils.indexOfAny("", *) = -1
|
||||
* StringUtils.indexOfAny(*, null) = -1
|
||||
* StringUtils.indexOfAny(*, []) = -1
|
||||
* StringUtils.indexOfAny("zzabyycdxx", ['z', 'a']) = 0
|
||||
* StringUtils.indexOfAny("zzabyycdxx", ['b', 'y']) = 3
|
||||
* StringUtils.indexOfAny("aba", ['z']) = -1
|
||||
* </pre>
|
||||
*
|
||||
* @param cs the CharSequence to check, may be null
|
||||
|
@ -2112,7 +2112,7 @@ public class StringUtils {
|
|||
* StringUtils.indexOfAny(*, "") = -1
|
||||
* StringUtils.indexOfAny("zzabyycdxx", "za") = 0
|
||||
* StringUtils.indexOfAny("zzabyycdxx", "by") = 3
|
||||
* StringUtils.indexOfAny("aba","z") = -1
|
||||
* StringUtils.indexOfAny("aba", "z") = -1
|
||||
* </pre>
|
||||
*
|
||||
* @param cs the CharSequence to check, may be null
|
||||
|
@ -2138,14 +2138,14 @@ public class StringUtils {
|
|||
* A {@code null} or zero length search array will return {@code false}.</p>
|
||||
*
|
||||
* <pre>
|
||||
* StringUtils.containsAny(null, *) = false
|
||||
* StringUtils.containsAny("", *) = false
|
||||
* StringUtils.containsAny(*, null) = false
|
||||
* StringUtils.containsAny(*, []) = false
|
||||
* StringUtils.containsAny("zzabyycdxx",['z','a']) = true
|
||||
* StringUtils.containsAny("zzabyycdxx",['b','y']) = true
|
||||
* StringUtils.containsAny("zzabyycdxx",['z','y']) = true
|
||||
* StringUtils.containsAny("aba", ['z']) = false
|
||||
* StringUtils.containsAny(null, *) = false
|
||||
* StringUtils.containsAny("", *) = false
|
||||
* StringUtils.containsAny(*, null) = false
|
||||
* StringUtils.containsAny(*, []) = false
|
||||
* StringUtils.containsAny("zzabyycdxx", ['z', 'a']) = true
|
||||
* StringUtils.containsAny("zzabyycdxx", ['b', 'y']) = true
|
||||
* StringUtils.containsAny("zzabyycdxx", ['z', 'y']) = true
|
||||
* StringUtils.containsAny("aba", ['z']) = false
|
||||
* </pre>
|
||||
*
|
||||
* @param cs the CharSequence to check, may be null
|
||||
|
@ -2205,7 +2205,7 @@ public class StringUtils {
|
|||
* StringUtils.containsAny("zzabyycdxx", "zy") = true
|
||||
* StringUtils.containsAny("zzabyycdxx", "\tx") = true
|
||||
* StringUtils.containsAny("zzabyycdxx", "$.#yF") = true
|
||||
* StringUtils.containsAny("aba","z") = false
|
||||
* StringUtils.containsAny("aba", "z") = false
|
||||
* </pre>
|
||||
*
|
||||
* @param cs
|
||||
|
@ -2327,7 +2327,7 @@ public class StringUtils {
|
|||
* StringUtils.indexOfAnyBut(*, "") = -1
|
||||
* StringUtils.indexOfAnyBut("zzabyycdxx", "za") = 3
|
||||
* StringUtils.indexOfAnyBut("zzabyycdxx", "") = -1
|
||||
* StringUtils.indexOfAnyBut("aba","ab") = -1
|
||||
* StringUtils.indexOfAnyBut("aba", "ab") = -1
|
||||
* </pre>
|
||||
*
|
||||
* @param seq the CharSequence to check, may be null
|
||||
|
@ -2523,16 +2523,16 @@ public class StringUtils {
|
|||
* null. This method uses {@link String#indexOf(String)} if possible.</p>
|
||||
*
|
||||
* <pre>
|
||||
* StringUtils.indexOfAny(null, *) = -1
|
||||
* StringUtils.indexOfAny(*, null) = -1
|
||||
* StringUtils.indexOfAny(*, []) = -1
|
||||
* StringUtils.indexOfAny("zzabyycdxx", ["ab","cd"]) = 2
|
||||
* StringUtils.indexOfAny("zzabyycdxx", ["cd","ab"]) = 2
|
||||
* StringUtils.indexOfAny("zzabyycdxx", ["mn","op"]) = -1
|
||||
* StringUtils.indexOfAny("zzabyycdxx", ["zab","aby"]) = 1
|
||||
* StringUtils.indexOfAny("zzabyycdxx", [""]) = 0
|
||||
* StringUtils.indexOfAny("", [""]) = 0
|
||||
* StringUtils.indexOfAny("", ["a"]) = -1
|
||||
* StringUtils.indexOfAny(null, *) = -1
|
||||
* StringUtils.indexOfAny(*, null) = -1
|
||||
* StringUtils.indexOfAny(*, []) = -1
|
||||
* StringUtils.indexOfAny("zzabyycdxx", ["ab", "cd"]) = 2
|
||||
* StringUtils.indexOfAny("zzabyycdxx", ["cd", "ab"]) = 2
|
||||
* StringUtils.indexOfAny("zzabyycdxx", ["mn", "op"]) = -1
|
||||
* StringUtils.indexOfAny("zzabyycdxx", ["zab", "aby"]) = 1
|
||||
* StringUtils.indexOfAny("zzabyycdxx", [""]) = 0
|
||||
* StringUtils.indexOfAny("", [""]) = 0
|
||||
* StringUtils.indexOfAny("", ["a"]) = -1
|
||||
* </pre>
|
||||
*
|
||||
* @param str the CharSequence to check, may be null
|
||||
|
@ -2576,15 +2576,15 @@ public class StringUtils {
|
|||
* if {@code str} is not null. This method uses {@link String#indexOf(String)} if possible</p>
|
||||
*
|
||||
* <pre>
|
||||
* StringUtils.lastIndexOfAny(null, *) = -1
|
||||
* StringUtils.lastIndexOfAny(*, null) = -1
|
||||
* StringUtils.lastIndexOfAny(*, []) = -1
|
||||
* StringUtils.lastIndexOfAny(*, [null]) = -1
|
||||
* StringUtils.lastIndexOfAny("zzabyycdxx", ["ab","cd"]) = 6
|
||||
* StringUtils.lastIndexOfAny("zzabyycdxx", ["cd","ab"]) = 6
|
||||
* StringUtils.lastIndexOfAny("zzabyycdxx", ["mn","op"]) = -1
|
||||
* StringUtils.lastIndexOfAny("zzabyycdxx", ["mn","op"]) = -1
|
||||
* StringUtils.lastIndexOfAny("zzabyycdxx", ["mn",""]) = 10
|
||||
* StringUtils.lastIndexOfAny(null, *) = -1
|
||||
* StringUtils.lastIndexOfAny(*, null) = -1
|
||||
* StringUtils.lastIndexOfAny(*, []) = -1
|
||||
* StringUtils.lastIndexOfAny(*, [null]) = -1
|
||||
* StringUtils.lastIndexOfAny("zzabyycdxx", ["ab", "cd"]) = 6
|
||||
* StringUtils.lastIndexOfAny("zzabyycdxx", ["cd", "ab"]) = 6
|
||||
* StringUtils.lastIndexOfAny("zzabyycdxx", ["mn", "op"]) = -1
|
||||
* StringUtils.lastIndexOfAny("zzabyycdxx", ["mn", "op"]) = -1
|
||||
* StringUtils.lastIndexOfAny("zzabyycdxx", ["mn", ""]) = 10
|
||||
* </pre>
|
||||
*
|
||||
* @param str the CharSequence to check, may be null
|
||||
|
@ -4910,7 +4910,7 @@ public class StringUtils {
|
|||
if (isEmpty(str) || isEmpty(remove)) {
|
||||
return str;
|
||||
}
|
||||
if (str.startsWith(remove)){
|
||||
if (str.startsWith(remove)) {
|
||||
return str.substring(remove.length());
|
||||
}
|
||||
return str;
|
||||
|
@ -6161,7 +6161,7 @@ public class StringUtils {
|
|||
*/
|
||||
@Deprecated
|
||||
public static String chomp(final String str, final String separator) {
|
||||
return removeEnd(str,separator);
|
||||
return removeEnd(str, separator);
|
||||
}
|
||||
|
||||
// Chopping
|
||||
|
@ -6289,7 +6289,7 @@ public class StringUtils {
|
|||
* @since 2.5
|
||||
*/
|
||||
public static String repeat(final String str, final String separator, final int repeat) {
|
||||
if(str == null || separator == null) {
|
||||
if (str == null || separator == null) {
|
||||
return repeat(str, repeat);
|
||||
}
|
||||
// given that repeat(String, int) is quite optimized, better to rely on it than try and splice this into it
|
||||
|
@ -8176,8 +8176,8 @@ public class StringUtils {
|
|||
* <pre>
|
||||
* StringUtils.getLevenshteinDistance(null, *) = IllegalArgumentException
|
||||
* StringUtils.getLevenshteinDistance(*, null) = IllegalArgumentException
|
||||
* StringUtils.getLevenshteinDistance("","") = 0
|
||||
* StringUtils.getLevenshteinDistance("","a") = 1
|
||||
* StringUtils.getLevenshteinDistance("", "") = 0
|
||||
* StringUtils.getLevenshteinDistance("", "a") = 1
|
||||
* StringUtils.getLevenshteinDistance("aaapppp", "") = 7
|
||||
* StringUtils.getLevenshteinDistance("frog", "fog") = 1
|
||||
* StringUtils.getLevenshteinDistance("fly", "ant") = 3
|
||||
|
@ -8268,7 +8268,7 @@ public class StringUtils {
|
|||
* StringUtils.getLevenshteinDistance(null, *, *) = IllegalArgumentException
|
||||
* StringUtils.getLevenshteinDistance(*, null, *) = IllegalArgumentException
|
||||
* StringUtils.getLevenshteinDistance(*, *, -1) = IllegalArgumentException
|
||||
* StringUtils.getLevenshteinDistance("","", 0) = 0
|
||||
* StringUtils.getLevenshteinDistance("", "", 0) = 0
|
||||
* StringUtils.getLevenshteinDistance("aaapppp", "", 8) = 7
|
||||
* StringUtils.getLevenshteinDistance("aaapppp", "", 7) = 7
|
||||
* StringUtils.getLevenshteinDistance("aaapppp", "", 6)) = -1
|
||||
|
@ -8431,8 +8431,8 @@ public class StringUtils {
|
|||
*
|
||||
* <pre>
|
||||
* StringUtils.getJaroWinklerDistance(null, null) = IllegalArgumentException
|
||||
* StringUtils.getJaroWinklerDistance("","") = 0.0
|
||||
* StringUtils.getJaroWinklerDistance("","a") = 0.0
|
||||
* StringUtils.getJaroWinklerDistance("", "") = 0.0
|
||||
* StringUtils.getJaroWinklerDistance("", "a") = 0.0
|
||||
* StringUtils.getJaroWinklerDistance("aaapppp", "") = 0.0
|
||||
* StringUtils.getJaroWinklerDistance("frog", "fog") = 0.93
|
||||
* StringUtils.getJaroWinklerDistance("fly", "ant") = 0.0
|
||||
|
|
|
@ -52,7 +52,7 @@ public class ThreadUtils {
|
|||
public static Thread findThreadById(final long threadId, final ThreadGroup threadGroup) {
|
||||
Validate.isTrue(threadGroup != null, "The thread group must not be null");
|
||||
final Thread thread = findThreadById(threadId);
|
||||
if(thread != null && threadGroup.equals(thread.getThreadGroup())) {
|
||||
if (thread != null && threadGroup.equals(thread.getThreadGroup())) {
|
||||
return thread;
|
||||
}
|
||||
return null;
|
||||
|
@ -75,7 +75,7 @@ public class ThreadUtils {
|
|||
public static Thread findThreadById(final long threadId, final String threadGroupName) {
|
||||
Validate.isTrue(threadGroupName != null, "The thread group name must not be null");
|
||||
final Thread thread = findThreadById(threadId);
|
||||
if(thread != null && thread.getThreadGroup() != null && thread.getThreadGroup().getName().equals(threadGroupName)) {
|
||||
if (thread != null && thread.getThreadGroup() != null && thread.getThreadGroup().getName().equals(threadGroupName)) {
|
||||
return thread;
|
||||
}
|
||||
return null;
|
||||
|
@ -119,13 +119,13 @@ public class ThreadUtils {
|
|||
|
||||
final Collection<ThreadGroup> threadGroups = findThreadGroups(new NamePredicate(threadGroupName));
|
||||
|
||||
if(threadGroups.isEmpty()) {
|
||||
if (threadGroups.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
final Collection<Thread> result = new ArrayList<>();
|
||||
final NamePredicate threadNamePredicate = new NamePredicate(threadName);
|
||||
for(final ThreadGroup group : threadGroups) {
|
||||
for (final ThreadGroup group : threadGroups) {
|
||||
result.addAll(findThreads(group, false, threadNamePredicate));
|
||||
}
|
||||
return Collections.unmodifiableCollection(result);
|
||||
|
@ -170,7 +170,7 @@ public class ThreadUtils {
|
|||
*/
|
||||
public static ThreadGroup getSystemThreadGroup() {
|
||||
ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
|
||||
while(threadGroup.getParent() != null) {
|
||||
while (threadGroup.getParent() != null) {
|
||||
threadGroup = threadGroup.getParent();
|
||||
}
|
||||
return threadGroup;
|
||||
|
@ -431,11 +431,11 @@ public class ThreadUtils {
|
|||
threadGroups = new ThreadGroup[count + (count / 2) + 1]; //slightly grow the array size
|
||||
count = group.enumerate(threadGroups, recurse);
|
||||
//return value of enumerate() must be strictly less than the array size according to javadoc
|
||||
} while(count >= threadGroups.length);
|
||||
} while (count >= threadGroups.length);
|
||||
|
||||
final List<ThreadGroup> result = new ArrayList<>(count);
|
||||
for(int i = 0; i < count; ++i) {
|
||||
if(predicate.test(threadGroups[i])) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
if (predicate.test(threadGroups[i])) {
|
||||
result.add(threadGroups[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2407,7 +2407,7 @@ public abstract class ToStringStyle implements Serializable {
|
|||
throw new UnsupportedOperationException(
|
||||
"Field names are mandatory when using JsonToStringStyle");
|
||||
}
|
||||
if (!isFullDetail(fullDetail)){
|
||||
if (!isFullDetail(fullDetail)) {
|
||||
throw new UnsupportedOperationException(
|
||||
"FullDetail must be true when using JsonToStringStyle");
|
||||
}
|
||||
|
@ -2423,7 +2423,7 @@ public abstract class ToStringStyle implements Serializable {
|
|||
throw new UnsupportedOperationException(
|
||||
"Field names are mandatory when using JsonToStringStyle");
|
||||
}
|
||||
if (!isFullDetail(fullDetail)){
|
||||
if (!isFullDetail(fullDetail)) {
|
||||
throw new UnsupportedOperationException(
|
||||
"FullDetail must be true when using JsonToStringStyle");
|
||||
}
|
||||
|
@ -2439,7 +2439,7 @@ public abstract class ToStringStyle implements Serializable {
|
|||
throw new UnsupportedOperationException(
|
||||
"Field names are mandatory when using JsonToStringStyle");
|
||||
}
|
||||
if (!isFullDetail(fullDetail)){
|
||||
if (!isFullDetail(fullDetail)) {
|
||||
throw new UnsupportedOperationException(
|
||||
"FullDetail must be true when using JsonToStringStyle");
|
||||
}
|
||||
|
@ -2455,7 +2455,7 @@ public abstract class ToStringStyle implements Serializable {
|
|||
throw new UnsupportedOperationException(
|
||||
"Field names are mandatory when using JsonToStringStyle");
|
||||
}
|
||||
if (!isFullDetail(fullDetail)){
|
||||
if (!isFullDetail(fullDetail)) {
|
||||
throw new UnsupportedOperationException(
|
||||
"FullDetail must be true when using JsonToStringStyle");
|
||||
}
|
||||
|
@ -2471,7 +2471,7 @@ public abstract class ToStringStyle implements Serializable {
|
|||
throw new UnsupportedOperationException(
|
||||
"Field names are mandatory when using JsonToStringStyle");
|
||||
}
|
||||
if (!isFullDetail(fullDetail)){
|
||||
if (!isFullDetail(fullDetail)) {
|
||||
throw new UnsupportedOperationException(
|
||||
"FullDetail must be true when using JsonToStringStyle");
|
||||
}
|
||||
|
@ -2487,7 +2487,7 @@ public abstract class ToStringStyle implements Serializable {
|
|||
throw new UnsupportedOperationException(
|
||||
"Field names are mandatory when using JsonToStringStyle");
|
||||
}
|
||||
if (!isFullDetail(fullDetail)){
|
||||
if (!isFullDetail(fullDetail)) {
|
||||
throw new UnsupportedOperationException(
|
||||
"FullDetail must be true when using JsonToStringStyle");
|
||||
}
|
||||
|
@ -2503,7 +2503,7 @@ public abstract class ToStringStyle implements Serializable {
|
|||
throw new UnsupportedOperationException(
|
||||
"Field names are mandatory when using JsonToStringStyle");
|
||||
}
|
||||
if (!isFullDetail(fullDetail)){
|
||||
if (!isFullDetail(fullDetail)) {
|
||||
throw new UnsupportedOperationException(
|
||||
"FullDetail must be true when using JsonToStringStyle");
|
||||
}
|
||||
|
@ -2519,7 +2519,7 @@ public abstract class ToStringStyle implements Serializable {
|
|||
throw new UnsupportedOperationException(
|
||||
"Field names are mandatory when using JsonToStringStyle");
|
||||
}
|
||||
if (!isFullDetail(fullDetail)){
|
||||
if (!isFullDetail(fullDetail)) {
|
||||
throw new UnsupportedOperationException(
|
||||
"FullDetail must be true when using JsonToStringStyle");
|
||||
}
|
||||
|
@ -2535,7 +2535,7 @@ public abstract class ToStringStyle implements Serializable {
|
|||
throw new UnsupportedOperationException(
|
||||
"Field names are mandatory when using JsonToStringStyle");
|
||||
}
|
||||
if (!isFullDetail(fullDetail)){
|
||||
if (!isFullDetail(fullDetail)) {
|
||||
throw new UnsupportedOperationException(
|
||||
"FullDetail must be true when using JsonToStringStyle");
|
||||
}
|
||||
|
@ -2551,7 +2551,7 @@ public abstract class ToStringStyle implements Serializable {
|
|||
throw new UnsupportedOperationException(
|
||||
"Field names are mandatory when using JsonToStringStyle");
|
||||
}
|
||||
if (!isFullDetail(fullDetail)){
|
||||
if (!isFullDetail(fullDetail)) {
|
||||
throw new UnsupportedOperationException(
|
||||
"FullDetail must be true when using JsonToStringStyle");
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ import java.util.concurrent.TimeUnit;
|
|||
* // Gather statistics
|
||||
* public void run() {
|
||||
* try {
|
||||
* while(true) {
|
||||
* while (true) {
|
||||
* semaphore.acquire(); // limit database load
|
||||
* performQuery(); // issue a query
|
||||
* }
|
||||
|
|
|
@ -231,7 +231,7 @@ public class ContextedException extends Exception implements ExceptionContext {
|
|||
* @return the message, never null
|
||||
*/
|
||||
@Override
|
||||
public String getMessage(){
|
||||
public String getMessage() {
|
||||
return getFormattedExceptionMessage(super.getMessage());
|
||||
}
|
||||
|
||||
|
|
|
@ -231,7 +231,7 @@ public class ContextedRuntimeException extends RuntimeException implements Excep
|
|||
* @return the message, never null
|
||||
*/
|
||||
@Override
|
||||
public String getMessage(){
|
||||
public String getMessage() {
|
||||
return getFormattedExceptionMessage(super.getMessage());
|
||||
}
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ public class DefaultExceptionContext implements ExceptionContext, Serializable {
|
|||
* @return the exception message <b>with</b> context information appended, never null
|
||||
*/
|
||||
@Override
|
||||
public String getFormattedExceptionMessage(final String baseMessage){
|
||||
public String getFormattedExceptionMessage(final String baseMessage) {
|
||||
final StringBuilder buffer = new StringBuilder(256);
|
||||
if (baseMessage != null) {
|
||||
buffer.append(baseMessage);
|
||||
|
|
|
@ -95,10 +95,10 @@ public class IEEE754rUtils {
|
|||
* @return the smallest of the values
|
||||
*/
|
||||
public static double min(final double a, final double b) {
|
||||
if(Double.isNaN(a)) {
|
||||
if (Double.isNaN(a)) {
|
||||
return b;
|
||||
} else
|
||||
if(Double.isNaN(b)) {
|
||||
if (Double.isNaN(b)) {
|
||||
return a;
|
||||
} else {
|
||||
return Math.min(a, b);
|
||||
|
@ -129,10 +129,10 @@ public class IEEE754rUtils {
|
|||
* @return the smallest of the values
|
||||
*/
|
||||
public static float min(final float a, final float b) {
|
||||
if(Float.isNaN(a)) {
|
||||
if (Float.isNaN(a)) {
|
||||
return b;
|
||||
} else
|
||||
if(Float.isNaN(b)) {
|
||||
if (Float.isNaN(b)) {
|
||||
return a;
|
||||
} else {
|
||||
return Math.min(a, b);
|
||||
|
@ -207,10 +207,10 @@ public class IEEE754rUtils {
|
|||
* @return the largest of the values
|
||||
*/
|
||||
public static double max(final double a, final double b) {
|
||||
if(Double.isNaN(a)) {
|
||||
if (Double.isNaN(a)) {
|
||||
return b;
|
||||
} else
|
||||
if(Double.isNaN(b)) {
|
||||
if (Double.isNaN(b)) {
|
||||
return a;
|
||||
} else {
|
||||
return Math.max(a, b);
|
||||
|
@ -241,10 +241,10 @@ public class IEEE754rUtils {
|
|||
* @return the largest of the values
|
||||
*/
|
||||
public static float max(final float a, final float b) {
|
||||
if(Float.isNaN(a)) {
|
||||
if (Float.isNaN(a)) {
|
||||
return b;
|
||||
} else
|
||||
if(Float.isNaN(b)) {
|
||||
if (Float.isNaN(b)) {
|
||||
return a;
|
||||
} else {
|
||||
return Math.max(a, b);
|
||||
|
|
|
@ -122,7 +122,7 @@ public class NumberUtils {
|
|||
* @since 2.1
|
||||
*/
|
||||
public static int toInt(final String str, final int defaultValue) {
|
||||
if(str == null) {
|
||||
if (str == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
|
@ -366,7 +366,7 @@ public class NumberUtils {
|
|||
* @since 2.5
|
||||
*/
|
||||
public static byte toByte(final String str, final byte defaultValue) {
|
||||
if(str == null) {
|
||||
if (str == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
|
@ -415,7 +415,7 @@ public class NumberUtils {
|
|||
* @since 2.5
|
||||
*/
|
||||
public static short toShort(final String str, final short defaultValue) {
|
||||
if(str == null) {
|
||||
if (str == null) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
|
@ -585,33 +585,33 @@ public class NumberUtils {
|
|||
// BigDecimal, BigInteger and Byte
|
||||
// useful methods:
|
||||
// Byte.decode(String)
|
||||
// Byte.valueOf(String,int radix)
|
||||
// Byte.valueOf(String, int radix)
|
||||
// Byte.valueOf(String)
|
||||
// Double.valueOf(String)
|
||||
// Float.valueOf(String)
|
||||
// Float.valueOf(String)
|
||||
// Integer.valueOf(String,int radix)
|
||||
// Integer.valueOf(String, int radix)
|
||||
// Integer.valueOf(String)
|
||||
// Integer.decode(String)
|
||||
// Integer.getInteger(String)
|
||||
// Integer.getInteger(String,int val)
|
||||
// Integer.getInteger(String,Integer val)
|
||||
// Integer.getInteger(String, int val)
|
||||
// Integer.getInteger(String, Integer val)
|
||||
// Integer.valueOf(String)
|
||||
// Double.valueOf(String)
|
||||
// new Byte(String)
|
||||
// Long.valueOf(String)
|
||||
// Long.getLong(String)
|
||||
// Long.getLong(String,int)
|
||||
// Long.getLong(String,Integer)
|
||||
// Long.valueOf(String,int)
|
||||
// Long.getLong(String, int)
|
||||
// Long.getLong(String, Integer)
|
||||
// Long.valueOf(String, int)
|
||||
// Long.valueOf(String)
|
||||
// Short.valueOf(String)
|
||||
// Short.decode(String)
|
||||
// Short.valueOf(String,int)
|
||||
// Short.valueOf(String, int)
|
||||
// Short.valueOf(String)
|
||||
// new BigDecimal(String)
|
||||
// new BigInteger(String)
|
||||
// new BigInteger(String,int radix)
|
||||
// new BigInteger(String, int radix)
|
||||
// Possible inputs:
|
||||
// 45 45.5 45E7 4.5E7 Hex Oct Binary xxxF xxxD xxxf xxxd
|
||||
// plus minus everything. Prolly more. A lot are not separable.
|
||||
|
@ -624,7 +624,7 @@ public class NumberUtils {
|
|||
* prefix is more than 8 - or BigInteger if there are more than 16 digits.
|
||||
* </p>
|
||||
* <p>Then, the value is examined for a type qualifier on the end, i.e. one of
|
||||
* <code>'f','F','d','D','l','L'</code>. If it is found, it starts
|
||||
* <code>'f', 'F', 'd', 'D', 'l', 'L'</code>. If it is found, it starts
|
||||
* trying to create successively larger types from the type specified
|
||||
* until one is found that can represent the value.</p>
|
||||
*
|
||||
|
@ -657,7 +657,7 @@ public class NumberUtils {
|
|||
// Need to deal with all possible hex prefixes here
|
||||
final String[] hex_prefixes = {"0x", "0X", "-0x", "-0X", "#", "-#"};
|
||||
int pfxLen = 0;
|
||||
for(final String pfx : hex_prefixes) {
|
||||
for (final String pfx : hex_prefixes) {
|
||||
if (str.startsWith(pfx)) {
|
||||
pfxLen += pfx.length();
|
||||
break;
|
||||
|
@ -665,7 +665,7 @@ public class NumberUtils {
|
|||
}
|
||||
if (pfxLen > 0) { // we have a hex number
|
||||
char firstSigDigit = 0; // strip leading zeroes
|
||||
for(int i = pfxLen; i < str.length(); i++) {
|
||||
for (int i = pfxLen; i < str.length(); i++) {
|
||||
firstSigDigit = str.charAt(i);
|
||||
if (firstSigDigit == '0') { // count leading zeroes
|
||||
pfxLen++;
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
* <p>SystemUtils is a simple little class which makes it easy to find out information about which platform you are on.
|
||||
* For some, this is a necessary evil. It was never something I expected to use myself until I was trying to ensure that Commons Lang itself compiled under JDK 1.2.
|
||||
* Having pushed out a few JDK 1.3 bits that had slipped in (<code>Collections.EMPTY_MAP</code> is a classic offender), I then found that one of the Unit Tests was dying mysteriously under JDK 1.2, but ran fine under JDK 1.3.
|
||||
* There was no obvious solution and I needed to move onwards, so the simple solution was to wrap that particular test in a <code>if(SystemUtils.isJavaVersionAtLeast(1.3f)) {</code>, make a note and move on.</p>
|
||||
* There was no obvious solution and I needed to move onwards, so the simple solution was to wrap that particular test in a <code>if (SystemUtils.isJavaVersionAtLeast(1.3f)) {</code>, make a note and move on.</p>
|
||||
*
|
||||
* <p>The {@link org.apache.commons.lang3.CharEncoding} class is also used to interact with the Java environment and may be used to see which character encodings are supported in a particular environment. </p>
|
||||
*
|
||||
|
|
|
@ -271,7 +271,7 @@ public class ConstructorUtils {
|
|||
// temporary variable for annotation, see comment above (1)
|
||||
@SuppressWarnings("unchecked")
|
||||
final
|
||||
Constructor<T> constructor = (Constructor<T>)ctor;
|
||||
Constructor<T> constructor = (Constructor<T>) ctor;
|
||||
result = constructor;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ public class MethodUtils {
|
|||
* <p>This method delegates the method search to {@link #getMatchingAccessibleMethod(Class, String, Class[])}.</p>
|
||||
*
|
||||
* <p>This is a convenient wrapper for
|
||||
* {@link #invokeMethod(Object object,String methodName, Object[] args, Class[] parameterTypes)}.
|
||||
* {@link #invokeMethod(Object object, String methodName, Object[] args, Class[] parameterTypes)}.
|
||||
* </p>
|
||||
*
|
||||
* @param object invoke method on this object
|
||||
|
@ -99,7 +99,7 @@ public class MethodUtils {
|
|||
* <p>Invokes a named method without parameters.</p>
|
||||
*
|
||||
* <p>This is a convenient wrapper for
|
||||
* {@link #invokeMethod(Object object,boolean forceAccess,String methodName, Object[] args, Class[] parameterTypes)}.
|
||||
* {@link #invokeMethod(Object object, boolean forceAccess, String methodName, Object[] args, Class[] parameterTypes)}.
|
||||
* </p>
|
||||
*
|
||||
* @param object invoke method on this object
|
||||
|
@ -128,7 +128,7 @@ public class MethodUtils {
|
|||
* would match a {@code boolean} primitive.</p>
|
||||
*
|
||||
* <p>This is a convenient wrapper for
|
||||
* {@link #invokeMethod(Object object,String methodName, Object[] args, Class[] parameterTypes)}.
|
||||
* {@link #invokeMethod(Object object, String methodName, Object[] args, Class[] parameterTypes)}.
|
||||
* </p>
|
||||
*
|
||||
* @param object invoke method on this object
|
||||
|
@ -156,7 +156,7 @@ public class MethodUtils {
|
|||
* would match a {@code boolean} primitive.</p>
|
||||
*
|
||||
* <p>This is a convenient wrapper for
|
||||
* {@link #invokeMethod(Object object,boolean forceAccess,String methodName, Object[] args, Class[] parameterTypes)}.
|
||||
* {@link #invokeMethod(Object object, boolean forceAccess, String methodName, Object[] args, Class[] parameterTypes)}.
|
||||
* </p>
|
||||
*
|
||||
* @param object invoke method on this object
|
||||
|
@ -261,7 +261,7 @@ public class MethodUtils {
|
|||
* types.</p>
|
||||
*
|
||||
* <p>This uses reflection to invoke the method obtained from a call to
|
||||
* {@link #getAccessibleMethod}(Class,String,Class[])}.</p>
|
||||
* {@link #getAccessibleMethod}(Class, String, Class[])}.</p>
|
||||
*
|
||||
* @param object invoke method on this object
|
||||
* @param methodName get method with this name
|
||||
|
@ -284,7 +284,7 @@ public class MethodUtils {
|
|||
* <p>Invokes a method with no parameters.</p>
|
||||
*
|
||||
* <p>This uses reflection to invoke the method obtained from a call to
|
||||
* {@link #getAccessibleMethod}(Class,String,Class[])}.</p>
|
||||
* {@link #getAccessibleMethod}(Class, String, Class[])}.</p>
|
||||
*
|
||||
* @param object invoke method on this object
|
||||
* @param methodName get method with this name
|
||||
|
@ -310,7 +310,7 @@ public class MethodUtils {
|
|||
* types given.</p>
|
||||
*
|
||||
* <p>This uses reflection to invoke the method obtained from a call to
|
||||
* {@link #getAccessibleMethod(Class,String,Class[])}.</p>
|
||||
* {@link #getAccessibleMethod(Class, String, Class[])}.</p>
|
||||
*
|
||||
* @param object invoke method on this object
|
||||
* @param methodName get method with this name
|
||||
|
@ -482,7 +482,7 @@ public class MethodUtils {
|
|||
// Copy the variadic arguments into the varargs array.
|
||||
System.arraycopy(args, methodParameterTypes.length - 1, varArgsArray, 0, varArgLength);
|
||||
|
||||
if(varArgComponentType.isPrimitive()) {
|
||||
if (varArgComponentType.isPrimitive()) {
|
||||
// unbox from wrapper type to primitive type
|
||||
varArgsArray = ArrayUtils.toPrimitive(varArgsArray);
|
||||
}
|
||||
|
|
|
@ -737,7 +737,7 @@ public class TypeUtils {
|
|||
/**
|
||||
* <p>Retrieves all the type arguments for this parameterized type
|
||||
* including owner hierarchy arguments such as
|
||||
* {@code Outer<K,V>.Inner<T>.DeepInner<E>} .
|
||||
* {@code Outer<K, V>.Inner<T>.DeepInner<E>} .
|
||||
* The arguments are returned in a
|
||||
* {@link Map} specifying the argument type for each {@link TypeVariable}.
|
||||
* </p>
|
||||
|
|
|
@ -276,7 +276,7 @@ public class ExtendedMessageFormat extends MessageFormat {
|
|||
if (ObjectUtils.notEqual(getClass(), obj.getClass())) {
|
||||
return false;
|
||||
}
|
||||
final ExtendedMessageFormat rhs = (ExtendedMessageFormat)obj;
|
||||
final ExtendedMessageFormat rhs = (ExtendedMessageFormat) obj;
|
||||
if (ObjectUtils.notEqual(toPattern, rhs.toPattern)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ public class ExtendedMessageFormat extends MessageFormat {
|
|||
"Quoted string must start with quote character";
|
||||
|
||||
// handle quote character at the beginning of the string
|
||||
if(appendTo != null) {
|
||||
if (appendTo != null) {
|
||||
appendTo.append(QUOTE);
|
||||
}
|
||||
next(pos);
|
||||
|
|
|
@ -1348,11 +1348,11 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
|
|||
* This method is for example useful for constructing queries
|
||||
* <pre>
|
||||
* StrBuilder whereClause = new StrBuilder();
|
||||
* if(searchCommand.getPriority() != null) {
|
||||
* if (searchCommand.getPriority() != null) {
|
||||
* whereClause.appendSeparator(" and", " where");
|
||||
* whereClause.append(" priority = ?")
|
||||
* }
|
||||
* if(searchCommand.getComponent() != null) {
|
||||
* if (searchCommand.getComponent() != null) {
|
||||
* whereClause.appendSeparator(" and", " where");
|
||||
* whereClause.append(" component = ?")
|
||||
* }
|
||||
|
@ -2145,7 +2145,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
|
|||
|
||||
final int half = size / 2;
|
||||
final char[] buf = buffer;
|
||||
for (int leftIdx = 0, rightIdx = size - 1; leftIdx < half; leftIdx++,rightIdx--) {
|
||||
for (int leftIdx = 0, rightIdx = size - 1; leftIdx < half; leftIdx++, rightIdx--) {
|
||||
final char swap = buf[leftIdx];
|
||||
buf[leftIdx] = buf[rightIdx];
|
||||
buf[rightIdx] = swap;
|
||||
|
@ -2230,7 +2230,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
|
|||
return false;
|
||||
}
|
||||
int pos = size - len;
|
||||
for (int i = 0; i < len; i++,pos++) {
|
||||
for (int i = 0; i < len; i++, pos++) {
|
||||
if (buffer[pos] != str.charAt(i)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -218,10 +218,10 @@ public class StrSubstitutor {
|
|||
if (valueProperties == null) {
|
||||
return source.toString();
|
||||
}
|
||||
final Map<String,String> valueMap = new HashMap<>();
|
||||
final Map<String, String> valueMap = new HashMap<>();
|
||||
final Enumeration<?> propNames = valueProperties.propertyNames();
|
||||
while (propNames.hasMoreElements()) {
|
||||
final String propName = (String)propNames.nextElement();
|
||||
final String propName = (String) propNames.nextElement();
|
||||
final String propValue = valueProperties.getProperty(propName);
|
||||
valueMap.put(propName, propValue);
|
||||
}
|
||||
|
|
|
@ -292,7 +292,7 @@ public class WordUtils {
|
|||
while (offset < inputLineLength) {
|
||||
int spaceToWrapAt = -1;
|
||||
Matcher matcher = patternToWrapOn.matcher(
|
||||
str.substring(offset, Math.min((int)Math.min(Integer.MAX_VALUE, offset + wrapLength + 1L), inputLineLength)));
|
||||
str.substring(offset, Math.min((int) Math.min(Integer.MAX_VALUE, offset + wrapLength + 1L), inputLineLength)));
|
||||
if (matcher.find()) {
|
||||
if (matcher.start() == 0) {
|
||||
offset += matcher.end();
|
||||
|
@ -302,11 +302,11 @@ public class WordUtils {
|
|||
}
|
||||
|
||||
// only last line without leading spaces is left
|
||||
if(inputLineLength - offset <= wrapLength) {
|
||||
if (inputLineLength - offset <= wrapLength) {
|
||||
break;
|
||||
}
|
||||
|
||||
while(matcher.find()){
|
||||
while (matcher.find()) {
|
||||
spaceToWrapAt = matcher.start() + offset;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ public class AggregateTranslator extends CharSequenceTranslator {
|
|||
public int translate(final CharSequence input, final int index, final Writer out) throws IOException {
|
||||
for (final CharSequenceTranslator translator : translators) {
|
||||
final int consumed = translator.translate(input, index, out);
|
||||
if(consumed != 0) {
|
||||
if (consumed != 0) {
|
||||
return consumed;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -163,15 +163,15 @@ public class EntityArrays {
|
|||
// <!-- Greek -->
|
||||
{"\u0391", "Α"}, // greek capital letter alpha, U+0391 -->
|
||||
{"\u0392", "Β"}, // greek capital letter beta, U+0392 -->
|
||||
{"\u0393", "Γ"}, // greek capital letter gamma,U+0393 ISOgrk3 -->
|
||||
{"\u0394", "Δ"}, // greek capital letter delta,U+0394 ISOgrk3 -->
|
||||
{"\u0393", "Γ"}, // greek capital letter gamma, U+0393 ISOgrk3 -->
|
||||
{"\u0394", "Δ"}, // greek capital letter delta, U+0394 ISOgrk3 -->
|
||||
{"\u0395", "Ε"}, // greek capital letter epsilon, U+0395 -->
|
||||
{"\u0396", "Ζ"}, // greek capital letter zeta, U+0396 -->
|
||||
{"\u0397", "Η"}, // greek capital letter eta, U+0397 -->
|
||||
{"\u0398", "Θ"}, // greek capital letter theta,U+0398 ISOgrk3 -->
|
||||
{"\u0398", "Θ"}, // greek capital letter theta, U+0398 ISOgrk3 -->
|
||||
{"\u0399", "Ι"}, // greek capital letter iota, U+0399 -->
|
||||
{"\u039A", "Κ"}, // greek capital letter kappa, U+039A -->
|
||||
{"\u039B", "Λ"}, // greek capital letter lambda,U+039B ISOgrk3 -->
|
||||
{"\u039B", "Λ"}, // greek capital letter lambda, U+039B ISOgrk3 -->
|
||||
{"\u039C", "Μ"}, // greek capital letter mu, U+039C -->
|
||||
{"\u039D", "Ν"}, // greek capital letter nu, U+039D -->
|
||||
{"\u039E", "Ξ"}, // greek capital letter xi, U+039E ISOgrk3 -->
|
||||
|
@ -179,56 +179,56 @@ public class EntityArrays {
|
|||
{"\u03A0", "Π"}, // greek capital letter pi, U+03A0 ISOgrk3 -->
|
||||
{"\u03A1", "Ρ"}, // greek capital letter rho, U+03A1 -->
|
||||
// <!-- there is no Sigmaf, and no U+03A2 character either -->
|
||||
{"\u03A3", "Σ"}, // greek capital letter sigma,U+03A3 ISOgrk3 -->
|
||||
{"\u03A3", "Σ"}, // greek capital letter sigma, U+03A3 ISOgrk3 -->
|
||||
{"\u03A4", "Τ"}, // greek capital letter tau, U+03A4 -->
|
||||
{"\u03A5", "Υ"}, // greek capital letter upsilon,U+03A5 ISOgrk3 -->
|
||||
{"\u03A6", "Φ"}, // greek capital letter phi,U+03A6 ISOgrk3 -->
|
||||
{"\u03A5", "Υ"}, // greek capital letter upsilon, U+03A5 ISOgrk3 -->
|
||||
{"\u03A6", "Φ"}, // greek capital letter phi, U+03A6 ISOgrk3 -->
|
||||
{"\u03A7", "Χ"}, // greek capital letter chi, U+03A7 -->
|
||||
{"\u03A8", "Ψ"}, // greek capital letter psi,U+03A8 ISOgrk3 -->
|
||||
{"\u03A9", "Ω"}, // greek capital letter omega,U+03A9 ISOgrk3 -->
|
||||
{"\u03B1", "α"}, // greek small letter alpha,U+03B1 ISOgrk3 -->
|
||||
{"\u03A8", "Ψ"}, // greek capital letter psi, U+03A8 ISOgrk3 -->
|
||||
{"\u03A9", "Ω"}, // greek capital letter omega, U+03A9 ISOgrk3 -->
|
||||
{"\u03B1", "α"}, // greek small letter alpha, U+03B1 ISOgrk3 -->
|
||||
{"\u03B2", "β"}, // greek small letter beta, U+03B2 ISOgrk3 -->
|
||||
{"\u03B3", "γ"}, // greek small letter gamma,U+03B3 ISOgrk3 -->
|
||||
{"\u03B4", "δ"}, // greek small letter delta,U+03B4 ISOgrk3 -->
|
||||
{"\u03B5", "ε"}, // greek small letter epsilon,U+03B5 ISOgrk3 -->
|
||||
{"\u03B3", "γ"}, // greek small letter gamma, U+03B3 ISOgrk3 -->
|
||||
{"\u03B4", "δ"}, // greek small letter delta, U+03B4 ISOgrk3 -->
|
||||
{"\u03B5", "ε"}, // greek small letter epsilon, U+03B5 ISOgrk3 -->
|
||||
{"\u03B6", "ζ"}, // greek small letter zeta, U+03B6 ISOgrk3 -->
|
||||
{"\u03B7", "η"}, // greek small letter eta, U+03B7 ISOgrk3 -->
|
||||
{"\u03B8", "θ"}, // greek small letter theta,U+03B8 ISOgrk3 -->
|
||||
{"\u03B8", "θ"}, // greek small letter theta, U+03B8 ISOgrk3 -->
|
||||
{"\u03B9", "ι"}, // greek small letter iota, U+03B9 ISOgrk3 -->
|
||||
{"\u03BA", "κ"}, // greek small letter kappa,U+03BA ISOgrk3 -->
|
||||
{"\u03BB", "λ"}, // greek small letter lambda,U+03BB ISOgrk3 -->
|
||||
{"\u03BA", "κ"}, // greek small letter kappa, U+03BA ISOgrk3 -->
|
||||
{"\u03BB", "λ"}, // greek small letter lambda, U+03BB ISOgrk3 -->
|
||||
{"\u03BC", "μ"}, // greek small letter mu, U+03BC ISOgrk3 -->
|
||||
{"\u03BD", "ν"}, // greek small letter nu, U+03BD ISOgrk3 -->
|
||||
{"\u03BE", "ξ"}, // greek small letter xi, U+03BE ISOgrk3 -->
|
||||
{"\u03BF", "ο"}, // greek small letter omicron, U+03BF NEW -->
|
||||
{"\u03C0", "π"}, // greek small letter pi, U+03C0 ISOgrk3 -->
|
||||
{"\u03C1", "ρ"}, // greek small letter rho, U+03C1 ISOgrk3 -->
|
||||
{"\u03C2", "ς"}, // greek small letter final sigma,U+03C2 ISOgrk3 -->
|
||||
{"\u03C3", "σ"}, // greek small letter sigma,U+03C3 ISOgrk3 -->
|
||||
{"\u03C2", "ς"}, // greek small letter final sigma, U+03C2 ISOgrk3 -->
|
||||
{"\u03C3", "σ"}, // greek small letter sigma, U+03C3 ISOgrk3 -->
|
||||
{"\u03C4", "τ"}, // greek small letter tau, U+03C4 ISOgrk3 -->
|
||||
{"\u03C5", "υ"}, // greek small letter upsilon,U+03C5 ISOgrk3 -->
|
||||
{"\u03C5", "υ"}, // greek small letter upsilon, U+03C5 ISOgrk3 -->
|
||||
{"\u03C6", "φ"}, // greek small letter phi, U+03C6 ISOgrk3 -->
|
||||
{"\u03C7", "χ"}, // greek small letter chi, U+03C7 ISOgrk3 -->
|
||||
{"\u03C8", "ψ"}, // greek small letter psi, U+03C8 ISOgrk3 -->
|
||||
{"\u03C9", "ω"}, // greek small letter omega,U+03C9 ISOgrk3 -->
|
||||
{"\u03D1", "ϑ"}, // greek small letter theta symbol,U+03D1 NEW -->
|
||||
{"\u03D2", "ϒ"}, // greek upsilon with hook symbol,U+03D2 NEW -->
|
||||
{"\u03C9", "ω"}, // greek small letter omega, U+03C9 ISOgrk3 -->
|
||||
{"\u03D1", "ϑ"}, // greek small letter theta symbol, U+03D1 NEW -->
|
||||
{"\u03D2", "ϒ"}, // greek upsilon with hook symbol, U+03D2 NEW -->
|
||||
{"\u03D6", "ϖ"}, // greek pi symbol, U+03D6 ISOgrk3 -->
|
||||
// <!-- General Punctuation -->
|
||||
{"\u2022", "•"}, // bullet = black small circle,U+2022 ISOpub -->
|
||||
{"\u2022", "•"}, // bullet = black small circle, U+2022 ISOpub -->
|
||||
// <!-- bullet is NOT the same as bullet operator, U+2219 -->
|
||||
{"\u2026", "…"}, // horizontal ellipsis = three dot leader,U+2026 ISOpub -->
|
||||
{"\u2026", "…"}, // horizontal ellipsis = three dot leader, U+2026 ISOpub -->
|
||||
{"\u2032", "′"}, // prime = minutes = feet, U+2032 ISOtech -->
|
||||
{"\u2033", "″"}, // double prime = seconds = inches,U+2033 ISOtech -->
|
||||
{"\u203E", "‾"}, // overline = spacing overscore,U+203E NEW -->
|
||||
{"\u2033", "″"}, // double prime = seconds = inches, U+2033 ISOtech -->
|
||||
{"\u203E", "‾"}, // overline = spacing overscore, U+203E NEW -->
|
||||
{"\u2044", "⁄"}, // fraction slash, U+2044 NEW -->
|
||||
// <!-- Letterlike Symbols -->
|
||||
{"\u2118", "℘"}, // script capital P = power set= Weierstrass p, U+2118 ISOamso -->
|
||||
{"\u2111", "ℑ"}, // blackletter capital I = imaginary part,U+2111 ISOamso -->
|
||||
{"\u211C", "ℜ"}, // blackletter capital R = real part symbol,U+211C ISOamso -->
|
||||
{"\u2111", "ℑ"}, // blackletter capital I = imaginary part, U+2111 ISOamso -->
|
||||
{"\u211C", "ℜ"}, // blackletter capital R = real part symbol, U+211C ISOamso -->
|
||||
{"\u2122", "™"}, // trade mark sign, U+2122 ISOnum -->
|
||||
{"\u2135", "ℵ"}, // alef symbol = first transfinite cardinal,U+2135 NEW -->
|
||||
// <!-- alef symbol is NOT the same as hebrew letter alef,U+05D0 although the
|
||||
{"\u2135", "ℵ"}, // alef symbol = first transfinite cardinal, U+2135 NEW -->
|
||||
// <!-- alef symbol is NOT the same as hebrew letter alef, U+05D0 although the
|
||||
// same glyph could be used to depict both characters -->
|
||||
// <!-- Arrows -->
|
||||
{"\u2190", "←"}, // leftwards arrow, U+2190 ISOnum -->
|
||||
|
@ -242,23 +242,23 @@ public class EntityArrays {
|
|||
// arrow but also does not have any other character for that function.
|
||||
// So ? lArr canbe used for 'is implied by' as ISOtech suggests -->
|
||||
{"\u21D1", "⇑"}, // upwards double arrow, U+21D1 ISOamsa -->
|
||||
{"\u21D2", "⇒"}, // rightwards double arrow,U+21D2 ISOtech -->
|
||||
{"\u21D2", "⇒"}, // rightwards double arrow, U+21D2 ISOtech -->
|
||||
// <!-- ISO 10646 does not say this is the 'implies' character but does not
|
||||
// have another character with this function so ?rArr can be used for
|
||||
// 'implies' as ISOtech suggests -->
|
||||
{"\u21D3", "⇓"}, // downwards double arrow, U+21D3 ISOamsa -->
|
||||
{"\u21D4", "⇔"}, // left right double arrow,U+21D4 ISOamsa -->
|
||||
{"\u21D4", "⇔"}, // left right double arrow, U+21D4 ISOamsa -->
|
||||
// <!-- Mathematical Operators -->
|
||||
{"\u2200", "∀"}, // for all, U+2200 ISOtech -->
|
||||
{"\u2202", "∂"}, // partial differential, U+2202 ISOtech -->
|
||||
{"\u2203", "∃"}, // there exists, U+2203 ISOtech -->
|
||||
{"\u2205", "∅"}, // empty set = null set = diameter,U+2205 ISOamso -->
|
||||
{"\u2207", "∇"}, // nabla = backward difference,U+2207 ISOtech -->
|
||||
{"\u2205", "∅"}, // empty set = null set = diameter, U+2205 ISOamso -->
|
||||
{"\u2207", "∇"}, // nabla = backward difference, U+2207 ISOtech -->
|
||||
{"\u2208", "∈"}, // element of, U+2208 ISOtech -->
|
||||
{"\u2209", "∉"}, // not an element of, U+2209 ISOtech -->
|
||||
{"\u220B", "∋"}, // contains as member, U+220B ISOtech -->
|
||||
// <!-- should there be a more memorable name than 'ni'? -->
|
||||
{"\u220F", "∏"}, // n-ary product = product sign,U+220F ISOamsb -->
|
||||
{"\u220F", "∏"}, // n-ary product = product sign, U+220F ISOamsb -->
|
||||
// <!-- prod is NOT the same character as U+03A0 'greek capital letter pi'
|
||||
// though the same glyph might be used for both -->
|
||||
{"\u2211", "∑"}, // n-ary summation, U+2211 ISOamsb -->
|
||||
|
@ -266,7 +266,7 @@ public class EntityArrays {
|
|||
// though the same glyph might be used for both -->
|
||||
{"\u2212", "−"}, // minus sign, U+2212 ISOtech -->
|
||||
{"\u2217", "∗"}, // asterisk operator, U+2217 ISOtech -->
|
||||
{"\u221A", "√"}, // square root = radical sign,U+221A ISOtech -->
|
||||
{"\u221A", "√"}, // square root = radical sign, U+221A ISOtech -->
|
||||
{"\u221D", "∝"}, // proportional to, U+221D ISOtech -->
|
||||
{"\u221E", "∞"}, // infinity, U+221E ISOtech -->
|
||||
{"\u2220", "∠"}, // angle, U+2220 ISOamso -->
|
||||
|
@ -276,15 +276,15 @@ public class EntityArrays {
|
|||
{"\u222A", "∪"}, // union = cup, U+222A ISOtech -->
|
||||
{"\u222B", "∫"}, // integral, U+222B ISOtech -->
|
||||
{"\u2234", "∴"}, // therefore, U+2234 ISOtech -->
|
||||
{"\u223C", "∼"}, // tilde operator = varies with = similar to,U+223C ISOtech -->
|
||||
// <!-- tilde operator is NOT the same character as the tilde, U+007E,although
|
||||
{"\u223C", "∼"}, // tilde operator = varies with = similar to, U+223C ISOtech -->
|
||||
// <!-- tilde operator is NOT the same character as the tilde, U+007E, although
|
||||
// the same glyph might be used to represent both -->
|
||||
{"\u2245", "≅"}, // approximately equal to, U+2245 ISOtech -->
|
||||
{"\u2248", "≈"}, // almost equal to = asymptotic to,U+2248 ISOamsr -->
|
||||
{"\u2248", "≈"}, // almost equal to = asymptotic to, U+2248 ISOamsr -->
|
||||
{"\u2260", "≠"}, // not equal to, U+2260 ISOtech -->
|
||||
{"\u2261", "≡"}, // identical to, U+2261 ISOtech -->
|
||||
{"\u2264", "≤"}, // less-than or equal to, U+2264 ISOtech -->
|
||||
{"\u2265", "≥"}, // greater-than or equal to,U+2265 ISOtech -->
|
||||
{"\u2265", "≥"}, // greater-than or equal to, U+2265 ISOtech -->
|
||||
{"\u2282", "⊂"}, // subset of, U+2282 ISOtech -->
|
||||
{"\u2283", "⊃"}, // superset of, U+2283 ISOtech -->
|
||||
// <!-- note that nsup, 'not a superset of, U+2283' is not covered by the
|
||||
|
@ -292,21 +292,21 @@ public class EntityArrays {
|
|||
// It is in ISOamsn -->,
|
||||
{"\u2284", "⊄"}, // not a subset of, U+2284 ISOamsn -->
|
||||
{"\u2286", "⊆"}, // subset of or equal to, U+2286 ISOtech -->
|
||||
{"\u2287", "⊇"}, // superset of or equal to,U+2287 ISOtech -->
|
||||
{"\u2295", "⊕"}, // circled plus = direct sum,U+2295 ISOamsb -->
|
||||
{"\u2297", "⊗"}, // circled times = vector product,U+2297 ISOamsb -->
|
||||
{"\u22A5", "⊥"}, // up tack = orthogonal to = perpendicular,U+22A5 ISOtech -->
|
||||
{"\u2287", "⊇"}, // superset of or equal to, U+2287 ISOtech -->
|
||||
{"\u2295", "⊕"}, // circled plus = direct sum, U+2295 ISOamsb -->
|
||||
{"\u2297", "⊗"}, // circled times = vector product, U+2297 ISOamsb -->
|
||||
{"\u22A5", "⊥"}, // up tack = orthogonal to = perpendicular, U+22A5 ISOtech -->
|
||||
{"\u22C5", "⋅"}, // dot operator, U+22C5 ISOamsb -->
|
||||
// <!-- dot operator is NOT the same character as U+00B7 middle dot -->
|
||||
// <!-- Miscellaneous Technical -->
|
||||
{"\u2308", "⌈"}, // left ceiling = apl upstile,U+2308 ISOamsc -->
|
||||
{"\u2308", "⌈"}, // left ceiling = apl upstile, U+2308 ISOamsc -->
|
||||
{"\u2309", "⌉"}, // right ceiling, U+2309 ISOamsc -->
|
||||
{"\u230A", "⌊"}, // left floor = apl downstile,U+230A ISOamsc -->
|
||||
{"\u230A", "⌊"}, // left floor = apl downstile, U+230A ISOamsc -->
|
||||
{"\u230B", "⌋"}, // right floor, U+230B ISOamsc -->
|
||||
{"\u2329", "⟨"}, // left-pointing angle bracket = bra,U+2329 ISOtech -->
|
||||
{"\u2329", "⟨"}, // left-pointing angle bracket = bra, U+2329 ISOtech -->
|
||||
// <!-- lang is NOT the same character as U+003C 'less than' or U+2039 'single left-pointing angle quotation
|
||||
// mark' -->
|
||||
{"\u232A", "⟩"}, // right-pointing angle bracket = ket,U+232A ISOtech -->
|
||||
{"\u232A", "⟩"}, // right-pointing angle bracket = ket, U+232A ISOtech -->
|
||||
// <!-- rang is NOT the same character as U+003E 'greater than' or U+203A
|
||||
// 'single right-pointing angle quotation mark' -->
|
||||
// <!-- Geometric Shapes -->
|
||||
|
@ -314,42 +314,42 @@ public class EntityArrays {
|
|||
// <!-- Miscellaneous Symbols -->
|
||||
{"\u2660", "♠"}, // black spade suit, U+2660 ISOpub -->
|
||||
// <!-- black here seems to mean filled as opposed to hollow -->
|
||||
{"\u2663", "♣"}, // black club suit = shamrock,U+2663 ISOpub -->
|
||||
{"\u2665", "♥"}, // black heart suit = valentine,U+2665 ISOpub -->
|
||||
{"\u2663", "♣"}, // black club suit = shamrock, U+2663 ISOpub -->
|
||||
{"\u2665", "♥"}, // black heart suit = valentine, U+2665 ISOpub -->
|
||||
{"\u2666", "♦"}, // black diamond suit, U+2666 ISOpub -->
|
||||
|
||||
// <!-- Latin Extended-A -->
|
||||
{"\u0152", "Œ"}, // -- latin capital ligature OE,U+0152 ISOlat2 -->
|
||||
{"\u0152", "Œ"}, // -- latin capital ligature OE, U+0152 ISOlat2 -->
|
||||
{"\u0153", "œ"}, // -- latin small ligature oe, U+0153 ISOlat2 -->
|
||||
// <!-- ligature is a misnomer, this is a separate character in some languages -->
|
||||
{"\u0160", "Š"}, // -- latin capital letter S with caron,U+0160 ISOlat2 -->
|
||||
{"\u0161", "š"}, // -- latin small letter s with caron,U+0161 ISOlat2 -->
|
||||
{"\u0178", "Ÿ"}, // -- latin capital letter Y with diaeresis,U+0178 ISOlat2 -->
|
||||
{"\u0160", "Š"}, // -- latin capital letter S with caron, U+0160 ISOlat2 -->
|
||||
{"\u0161", "š"}, // -- latin small letter s with caron, U+0161 ISOlat2 -->
|
||||
{"\u0178", "Ÿ"}, // -- latin capital letter Y with diaeresis, U+0178 ISOlat2 -->
|
||||
// <!-- Spacing Modifier Letters -->
|
||||
{"\u02C6", "ˆ"}, // -- modifier letter circumflex accent,U+02C6 ISOpub -->
|
||||
{"\u02C6", "ˆ"}, // -- modifier letter circumflex accent, U+02C6 ISOpub -->
|
||||
{"\u02DC", "˜"}, // small tilde, U+02DC ISOdia -->
|
||||
// <!-- General Punctuation -->
|
||||
{"\u2002", " "}, // en space, U+2002 ISOpub -->
|
||||
{"\u2003", " "}, // em space, U+2003 ISOpub -->
|
||||
{"\u2009", " "}, // thin space, U+2009 ISOpub -->
|
||||
{"\u200C", "‌"}, // zero width non-joiner,U+200C NEW RFC 2070 -->
|
||||
{"\u200C", "‌"}, // zero width non-joiner, U+200C NEW RFC 2070 -->
|
||||
{"\u200D", "‍"}, // zero width joiner, U+200D NEW RFC 2070 -->
|
||||
{"\u200E", "‎"}, // left-to-right mark, U+200E NEW RFC 2070 -->
|
||||
{"\u200F", "‏"}, // right-to-left mark, U+200F NEW RFC 2070 -->
|
||||
{"\u2013", "–"}, // en dash, U+2013 ISOpub -->
|
||||
{"\u2014", "—"}, // em dash, U+2014 ISOpub -->
|
||||
{"\u2018", "‘"}, // left single quotation mark,U+2018 ISOnum -->
|
||||
{"\u2019", "’"}, // right single quotation mark,U+2019 ISOnum -->
|
||||
{"\u2018", "‘"}, // left single quotation mark, U+2018 ISOnum -->
|
||||
{"\u2019", "’"}, // right single quotation mark, U+2019 ISOnum -->
|
||||
{"\u201A", "‚"}, // single low-9 quotation mark, U+201A NEW -->
|
||||
{"\u201C", "“"}, // left double quotation mark,U+201C ISOnum -->
|
||||
{"\u201D", "”"}, // right double quotation mark,U+201D ISOnum -->
|
||||
{"\u201C", "“"}, // left double quotation mark, U+201C ISOnum -->
|
||||
{"\u201D", "”"}, // right double quotation mark, U+201D ISOnum -->
|
||||
{"\u201E", "„"}, // double low-9 quotation mark, U+201E NEW -->
|
||||
{"\u2020", "†"}, // dagger, U+2020 ISOpub -->
|
||||
{"\u2021", "‡"}, // double dagger, U+2021 ISOpub -->
|
||||
{"\u2030", "‰"}, // per mille sign, U+2030 ISOtech -->
|
||||
{"\u2039", "‹"}, // single left-pointing angle quotation mark,U+2039 ISO proposed -->
|
||||
{"\u2039", "‹"}, // single left-pointing angle quotation mark, U+2039 ISO proposed -->
|
||||
// <!-- lsaquo is proposed but not yet ISO standardized -->
|
||||
{"\u203A", "›"}, // single right-pointing angle quotation mark,U+203A ISO proposed -->
|
||||
{"\u203A", "›"}, // single right-pointing angle quotation mark, U+203A ISO proposed -->
|
||||
// <!-- rsaquo is proposed but not yet ISO standardized -->
|
||||
{"\u20AC", "€"}, // -- euro sign, U+20AC NEW -->
|
||||
};
|
||||
|
@ -448,7 +448,7 @@ public class EntityArrays {
|
|||
*/
|
||||
public static String[][] invert(final String[][] array) {
|
||||
final String[][] newarray = new String[array.length][2];
|
||||
for(int i = 0; i<array.length; i++) {
|
||||
for (int i = 0; i<array.length; i++) {
|
||||
newarray[i][0] = array[i][1];
|
||||
newarray[i][1] = array[i][0];
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ public class NumericEntityEscaper extends CodePointTranslator {
|
|||
*/
|
||||
@Override
|
||||
public boolean translate(final int codepoint, final Writer out) throws IOException {
|
||||
if(between) {
|
||||
if (between) {
|
||||
if (codepoint < below || codepoint > above) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class NumericEntityUnescaper extends CharSequenceTranslator {
|
|||
* @param options to apply to this unescaper
|
||||
*/
|
||||
public NumericEntityUnescaper(final OPTION... options) {
|
||||
if(options.length > 0) {
|
||||
if (options.length > 0) {
|
||||
this.options = EnumSet.copyOf(Arrays.asList(options));
|
||||
} else {
|
||||
this.options = EnumSet.copyOf(Arrays.asList(new OPTION[] { OPTION.semiColonRequired }));
|
||||
|
@ -81,24 +81,24 @@ public class NumericEntityUnescaper extends CharSequenceTranslator {
|
|||
public int translate(final CharSequence input, final int index, final Writer out) throws IOException {
|
||||
final int seqEnd = input.length();
|
||||
// Uses -2 to ensure there is something after the &#
|
||||
if(input.charAt(index) == '&' && index < seqEnd - 2 && input.charAt(index + 1) == '#') {
|
||||
if (input.charAt(index) == '&' && index < seqEnd - 2 && input.charAt(index + 1) == '#') {
|
||||
int start = index + 2;
|
||||
boolean isHex = false;
|
||||
|
||||
final char firstChar = input.charAt(start);
|
||||
if(firstChar == 'x' || firstChar == 'X') {
|
||||
if (firstChar == 'x' || firstChar == 'X') {
|
||||
start++;
|
||||
isHex = true;
|
||||
|
||||
// Check there's more than just an x after the &#
|
||||
if(start == seqEnd) {
|
||||
if (start == seqEnd) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int end = start;
|
||||
// Note that this supports character codes without a ; on the end
|
||||
while(end < seqEnd && ( input.charAt(end) >= '0' && input.charAt(end) <= '9' ||
|
||||
while (end < seqEnd && ( input.charAt(end) >= '0' && input.charAt(end) <= '9' ||
|
||||
input.charAt(end) >= 'a' && input.charAt(end) <= 'f' ||
|
||||
input.charAt(end) >= 'A' && input.charAt(end) <= 'F' ) ) {
|
||||
end++;
|
||||
|
@ -106,18 +106,18 @@ public class NumericEntityUnescaper extends CharSequenceTranslator {
|
|||
|
||||
final boolean semiNext = end != seqEnd && input.charAt(end) == ';';
|
||||
|
||||
if(!semiNext) {
|
||||
if(isSet(OPTION.semiColonRequired)) {
|
||||
if (!semiNext) {
|
||||
if (isSet(OPTION.semiColonRequired)) {
|
||||
return 0;
|
||||
} else
|
||||
if(isSet(OPTION.errorIfNoSemiColon)) {
|
||||
if (isSet(OPTION.errorIfNoSemiColon)) {
|
||||
throw new IllegalArgumentException("Semi-colon required at end of numeric entity");
|
||||
}
|
||||
}
|
||||
|
||||
int entityValue;
|
||||
try {
|
||||
if(isHex) {
|
||||
if (isHex) {
|
||||
entityValue = Integer.parseInt(input.subSequence(start, end).toString(), 16);
|
||||
} else {
|
||||
entityValue = Integer.parseInt(input.subSequence(start, end).toString(), 10);
|
||||
|
@ -126,7 +126,7 @@ public class NumericEntityUnescaper extends CharSequenceTranslator {
|
|||
return 0;
|
||||
}
|
||||
|
||||
if(entityValue > 0xFFFF) {
|
||||
if (entityValue > 0xFFFF) {
|
||||
final char[] chars = Character.toChars(entityValue);
|
||||
out.write(chars[0]);
|
||||
out.write(chars[1]);
|
||||
|
|
|
@ -42,7 +42,7 @@ public class OctalUnescaper extends CharSequenceTranslator {
|
|||
public int translate(final CharSequence input, final int index, final Writer out) throws IOException {
|
||||
final int remaining = input.length() - index - 1; // how many characters left, ignoring the first \
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
if(input.charAt(index) == '\\' && remaining > 0 && isOctalDigit(input.charAt(index + 1)) ) {
|
||||
if (input.charAt(index) == '\\' && remaining > 0 && isOctalDigit(input.charAt(index + 1)) ) {
|
||||
final int next = index + 1;
|
||||
final int next2 = index + 2;
|
||||
final int next3 = index + 3;
|
||||
|
@ -50,9 +50,9 @@ public class OctalUnescaper extends CharSequenceTranslator {
|
|||
// we know this is good as we checked it in the if block above
|
||||
builder.append(input.charAt(next));
|
||||
|
||||
if(remaining > 1 && isOctalDigit(input.charAt(next2))) {
|
||||
if (remaining > 1 && isOctalDigit(input.charAt(next2))) {
|
||||
builder.append(input.charAt(next2));
|
||||
if(remaining > 2 && isZeroToThree(input.charAt(next)) && isOctalDigit(input.charAt(next3))) {
|
||||
if (remaining > 2 && isZeroToThree(input.charAt(next)) && isOctalDigit(input.charAt(next3))) {
|
||||
builder.append(input.charAt(next3));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public class UnicodeEscaper extends CodePointTranslator {
|
|||
/**
|
||||
* <p>Constructs a <code>UnicodeEscaper</code> for all characters. </p>
|
||||
*/
|
||||
public UnicodeEscaper(){
|
||||
public UnicodeEscaper() {
|
||||
this(0, Integer.MAX_VALUE, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -1662,7 +1662,7 @@ public class DateUtils {
|
|||
* @since 2.4
|
||||
*/
|
||||
private static long getFragment(final Calendar calendar, final int fragment, final TimeUnit unit) {
|
||||
if(calendar == null) {
|
||||
if (calendar == null) {
|
||||
throw new IllegalArgumentException("The date must not be null");
|
||||
}
|
||||
|
||||
|
@ -1701,7 +1701,7 @@ public class DateUtils {
|
|||
case Calendar.SECOND:
|
||||
result += unit.convert(calendar.get(Calendar.MILLISECOND), TimeUnit.MILLISECONDS);
|
||||
break;
|
||||
case Calendar.MILLISECOND: break;//never useful
|
||||
case Calendar.MILLISECOND: break; //never useful
|
||||
default: throw new IllegalArgumentException("The fragment " + fragment + " is not supported");
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -344,7 +344,7 @@ public class DurationFormatUtils {
|
|||
} else {
|
||||
// there are no M's in the format string
|
||||
|
||||
if( !Token.containsTokenWithValue(tokens, y) ) {
|
||||
if ( !Token.containsTokenWithValue(tokens, y) ) {
|
||||
int target = end.get(Calendar.YEAR);
|
||||
if (months < 0) {
|
||||
// target is end-year -1
|
||||
|
@ -369,7 +369,7 @@ public class DurationFormatUtils {
|
|||
years = 0;
|
||||
}
|
||||
|
||||
while( start.get(Calendar.MONTH) != end.get(Calendar.MONTH) ) {
|
||||
while ( start.get(Calendar.MONTH) != end.get(Calendar.MONTH) ) {
|
||||
days += start.getActualMaximum(Calendar.DAY_OF_MONTH);
|
||||
start.add(Calendar.MONTH, 1);
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ public class FastDateParser implements DateParser, Serializable {
|
|||
*/
|
||||
private static final long serialVersionUID = 3L;
|
||||
|
||||
static final Locale JAPANESE_IMPERIAL = new Locale("ja","JP","JP");
|
||||
static final Locale JAPANESE_IMPERIAL = new Locale("ja", "JP", "JP");
|
||||
|
||||
// defining fields
|
||||
private final String pattern;
|
||||
|
@ -135,10 +135,10 @@ public class FastDateParser implements DateParser, Serializable {
|
|||
final Calendar definingCalendar = Calendar.getInstance(timeZone, locale);
|
||||
|
||||
int centuryStartYear;
|
||||
if(centuryStart!=null) {
|
||||
if (centuryStart!=null) {
|
||||
definingCalendar.setTime(centuryStart);
|
||||
centuryStartYear= definingCalendar.get(Calendar.YEAR);
|
||||
} else if(locale.equals(JAPANESE_IMPERIAL)) {
|
||||
} else if (locale.equals(JAPANESE_IMPERIAL)) {
|
||||
centuryStartYear= 0;
|
||||
} else {
|
||||
// from 80 years ago to 20 years from now
|
||||
|
@ -161,9 +161,9 @@ public class FastDateParser implements DateParser, Serializable {
|
|||
patterns = new ArrayList<>();
|
||||
|
||||
final StrategyParser fm = new StrategyParser(definingCalendar);
|
||||
for(;;) {
|
||||
for (;;) {
|
||||
final StrategyAndWidth field = fm.getNextStrategy();
|
||||
if(field==null) {
|
||||
if (field==null) {
|
||||
break;
|
||||
}
|
||||
patterns.add(field);
|
||||
|
@ -186,7 +186,7 @@ public class FastDateParser implements DateParser, Serializable {
|
|||
}
|
||||
|
||||
int getMaxWidth(final ListIterator<StrategyAndWidth> lt) {
|
||||
if(!strategy.isNumber() || !lt.hasNext()) {
|
||||
if (!strategy.isNumber() || !lt.hasNext()) {
|
||||
return 0;
|
||||
}
|
||||
final Strategy nextStrategy = lt.next().strategy;
|
||||
|
@ -448,7 +448,7 @@ public class FastDateParser implements DateParser, Serializable {
|
|||
sb.append(c);
|
||||
}
|
||||
}
|
||||
if(sb.charAt(sb.length() - 1) == '.') {
|
||||
if (sb.charAt(sb.length() - 1) == '.') {
|
||||
// trailing '.' is optional
|
||||
sb.append('?');
|
||||
}
|
||||
|
@ -719,7 +719,7 @@ public class FastDateParser implements DateParser, Serializable {
|
|||
void setCalendar(final FastDateParser parser, final Calendar cal, final String value) {
|
||||
final String lowerCase = value.toLowerCase(locale);
|
||||
Integer iVal = lKeyValues.get(lowerCase);
|
||||
if(iVal == null) {
|
||||
if (iVal == null) {
|
||||
// match missing the optional trailing period
|
||||
iVal = lKeyValues.get(lowerCase + '.');
|
||||
}
|
||||
|
|
|
@ -488,7 +488,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
|
|||
public StringBuffer format(final long millis, final StringBuffer buf) {
|
||||
final Calendar c = newCalendar();
|
||||
c.setTimeInMillis(millis);
|
||||
return (StringBuffer) applyRules(c, (Appendable)buf);
|
||||
return (StringBuffer) applyRules(c, (Appendable) buf);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -498,7 +498,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
|
|||
public StringBuffer format(final Date date, final StringBuffer buf) {
|
||||
final Calendar c = newCalendar();
|
||||
c.setTime(date);
|
||||
return (StringBuffer) applyRules(c, (Appendable)buf);
|
||||
return (StringBuffer) applyRules(c, (Appendable) buf);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -536,8 +536,8 @@ public class FastDatePrinter implements DatePrinter, Serializable {
|
|||
@Override
|
||||
public <B extends Appendable> B format(Calendar calendar, final B buf) {
|
||||
// do not pass in calendar directly, this will cause TimeZone of FastDatePrinter to be ignored
|
||||
if(!calendar.getTimeZone().equals(mTimeZone)) {
|
||||
calendar = (Calendar)calendar.clone();
|
||||
if (!calendar.getTimeZone().equals(mTimeZone)) {
|
||||
calendar = (Calendar) calendar.clone();
|
||||
calendar.setTimeZone(mTimeZone);
|
||||
}
|
||||
return applyRules(calendar, buf);
|
||||
|
@ -555,7 +555,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
|
|||
*/
|
||||
@Deprecated
|
||||
protected StringBuffer applyRules(final Calendar calendar, final StringBuffer buf) {
|
||||
return (StringBuffer) applyRules(calendar, (Appendable)buf);
|
||||
return (StringBuffer) applyRules(calendar, (Appendable) buf);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -678,8 +678,8 @@ public class FastDatePrinter implements DatePrinter, Serializable {
|
|||
* @param value the value to append digits from.
|
||||
*/
|
||||
private static void appendDigits(final Appendable buffer, final int value) throws IOException {
|
||||
buffer.append((char)(value / 10 + '0'));
|
||||
buffer.append((char)(value % 10 + '0'));
|
||||
buffer.append((char) (value / 10 + '0'));
|
||||
buffer.append((char) (value % 10 + '0'));
|
||||
}
|
||||
|
||||
private static final int MAX_DIGITS = 10; // log10(Integer.MAX_VALUE) ~= 9.3
|
||||
|
@ -939,7 +939,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
|
|||
@Override
|
||||
public final void appendTo(final Appendable buffer, final int value) throws IOException {
|
||||
if (value < 10) {
|
||||
buffer.append((char)(value + '0'));
|
||||
buffer.append((char) (value + '0'));
|
||||
} else if (value < 100) {
|
||||
appendDigits(buffer, value);
|
||||
} else {
|
||||
|
@ -984,7 +984,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
|
|||
@Override
|
||||
public final void appendTo(final Appendable buffer, final int value) throws IOException {
|
||||
if (value < 10) {
|
||||
buffer.append((char)(value + '0'));
|
||||
buffer.append((char) (value + '0'));
|
||||
} else {
|
||||
appendDigits(buffer, value);
|
||||
}
|
||||
|
@ -1562,7 +1562,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
|
|||
return true;
|
||||
}
|
||||
if (obj instanceof TimeZoneDisplayKey) {
|
||||
final TimeZoneDisplayKey other = (TimeZoneDisplayKey)obj;
|
||||
final TimeZoneDisplayKey other = (TimeZoneDisplayKey) obj;
|
||||
return
|
||||
mTimeZone.equals(other.mTimeZone) &&
|
||||
mStyle == other.mStyle &&
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.apache.commons.lang3.Validate;
|
|||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
// TODO: Before making public move from getDateTimeInstance(Integer,...) to int; or some other approach.
|
||||
// TODO: Before making public move from getDateTimeInstance(Integer, ...) to int; or some other approach.
|
||||
abstract class FormatCache<F extends Format> {
|
||||
|
||||
/**
|
||||
|
@ -201,7 +201,7 @@ abstract class FormatCache<F extends Format> {
|
|||
} else {
|
||||
formatter = DateFormat.getDateTimeInstance(dateStyle.intValue(), timeStyle.intValue(), locale);
|
||||
}
|
||||
pattern = ((SimpleDateFormat)formatter).toPattern();
|
||||
pattern = ((SimpleDateFormat) formatter).toPattern();
|
||||
final String previous = cDateTimeInstanceCache.putIfAbsent(key, pattern);
|
||||
if (previous != null) {
|
||||
// even though it doesn't matter if another thread put the pattern
|
||||
|
@ -240,7 +240,7 @@ abstract class FormatCache<F extends Format> {
|
|||
// Eliminate the usual boilerplate because
|
||||
// this inner static class is only used in a generic ConcurrentHashMap
|
||||
// which will not compare against other Object types
|
||||
return Arrays.equals(keys, ((MultipartKey)obj).keys);
|
||||
return Arrays.equals(keys, ((MultipartKey) obj).keys);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -248,10 +248,10 @@ abstract class FormatCache<F extends Format> {
|
|||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if(hashCode==0) {
|
||||
if (hashCode==0) {
|
||||
int rc= 0;
|
||||
for(final Object key : keys) {
|
||||
if(key!=null) {
|
||||
for (final Object key : keys) {
|
||||
if (key!=null) {
|
||||
rc= rc*7 + key.hashCode();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,12 +34,12 @@ import org.junit.jupiter.api.Test;
|
|||
public class ArrayUtilsAddTest {
|
||||
|
||||
@Test
|
||||
public void testJira567(){
|
||||
public void testJira567() {
|
||||
Number[] n;
|
||||
// Valid array construction
|
||||
n = ArrayUtils.addAll(new Number[]{Integer.valueOf(1)}, new Long[]{Long.valueOf(2)});
|
||||
assertEquals(2,n.length);
|
||||
assertEquals(Number.class,n.getClass().getComponentType());
|
||||
assertEquals(2, n.length);
|
||||
assertEquals(Number.class, n.getClass().getComponentType());
|
||||
// Invalid - can't store Long in Integer array
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> ArrayUtils.addAll(new Integer[]{Integer.valueOf(1)}, new Long[]{Long.valueOf(2)}));
|
||||
|
@ -63,17 +63,17 @@ public class ArrayUtilsAddTest {
|
|||
@Test
|
||||
public void testAddObjectArrayByte() {
|
||||
byte[] newArray;
|
||||
newArray = ArrayUtils.add((byte[])null, (byte)0);
|
||||
newArray = ArrayUtils.add((byte[]) null, (byte) 0);
|
||||
assertTrue(Arrays.equals(new byte[]{0}, newArray));
|
||||
assertEquals(Byte.TYPE, newArray.getClass().getComponentType());
|
||||
newArray = ArrayUtils.add((byte[])null, (byte)1);
|
||||
newArray = ArrayUtils.add((byte[]) null, (byte) 1);
|
||||
assertTrue(Arrays.equals(new byte[]{1}, newArray));
|
||||
assertEquals(Byte.TYPE, newArray.getClass().getComponentType());
|
||||
final byte[] array1 = new byte[]{1, 2, 3};
|
||||
newArray = ArrayUtils.add(array1, (byte)0);
|
||||
newArray = ArrayUtils.add(array1, (byte) 0);
|
||||
assertTrue(Arrays.equals(new byte[]{1, 2, 3, 0}, newArray));
|
||||
assertEquals(Byte.TYPE, newArray.getClass().getComponentType());
|
||||
newArray = ArrayUtils.add(array1, (byte)4);
|
||||
newArray = ArrayUtils.add(array1, (byte) 4);
|
||||
assertTrue(Arrays.equals(new byte[]{1, 2, 3, 4}, newArray));
|
||||
assertEquals(Byte.TYPE, newArray.getClass().getComponentType());
|
||||
}
|
||||
|
@ -81,17 +81,17 @@ public class ArrayUtilsAddTest {
|
|||
@Test
|
||||
public void testAddObjectArrayChar() {
|
||||
char[] newArray;
|
||||
newArray = ArrayUtils.add((char[])null, (char)0);
|
||||
newArray = ArrayUtils.add((char[]) null, (char) 0);
|
||||
assertTrue(Arrays.equals(new char[]{0}, newArray));
|
||||
assertEquals(Character.TYPE, newArray.getClass().getComponentType());
|
||||
newArray = ArrayUtils.add((char[])null, (char)1);
|
||||
newArray = ArrayUtils.add((char[]) null, (char) 1);
|
||||
assertTrue(Arrays.equals(new char[]{1}, newArray));
|
||||
assertEquals(Character.TYPE, newArray.getClass().getComponentType());
|
||||
final char[] array1 = new char[]{1, 2, 3};
|
||||
newArray = ArrayUtils.add(array1, (char)0);
|
||||
newArray = ArrayUtils.add(array1, (char) 0);
|
||||
assertTrue(Arrays.equals(new char[]{1, 2, 3, 0}, newArray));
|
||||
assertEquals(Character.TYPE, newArray.getClass().getComponentType());
|
||||
newArray = ArrayUtils.add(array1, (char)4);
|
||||
newArray = ArrayUtils.add(array1, (char) 4);
|
||||
assertTrue(Arrays.equals(new char[]{1, 2, 3, 4}, newArray));
|
||||
assertEquals(Character.TYPE, newArray.getClass().getComponentType());
|
||||
}
|
||||
|
@ -99,10 +99,10 @@ public class ArrayUtilsAddTest {
|
|||
@Test
|
||||
public void testAddObjectArrayDouble() {
|
||||
double[] newArray;
|
||||
newArray = ArrayUtils.add((double[])null, 0);
|
||||
newArray = ArrayUtils.add((double[]) null, 0);
|
||||
assertTrue(Arrays.equals(new double[]{0}, newArray));
|
||||
assertEquals(Double.TYPE, newArray.getClass().getComponentType());
|
||||
newArray = ArrayUtils.add((double[])null, 1);
|
||||
newArray = ArrayUtils.add((double[]) null, 1);
|
||||
assertTrue(Arrays.equals(new double[]{1}, newArray));
|
||||
assertEquals(Double.TYPE, newArray.getClass().getComponentType());
|
||||
final double[] array1 = new double[]{1, 2, 3};
|
||||
|
@ -117,10 +117,10 @@ public class ArrayUtilsAddTest {
|
|||
@Test
|
||||
public void testAddObjectArrayFloat() {
|
||||
float[] newArray;
|
||||
newArray = ArrayUtils.add((float[])null, 0);
|
||||
newArray = ArrayUtils.add((float[]) null, 0);
|
||||
assertTrue(Arrays.equals(new float[]{0}, newArray));
|
||||
assertEquals(Float.TYPE, newArray.getClass().getComponentType());
|
||||
newArray = ArrayUtils.add((float[])null, 1);
|
||||
newArray = ArrayUtils.add((float[]) null, 1);
|
||||
assertTrue(Arrays.equals(new float[]{1}, newArray));
|
||||
assertEquals(Float.TYPE, newArray.getClass().getComponentType());
|
||||
final float[] array1 = new float[]{1, 2, 3};
|
||||
|
@ -135,10 +135,10 @@ public class ArrayUtilsAddTest {
|
|||
@Test
|
||||
public void testAddObjectArrayInt() {
|
||||
int[] newArray;
|
||||
newArray = ArrayUtils.add((int[])null, 0);
|
||||
newArray = ArrayUtils.add((int[]) null, 0);
|
||||
assertTrue(Arrays.equals(new int[]{0}, newArray));
|
||||
assertEquals(Integer.TYPE, newArray.getClass().getComponentType());
|
||||
newArray = ArrayUtils.add((int[])null, 1);
|
||||
newArray = ArrayUtils.add((int[]) null, 1);
|
||||
assertTrue(Arrays.equals(new int[]{1}, newArray));
|
||||
assertEquals(Integer.TYPE, newArray.getClass().getComponentType());
|
||||
final int[] array1 = new int[]{1, 2, 3};
|
||||
|
@ -153,10 +153,10 @@ public class ArrayUtilsAddTest {
|
|||
@Test
|
||||
public void testAddObjectArrayLong() {
|
||||
long[] newArray;
|
||||
newArray = ArrayUtils.add((long[])null, 0);
|
||||
newArray = ArrayUtils.add((long[]) null, 0);
|
||||
assertTrue(Arrays.equals(new long[]{0}, newArray));
|
||||
assertEquals(Long.TYPE, newArray.getClass().getComponentType());
|
||||
newArray = ArrayUtils.add((long[])null, 1);
|
||||
newArray = ArrayUtils.add((long[]) null, 1);
|
||||
assertTrue(Arrays.equals(new long[]{1}, newArray));
|
||||
assertEquals(Long.TYPE, newArray.getClass().getComponentType());
|
||||
final long[] array1 = new long[]{1, 2, 3};
|
||||
|
@ -171,17 +171,17 @@ public class ArrayUtilsAddTest {
|
|||
@Test
|
||||
public void testAddObjectArrayShort() {
|
||||
short[] newArray;
|
||||
newArray = ArrayUtils.add((short[])null, (short)0);
|
||||
newArray = ArrayUtils.add((short[]) null, (short) 0);
|
||||
assertTrue(Arrays.equals(new short[]{0}, newArray));
|
||||
assertEquals(Short.TYPE, newArray.getClass().getComponentType());
|
||||
newArray = ArrayUtils.add((short[])null, (short)1);
|
||||
newArray = ArrayUtils.add((short[]) null, (short) 1);
|
||||
assertTrue(Arrays.equals(new short[]{1}, newArray));
|
||||
assertEquals(Short.TYPE, newArray.getClass().getComponentType());
|
||||
final short[] array1 = new short[]{1, 2, 3};
|
||||
newArray = ArrayUtils.add(array1, (short)0);
|
||||
newArray = ArrayUtils.add(array1, (short) 0);
|
||||
assertTrue(Arrays.equals(new short[]{1, 2, 3, 0}, newArray));
|
||||
assertEquals(Short.TYPE, newArray.getClass().getComponentType());
|
||||
newArray = ArrayUtils.add(array1, (short)4);
|
||||
newArray = ArrayUtils.add(array1, (short) 4);
|
||||
assertTrue(Arrays.equals(new short[]{1, 2, 3, 4}, newArray));
|
||||
assertEquals(Short.TYPE, newArray.getClass().getComponentType());
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ public class ArrayUtilsAddTest {
|
|||
Object[] newArray;
|
||||
|
||||
//show that not casting is okay
|
||||
newArray = ArrayUtils.add((Object[])null, "a");
|
||||
newArray = ArrayUtils.add((Object[]) null, "a");
|
||||
assertTrue(Arrays.equals(new String[]{"a"}, newArray));
|
||||
assertTrue(Arrays.equals(new Object[]{"a"}, newArray));
|
||||
assertEquals(String.class, newArray.getClass().getComponentType());
|
||||
|
@ -224,7 +224,7 @@ public class ArrayUtilsAddTest {
|
|||
|
||||
@Test
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testLANG571(){
|
||||
public void testLANG571() {
|
||||
final String[] stringArray=null;
|
||||
final String aString=null;
|
||||
assertThrows(IllegalArgumentException.class, () -> ArrayUtils.add(stringArray, aString));
|
||||
|
@ -353,7 +353,7 @@ public class ArrayUtilsAddTest {
|
|||
@Test
|
||||
public void testAddObjectAtIndex() {
|
||||
Object[] newArray;
|
||||
newArray = ArrayUtils.add((Object[])null, 0, "a");
|
||||
newArray = ArrayUtils.add((Object[]) null, 0, "a");
|
||||
assertTrue(Arrays.equals(new String[]{"a"}, newArray));
|
||||
assertTrue(Arrays.equals(new Object[]{"a"}, newArray));
|
||||
assertEquals(String.class, newArray.getClass().getComponentType());
|
||||
|
|
|
@ -31,8 +31,8 @@ public class ArrayUtilsInsertTest {
|
|||
|
||||
@Test
|
||||
public void testInsertBooleans() {
|
||||
final boolean[] array = {true,false,true};
|
||||
final boolean[] values = {false,true,false};
|
||||
final boolean[] array = {true, false, true};
|
||||
final boolean[] values = {false, true, false};
|
||||
|
||||
final boolean[] result = ArrayUtils.insert(42, array, null);
|
||||
assertArrayEquals(array, result);
|
||||
|
@ -45,19 +45,19 @@ public class ArrayUtilsInsertTest {
|
|||
assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(-1, array, array));
|
||||
assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(array.length + 1, array, array));
|
||||
|
||||
assertArrayEquals(new boolean[]{false,true,false,true}, ArrayUtils.insert(0, array, false));
|
||||
assertArrayEquals(new boolean[]{true,false,false,true}, ArrayUtils.insert(1, array, false));
|
||||
assertArrayEquals(new boolean[]{true,false,true,false}, ArrayUtils.insert(array.length, array, false));
|
||||
assertArrayEquals(new boolean[]{false,true,false,true,false,true}, ArrayUtils.insert(0, array, values));
|
||||
assertArrayEquals(new boolean[]{true,false,true,false,false,true}, ArrayUtils.insert(1, array, values));
|
||||
assertArrayEquals(new boolean[]{true,false,true,false,true,false}, ArrayUtils.insert(array.length, array, values));
|
||||
assertArrayEquals(new boolean[]{false, true, false, true}, ArrayUtils.insert(0, array, false));
|
||||
assertArrayEquals(new boolean[]{true, false, false, true}, ArrayUtils.insert(1, array, false));
|
||||
assertArrayEquals(new boolean[]{true, false, true, false}, ArrayUtils.insert(array.length, array, false));
|
||||
assertArrayEquals(new boolean[]{false, true, false, true, false, true}, ArrayUtils.insert(0, array, values));
|
||||
assertArrayEquals(new boolean[]{true, false, true, false, false, true}, ArrayUtils.insert(1, array, values));
|
||||
assertArrayEquals(new boolean[]{true, false, true, false, true, false}, ArrayUtils.insert(array.length, array, values));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testInsertBytes() {
|
||||
final byte[] array = {1,2,3};
|
||||
final byte[] values = {4,5,6};
|
||||
final byte[] array = {1, 2, 3};
|
||||
final byte[] values = {4, 5, 6};
|
||||
|
||||
final byte[] result = ArrayUtils.insert(42, array, null);
|
||||
assertArrayEquals(array, result);
|
||||
|
@ -70,18 +70,18 @@ public class ArrayUtilsInsertTest {
|
|||
assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(-1, array, array));
|
||||
assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(array.length + 1, array, array));
|
||||
|
||||
assertArrayEquals(new byte[]{0,1,2,3}, ArrayUtils.insert(0, array, (byte) 0));
|
||||
assertArrayEquals(new byte[]{1,0,2,3}, ArrayUtils.insert(1, array, (byte) 0));
|
||||
assertArrayEquals(new byte[]{1,2,3,0}, ArrayUtils.insert(array.length, array, (byte) 0));
|
||||
assertArrayEquals(new byte[]{4,5,6,1,2,3}, ArrayUtils.insert(0, array, values));
|
||||
assertArrayEquals(new byte[]{1,4,5,6,2,3}, ArrayUtils.insert(1, array, values));
|
||||
assertArrayEquals(new byte[]{1,2,3,4,5,6}, ArrayUtils.insert(array.length, array, values));
|
||||
assertArrayEquals(new byte[]{0, 1, 2, 3}, ArrayUtils.insert(0, array, (byte) 0));
|
||||
assertArrayEquals(new byte[]{1, 0, 2, 3}, ArrayUtils.insert(1, array, (byte) 0));
|
||||
assertArrayEquals(new byte[]{1, 2, 3, 0}, ArrayUtils.insert(array.length, array, (byte) 0));
|
||||
assertArrayEquals(new byte[]{4, 5, 6, 1, 2, 3}, ArrayUtils.insert(0, array, values));
|
||||
assertArrayEquals(new byte[]{1, 4, 5, 6, 2, 3}, ArrayUtils.insert(1, array, values));
|
||||
assertArrayEquals(new byte[]{1, 2, 3, 4, 5, 6}, ArrayUtils.insert(array.length, array, values));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInsertChars() {
|
||||
final char[] array = {'a','b','c'};
|
||||
final char[] values = {'d','e','f'};
|
||||
final char[] array = {'a', 'b', 'c'};
|
||||
final char[] values = {'d', 'e', 'f'};
|
||||
|
||||
final char[] result = ArrayUtils.insert(42, array, null);
|
||||
assertArrayEquals(array, result);
|
||||
|
@ -94,18 +94,18 @@ public class ArrayUtilsInsertTest {
|
|||
assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(-1, array, array));
|
||||
assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(array.length + 1, array, array));
|
||||
|
||||
assertArrayEquals(new char[]{'z','a','b','c'}, ArrayUtils.insert(0, array, 'z'));
|
||||
assertArrayEquals(new char[]{'a','z','b','c'}, ArrayUtils.insert(1, array, 'z'));
|
||||
assertArrayEquals(new char[]{'a','b','c','z'}, ArrayUtils.insert(array.length, array, 'z'));
|
||||
assertArrayEquals(new char[]{'d','e','f','a','b','c'}, ArrayUtils.insert(0, array, values));
|
||||
assertArrayEquals(new char[]{'a','d','e','f','b','c'}, ArrayUtils.insert(1, array, values));
|
||||
assertArrayEquals(new char[]{'a','b','c','d','e','f'}, ArrayUtils.insert(array.length, array, values));
|
||||
assertArrayEquals(new char[]{'z', 'a', 'b', 'c'}, ArrayUtils.insert(0, array, 'z'));
|
||||
assertArrayEquals(new char[]{'a', 'z', 'b', 'c'}, ArrayUtils.insert(1, array, 'z'));
|
||||
assertArrayEquals(new char[]{'a', 'b', 'c', 'z'}, ArrayUtils.insert(array.length, array, 'z'));
|
||||
assertArrayEquals(new char[]{'d', 'e', 'f', 'a', 'b', 'c'}, ArrayUtils.insert(0, array, values));
|
||||
assertArrayEquals(new char[]{'a', 'd', 'e', 'f', 'b', 'c'}, ArrayUtils.insert(1, array, values));
|
||||
assertArrayEquals(new char[]{'a', 'b', 'c', 'd', 'e', 'f'}, ArrayUtils.insert(array.length, array, values));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInsertDoubles() {
|
||||
final double[] array = {1,2,3};
|
||||
final double[] values = {4,5,6};
|
||||
final double[] array = {1, 2, 3};
|
||||
final double[] values = {4, 5, 6};
|
||||
final double delta = 0.000001;
|
||||
|
||||
final double[] result = ArrayUtils.insert(42, array, null);
|
||||
|
@ -119,18 +119,18 @@ public class ArrayUtilsInsertTest {
|
|||
assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(-1, array, array));
|
||||
assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(array.length + 1, array, array));
|
||||
|
||||
assertArrayEquals(new double[]{0,1,2,3}, ArrayUtils.insert(0, array, 0), delta);
|
||||
assertArrayEquals(new double[]{1,0,2,3}, ArrayUtils.insert(1, array, 0), delta);
|
||||
assertArrayEquals(new double[]{1,2,3,0}, ArrayUtils.insert(array.length, array, 0), delta);
|
||||
assertArrayEquals(new double[]{4,5,6,1,2,3}, ArrayUtils.insert(0, array, values), delta);
|
||||
assertArrayEquals(new double[]{1,4,5,6,2,3}, ArrayUtils.insert(1, array, values), delta);
|
||||
assertArrayEquals(new double[]{1,2,3,4,5,6}, ArrayUtils.insert(array.length, array, values), delta);
|
||||
assertArrayEquals(new double[]{0, 1, 2, 3}, ArrayUtils.insert(0, array, 0), delta);
|
||||
assertArrayEquals(new double[]{1, 0, 2, 3}, ArrayUtils.insert(1, array, 0), delta);
|
||||
assertArrayEquals(new double[]{1, 2, 3, 0}, ArrayUtils.insert(array.length, array, 0), delta);
|
||||
assertArrayEquals(new double[]{4, 5, 6, 1, 2, 3}, ArrayUtils.insert(0, array, values), delta);
|
||||
assertArrayEquals(new double[]{1, 4, 5, 6, 2, 3}, ArrayUtils.insert(1, array, values), delta);
|
||||
assertArrayEquals(new double[]{1, 2, 3, 4, 5, 6}, ArrayUtils.insert(array.length, array, values), delta);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInsertFloats() {
|
||||
final float[] array = {1,2,3};
|
||||
final float[] values = {4,5,6};
|
||||
final float[] array = {1, 2, 3};
|
||||
final float[] values = {4, 5, 6};
|
||||
final float delta = 0.000001f;
|
||||
|
||||
final float[] result = ArrayUtils.insert(42, array, null);
|
||||
|
@ -144,18 +144,18 @@ public class ArrayUtilsInsertTest {
|
|||
assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(-1, array, array));
|
||||
assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(array.length + 1, array, array));
|
||||
|
||||
assertArrayEquals(new float[]{0,1,2,3}, ArrayUtils.insert(0, array, 0), delta);
|
||||
assertArrayEquals(new float[]{1,0,2,3}, ArrayUtils.insert(1, array, 0), delta);
|
||||
assertArrayEquals(new float[]{1,2,3,0}, ArrayUtils.insert(array.length, array, 0), delta);
|
||||
assertArrayEquals(new float[]{4,5,6,1,2,3}, ArrayUtils.insert(0, array, values), delta);
|
||||
assertArrayEquals(new float[]{1,4,5,6,2,3}, ArrayUtils.insert(1, array, values), delta);
|
||||
assertArrayEquals(new float[]{1,2,3,4,5,6}, ArrayUtils.insert(array.length, array, values), delta);
|
||||
assertArrayEquals(new float[]{0, 1, 2, 3}, ArrayUtils.insert(0, array, 0), delta);
|
||||
assertArrayEquals(new float[]{1, 0, 2, 3}, ArrayUtils.insert(1, array, 0), delta);
|
||||
assertArrayEquals(new float[]{1, 2, 3, 0}, ArrayUtils.insert(array.length, array, 0), delta);
|
||||
assertArrayEquals(new float[]{4, 5, 6, 1, 2, 3}, ArrayUtils.insert(0, array, values), delta);
|
||||
assertArrayEquals(new float[]{1, 4, 5, 6, 2, 3}, ArrayUtils.insert(1, array, values), delta);
|
||||
assertArrayEquals(new float[]{1, 2, 3, 4, 5, 6}, ArrayUtils.insert(array.length, array, values), delta);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInsertInts() {
|
||||
final int[] array = {1,2,3};
|
||||
final int[] values = {4,5,6};
|
||||
final int[] array = {1, 2, 3};
|
||||
final int[] values = {4, 5, 6};
|
||||
|
||||
final int[] result = ArrayUtils.insert(42, array, null);
|
||||
assertArrayEquals(array, result);
|
||||
|
@ -168,19 +168,19 @@ public class ArrayUtilsInsertTest {
|
|||
assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(-1, array, array));
|
||||
assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(array.length + 1, array, array));
|
||||
|
||||
assertArrayEquals(new int[]{0,1,2,3}, ArrayUtils.insert(0, array, 0));
|
||||
assertArrayEquals(new int[]{1,0,2,3}, ArrayUtils.insert(1, array, 0));
|
||||
assertArrayEquals(new int[]{1,2,3,0}, ArrayUtils.insert(array.length, array, 0));
|
||||
assertArrayEquals(new int[]{4,5,6,1,2,3}, ArrayUtils.insert(0, array, values));
|
||||
assertArrayEquals(new int[]{1,4,5,6,2,3}, ArrayUtils.insert(1, array, values));
|
||||
assertArrayEquals(new int[]{1,2,3,4,5,6}, ArrayUtils.insert(array.length, array, values));
|
||||
assertArrayEquals(new int[]{0, 1, 2, 3}, ArrayUtils.insert(0, array, 0));
|
||||
assertArrayEquals(new int[]{1, 0, 2, 3}, ArrayUtils.insert(1, array, 0));
|
||||
assertArrayEquals(new int[]{1, 2, 3, 0}, ArrayUtils.insert(array.length, array, 0));
|
||||
assertArrayEquals(new int[]{4, 5, 6, 1, 2, 3}, ArrayUtils.insert(0, array, values));
|
||||
assertArrayEquals(new int[]{1, 4, 5, 6, 2, 3}, ArrayUtils.insert(1, array, values));
|
||||
assertArrayEquals(new int[]{1, 2, 3, 4, 5, 6}, ArrayUtils.insert(array.length, array, values));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testInsertLongs() {
|
||||
final long[] array = {1,2,3};
|
||||
final long[] values = {4,5,6};
|
||||
final long[] array = {1, 2, 3};
|
||||
final long[] values = {4, 5, 6};
|
||||
|
||||
final long[] result = ArrayUtils.insert(42, array, null);
|
||||
assertArrayEquals(array, result);
|
||||
|
@ -193,19 +193,19 @@ public class ArrayUtilsInsertTest {
|
|||
assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(-1, array, array));
|
||||
assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(array.length + 1, array, array));
|
||||
|
||||
assertArrayEquals(new long[]{0,1,2,3}, ArrayUtils.insert(0, array, 0));
|
||||
assertArrayEquals(new long[]{1,0,2,3}, ArrayUtils.insert(1, array, 0));
|
||||
assertArrayEquals(new long[]{1,2,3,0}, ArrayUtils.insert(array.length, array, 0));
|
||||
assertArrayEquals(new long[]{4,5,6,1,2,3}, ArrayUtils.insert(0, array, values));
|
||||
assertArrayEquals(new long[]{1,4,5,6,2,3}, ArrayUtils.insert(1, array, values));
|
||||
assertArrayEquals(new long[]{1,2,3,4,5,6}, ArrayUtils.insert(array.length, array, values));
|
||||
assertArrayEquals(new long[]{0, 1, 2, 3}, ArrayUtils.insert(0, array, 0));
|
||||
assertArrayEquals(new long[]{1, 0, 2, 3}, ArrayUtils.insert(1, array, 0));
|
||||
assertArrayEquals(new long[]{1, 2, 3, 0}, ArrayUtils.insert(array.length, array, 0));
|
||||
assertArrayEquals(new long[]{4, 5, 6, 1, 2, 3}, ArrayUtils.insert(0, array, values));
|
||||
assertArrayEquals(new long[]{1, 4, 5, 6, 2, 3}, ArrayUtils.insert(1, array, values));
|
||||
assertArrayEquals(new long[]{1, 2, 3, 4, 5, 6}, ArrayUtils.insert(array.length, array, values));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testInsertShorts() {
|
||||
final short[] array = {1,2,3};
|
||||
final short[] values = {4,5,6};
|
||||
final short[] array = {1, 2, 3};
|
||||
final short[] values = {4, 5, 6};
|
||||
|
||||
final short[] result = ArrayUtils.insert(42, array, null);
|
||||
assertArrayEquals(array, result);
|
||||
|
@ -218,19 +218,19 @@ public class ArrayUtilsInsertTest {
|
|||
assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(-1, array, array));
|
||||
assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(array.length + 1, array, array));
|
||||
|
||||
assertArrayEquals(new short[]{0,1,2,3}, ArrayUtils.insert(0, array, (short) 0));
|
||||
assertArrayEquals(new short[]{1,0,2,3}, ArrayUtils.insert(1, array, (short) 0));
|
||||
assertArrayEquals(new short[]{1,2,3,0}, ArrayUtils.insert(array.length, array, (short) 0));
|
||||
assertArrayEquals(new short[]{4,5,6,1,2,3}, ArrayUtils.insert(0, array, values));
|
||||
assertArrayEquals(new short[]{1,4,5,6,2,3}, ArrayUtils.insert(1, array, values));
|
||||
assertArrayEquals(new short[]{1,2,3,4,5,6}, ArrayUtils.insert(array.length, array, values));
|
||||
assertArrayEquals(new short[]{0, 1, 2, 3}, ArrayUtils.insert(0, array, (short) 0));
|
||||
assertArrayEquals(new short[]{1, 0, 2, 3}, ArrayUtils.insert(1, array, (short) 0));
|
||||
assertArrayEquals(new short[]{1, 2, 3, 0}, ArrayUtils.insert(array.length, array, (short) 0));
|
||||
assertArrayEquals(new short[]{4, 5, 6, 1, 2, 3}, ArrayUtils.insert(0, array, values));
|
||||
assertArrayEquals(new short[]{1, 4, 5, 6, 2, 3}, ArrayUtils.insert(1, array, values));
|
||||
assertArrayEquals(new short[]{1, 2, 3, 4, 5, 6}, ArrayUtils.insert(array.length, array, values));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testInsertGenericArray() {
|
||||
final String[] array = {"a","b","c"};
|
||||
final String[] values = {"d","e","f"};
|
||||
final String[] array = {"a", "b", "c"};
|
||||
final String[] values = {"d", "e", "f"};
|
||||
|
||||
final String[] result = ArrayUtils.insert(42, array, (String[]) null);
|
||||
assertArrayEquals(array, result);
|
||||
|
@ -243,11 +243,11 @@ public class ArrayUtilsInsertTest {
|
|||
assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(-1, array, array));
|
||||
assertThrows(IndexOutOfBoundsException.class, () -> ArrayUtils.insert(array.length + 1, array, array));
|
||||
|
||||
assertArrayEquals(new String[]{"z","a","b","c"}, ArrayUtils.insert(0, array, "z"));
|
||||
assertArrayEquals(new String[]{"a","z","b","c"}, ArrayUtils.insert(1, array, "z"));
|
||||
assertArrayEquals(new String[]{"a","b","c","z"}, ArrayUtils.insert(array.length, array, "z"));
|
||||
assertArrayEquals(new String[]{"d","e","f","a","b","c"}, ArrayUtils.insert(0, array, values));
|
||||
assertArrayEquals(new String[]{"a","d","e","f","b","c"}, ArrayUtils.insert(1, array, values));
|
||||
assertArrayEquals(new String[]{"a","b","c","d","e","f"}, ArrayUtils.insert(array.length, array, values));
|
||||
assertArrayEquals(new String[]{"z", "a", "b", "c"}, ArrayUtils.insert(0, array, "z"));
|
||||
assertArrayEquals(new String[]{"a", "z", "b", "c"}, ArrayUtils.insert(1, array, "z"));
|
||||
assertArrayEquals(new String[]{"a", "b", "c", "z"}, ArrayUtils.insert(array.length, array, "z"));
|
||||
assertArrayEquals(new String[]{"d", "e", "f", "a", "b", "c"}, ArrayUtils.insert(0, array, values));
|
||||
assertArrayEquals(new String[]{"a", "d", "e", "f", "b", "c"}, ArrayUtils.insert(1, array, values));
|
||||
assertArrayEquals(new String[]{"a", "b", "c", "d", "e", "f"}, ArrayUtils.insert(array.length, array, values));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,8 +52,8 @@ public class ArrayUtilsRemoveTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveNumberArray(){
|
||||
final Number[] inarray = {Integer.valueOf(1),Long.valueOf(2),Byte.valueOf((byte) 3)};
|
||||
public void testRemoveNumberArray() {
|
||||
final Number[] inarray = {Integer.valueOf(1), Long.valueOf(2), Byte.valueOf((byte) 3)};
|
||||
assertEquals(3, inarray.length);
|
||||
Number[] outarray;
|
||||
outarray = ArrayUtils.remove(inarray, 1);
|
||||
|
|
|
@ -942,9 +942,9 @@ public class ArrayUtilsTest {
|
|||
public void testSubarrChar() {
|
||||
final char[] nullArray = null;
|
||||
final char[] array = {'a', 'b', 'c', 'd', 'e', 'f'};
|
||||
final char[] leftSubarray = {'a', 'b', 'c', 'd',};
|
||||
final char[] midSubarray = {'b', 'c', 'd', 'e',};
|
||||
final char[] rightSubarray = {'c', 'd', 'e', 'f',};
|
||||
final char[] leftSubarray = {'a', 'b', 'c', 'd'};
|
||||
final char[] midSubarray = {'b', 'c', 'd', 'e'};
|
||||
final char[] rightSubarray = {'c', 'd', 'e', 'f'};
|
||||
|
||||
assertTrue(ArrayUtils.isEquals(leftSubarray, ArrayUtils.subarray(array, 0, 4)), "0 start, mid end");
|
||||
assertTrue(ArrayUtils.isEquals(array, ArrayUtils.subarray(array, 0, array.length)), "0 start, length end");
|
||||
|
@ -1022,8 +1022,8 @@ public class ArrayUtilsTest {
|
|||
public void testSubarrayDouble() {
|
||||
final double[] nullArray = null;
|
||||
final double[] array = {10.123, 11.234, 12.345, 13.456, 14.567, 15.678};
|
||||
final double[] leftSubarray = {10.123, 11.234, 12.345, 13.456,};
|
||||
final double[] midSubarray = {11.234, 12.345, 13.456, 14.567,};
|
||||
final double[] leftSubarray = {10.123, 11.234, 12.345, 13.456};
|
||||
final double[] midSubarray = {11.234, 12.345, 13.456, 14.567};
|
||||
final double[] rightSubarray = {12.345, 13.456, 14.567, 15.678};
|
||||
|
||||
assertTrue(ArrayUtils.isEquals(leftSubarray, ArrayUtils.subarray(array, 0, 4)), "0 start, mid end");
|
||||
|
@ -1079,7 +1079,7 @@ public class ArrayUtilsTest {
|
|||
assertEquals(ArrayUtils.EMPTY_FLOAT_ARRAY, ArrayUtils.subarray(array, 3, 3), "start == end");
|
||||
assertTrue(ArrayUtils.isEquals(leftSubarray, ArrayUtils.subarray(array, -2, 4)),
|
||||
"start undershoot, normal end");
|
||||
assertEquals(ArrayUtils.EMPTY_FLOAT_ARRAY, ArrayUtils.subarray(array, 33, 4),"start overshoot, any end");
|
||||
assertEquals(ArrayUtils.EMPTY_FLOAT_ARRAY, ArrayUtils.subarray(array, 33, 4), "start overshoot, any end");
|
||||
assertTrue(ArrayUtils.isEquals(rightSubarray, ArrayUtils.subarray(array, 2, 33)),
|
||||
"normal start, end overshoot");
|
||||
assertTrue(ArrayUtils.isEquals(array, ArrayUtils.subarray(array, -2, 12)), "start undershoot, end overshoot");
|
||||
|
@ -4821,7 +4821,7 @@ public class ArrayUtilsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testIsArrayIndexValid(){
|
||||
public void testIsArrayIndexValid() {
|
||||
assertFalse(ArrayUtils.isArrayIndexValid(null, 0));
|
||||
String[] array = new String[1];
|
||||
|
||||
|
|
|
@ -1007,7 +1007,7 @@ public class BooleanUtilsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testCompare(){
|
||||
public void testCompare() {
|
||||
assertTrue(BooleanUtils.compare(true, false) > 0);
|
||||
assertEquals(0, BooleanUtils.compare(true, true));
|
||||
assertEquals(0, BooleanUtils.compare(false, false));
|
||||
|
|
|
@ -84,7 +84,7 @@ public class CharSequenceUtilsTest {
|
|||
final boolean expected;
|
||||
final Class<? extends Throwable> throwable;
|
||||
TestData(final String source, final boolean ignoreCase, final int toffset,
|
||||
final String other, final int ooffset, final int len, final boolean expected){
|
||||
final String other, final int ooffset, final int len, final boolean expected) {
|
||||
this.source = source;
|
||||
this.ignoreCase = ignoreCase;
|
||||
this.toffset = toffset;
|
||||
|
@ -95,7 +95,7 @@ public class CharSequenceUtilsTest {
|
|||
this.throwable = null;
|
||||
}
|
||||
TestData(final String source, final boolean ignoreCase, final int toffset,
|
||||
final String other, final int ooffset, final int len, final Class<? extends Throwable> throwable){
|
||||
final String other, final int ooffset, final int len, final Class<? extends Throwable> throwable) {
|
||||
this.source = source;
|
||||
this.ignoreCase = ignoreCase;
|
||||
this.toffset = toffset;
|
||||
|
@ -106,7 +106,7 @@ public class CharSequenceUtilsTest {
|
|||
this.throwable = throwable;
|
||||
}
|
||||
@Override
|
||||
public String toString(){
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(source).append("[").append(toffset).append("]");
|
||||
sb.append(ignoreCase? " caseblind ":" samecase ");
|
||||
|
@ -134,8 +134,8 @@ public class CharSequenceUtilsTest {
|
|||
new TestData("Abc", false, 0, "abc", 0, 3, false),
|
||||
new TestData("Abc", true, 1, "abc", 1, 2, true),
|
||||
new TestData("Abc", false, 1, "abc", 1, 2, true),
|
||||
new TestData("Abcd",true, 1, "abcD",1, 2, true),
|
||||
new TestData("Abcd",false, 1, "abcD",1, 2, true),
|
||||
new TestData("Abcd", true, 1, "abcD", 1, 2, true),
|
||||
new TestData("Abcd", false, 1, "abcD", 1, 2, true),
|
||||
};
|
||||
|
||||
private abstract static class RunTest {
|
||||
|
|
|
@ -325,7 +325,7 @@ public class CharSetTest {
|
|||
|
||||
set = CharSet.getInstance("^-b");
|
||||
array = set.getCharRanges();
|
||||
assertTrue(ArrayUtils.contains(array, CharRange.isIn('^','b'))); // "^-b"
|
||||
assertTrue(ArrayUtils.contains(array, CharRange.isIn('^', 'b'))); // "^-b"
|
||||
assertTrue(set.contains('b'));
|
||||
assertTrue(set.contains('_')); // between ^ and a
|
||||
assertFalse(set.contains('A'));
|
||||
|
@ -333,7 +333,7 @@ public class CharSetTest {
|
|||
|
||||
set = CharSet.getInstance("b-^");
|
||||
array = set.getCharRanges();
|
||||
assertTrue(ArrayUtils.contains(array, CharRange.isIn('^','b'))); // "b-^"
|
||||
assertTrue(ArrayUtils.contains(array, CharRange.isIn('^', 'b'))); // "b-^"
|
||||
assertTrue(set.contains('b'));
|
||||
assertTrue(set.contains('^'));
|
||||
assertTrue(set.contains('a')); // between ^ and b
|
||||
|
|
|
@ -158,7 +158,7 @@ public class ClassUtilsTest {
|
|||
// -------------------------------------------------------------------------
|
||||
@Test
|
||||
public void test_getAbbreviatedName_Class() {
|
||||
assertEquals("", ClassUtils.getAbbreviatedName((Class<?>)null, 1));
|
||||
assertEquals("", ClassUtils.getAbbreviatedName((Class<?>) null, 1));
|
||||
assertEquals("j.l.String", ClassUtils.getAbbreviatedName(String.class, 1));
|
||||
assertEquals("j.l.String", ClassUtils.getAbbreviatedName(String.class, 5));
|
||||
assertEquals("j.lang.String", ClassUtils.getAbbreviatedName(String.class, 13));
|
||||
|
@ -1295,8 +1295,8 @@ public class ClassUtilsTest {
|
|||
assertNull(ClassUtils.primitivesToWrappers((Class<?>[]) null), "null -> null"); // equivalent cast to avoid warning
|
||||
// Other possible casts for null
|
||||
assertTrue(Arrays.equals(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.primitivesToWrappers()), "empty -> empty");
|
||||
final Class<?>[] castNull = ClassUtils.primitivesToWrappers((Class<?>)null); // == new Class<?>[]{null}
|
||||
assertTrue(Arrays.equals(new Class<?>[]{null}, castNull), "(Class<?>)null -> [null]");
|
||||
final Class<?>[] castNull = ClassUtils.primitivesToWrappers((Class<?>) null); // == new Class<?>[]{null}
|
||||
assertTrue(Arrays.equals(new Class<?>[]{null}, castNull), "(Class<?>) null -> [null]");
|
||||
// test empty array is returned unchanged
|
||||
assertArrayEquals(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.primitivesToWrappers(ArrayUtils.EMPTY_CLASS_ARRAY),
|
||||
"empty -> empty");
|
||||
|
@ -1366,7 +1366,7 @@ public class ClassUtilsTest {
|
|||
// Additional varargs tests
|
||||
assertTrue(Arrays.equals(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.toClass()), "empty -> empty");
|
||||
final Class<?>[] castNull = ClassUtils.toClass((Object) null); // == new Object[]{null}
|
||||
assertTrue(Arrays.equals(new Object[]{null}, castNull), "(Object)null -> [null]");
|
||||
assertTrue(Arrays.equals(new Object[]{null}, castNull), "(Object) null -> [null]");
|
||||
|
||||
assertSame(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.toClass(ArrayUtils.EMPTY_OBJECT_ARRAY));
|
||||
|
||||
|
@ -1415,8 +1415,8 @@ public class ClassUtilsTest {
|
|||
assertNull(ClassUtils.wrappersToPrimitives((Class<?>[]) null), "Wrong result for null input"); // equivalent cast
|
||||
// Other possible casts for null
|
||||
assertTrue(Arrays.equals(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.wrappersToPrimitives()), "empty -> empty");
|
||||
final Class<?>[] castNull = ClassUtils.wrappersToPrimitives((Class<?>)null); // == new Class<?>[]{null}
|
||||
assertTrue(Arrays.equals(new Class<?>[]{null}, castNull), "(Class<?>)null -> [null]");
|
||||
final Class<?>[] castNull = ClassUtils.wrappersToPrimitives((Class<?>) null); // == new Class<?>[]{null}
|
||||
assertTrue(Arrays.equals(new Class<?>[]{null}, castNull), "(Class<?>) null -> [null]");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -71,7 +71,7 @@ public class HashSetvBitSetTest {
|
|||
final int[] array = new int[100];
|
||||
toRemove.set(10, 20);
|
||||
final int[] extractIndices = extractIndices(toRemove);
|
||||
return (int[]) ArrayUtils.removeAll((Object)array, extractIndices);
|
||||
return (int[]) ArrayUtils.removeAll((Object) array, extractIndices);
|
||||
}
|
||||
|
||||
// --- utility methods
|
||||
|
@ -88,7 +88,7 @@ public class HashSetvBitSetTest {
|
|||
final int[] result = new int[coll.cardinality()];
|
||||
int i = 0;
|
||||
int j=0;
|
||||
while((j=coll.nextSetBit(j)) != -1) {
|
||||
while ((j=coll.nextSetBit(j)) != -1) {
|
||||
result[i++] = j++;
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -226,7 +226,7 @@ public class ObjectUtilsTest {
|
|||
ObjectUtils.identityToString(buffer, i);
|
||||
assertEquals(expected, buffer.toString());
|
||||
|
||||
assertThrows(NullPointerException.class, () -> ObjectUtils.identityToString((StringBuffer)null, "tmp"));
|
||||
assertThrows(NullPointerException.class, () -> ObjectUtils.identityToString((StringBuffer) null, "tmp"));
|
||||
assertThrows(NullPointerException.class, () -> ObjectUtils.identityToString(new StringBuffer(), null));
|
||||
}
|
||||
|
||||
|
@ -277,7 +277,7 @@ public class ObjectUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testIdentityToStringStringBuilderNullStringBuilder() {
|
||||
assertThrows(NullPointerException.class, () -> ObjectUtils.identityToString((StringBuilder)null, "tmp"));
|
||||
assertThrows(NullPointerException.class, () -> ObjectUtils.identityToString((StringBuilder) null, "tmp"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -289,7 +289,7 @@ public class ObjectUtilsTest {
|
|||
ObjectUtils.identityToString(builder, i);
|
||||
assertEquals(expected, builder.toString());
|
||||
|
||||
assertThrows(NullPointerException.class, () -> ObjectUtils.identityToString((StrBuilder)null, "tmp"));
|
||||
assertThrows(NullPointerException.class, () -> ObjectUtils.identityToString((StrBuilder) null, "tmp"));
|
||||
|
||||
assertThrows(NullPointerException.class, () -> ObjectUtils.identityToString(new StrBuilder(), null));
|
||||
}
|
||||
|
@ -303,11 +303,11 @@ public class ObjectUtilsTest {
|
|||
ObjectUtils.identityToString(appendable, i);
|
||||
assertEquals(expected, appendable.toString());
|
||||
|
||||
assertThrows(NullPointerException.class, () -> ObjectUtils.identityToString((Appendable)null, "tmp"));
|
||||
assertThrows(NullPointerException.class, () -> ObjectUtils.identityToString((Appendable) null, "tmp"));
|
||||
|
||||
assertThrows(
|
||||
NullPointerException.class,
|
||||
() -> ObjectUtils.identityToString((Appendable)(new StringBuilder()), null));
|
||||
() -> ObjectUtils.identityToString((Appendable) (new StringBuilder()), null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -631,7 +631,7 @@ public class ObjectUtilsTest {
|
|||
|
||||
@Override
|
||||
public CloneableString clone() throws CloneNotSupportedException {
|
||||
return (CloneableString)super.clone();
|
||||
return (CloneableString) super.clone();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public class RandomStringUtilsTest {
|
|||
|
||||
r1 = RandomStringUtils.randomAscii(50);
|
||||
assertEquals(50, r1.length(), "randomAscii(50) length");
|
||||
for(int i = 0; i < r1.length(); i++) {
|
||||
for (int i = 0; i < r1.length(); i++) {
|
||||
assertTrue(r1.charAt(i) >= 32 && r1.charAt(i) <= 127, "char between 32 and 127");
|
||||
}
|
||||
r2 = RandomStringUtils.randomAscii(50);
|
||||
|
@ -73,7 +73,7 @@ public class RandomStringUtilsTest {
|
|||
|
||||
r1 = RandomStringUtils.randomAlphabetic(50);
|
||||
assertEquals(50, r1.length(), "randomAlphabetic(50)");
|
||||
for(int i = 0; i < r1.length(); i++) {
|
||||
for (int i = 0; i < r1.length(); i++) {
|
||||
assertTrue(Character.isLetter(r1.charAt(i)) && !Character.isDigit(r1.charAt(i)), "r1 contains alphabetic");
|
||||
}
|
||||
r2 = RandomStringUtils.randomAlphabetic(50);
|
||||
|
@ -81,7 +81,7 @@ public class RandomStringUtilsTest {
|
|||
|
||||
r1 = RandomStringUtils.randomAlphanumeric(50);
|
||||
assertEquals(50, r1.length(), "randomAlphanumeric(50)");
|
||||
for(int i = 0; i < r1.length(); i++) {
|
||||
for (int i = 0; i < r1.length(); i++) {
|
||||
assertTrue(Character.isLetterOrDigit(r1.charAt(i)), "r1 contains alphanumeric");
|
||||
}
|
||||
r2 = RandomStringUtils.randomAlphabetic(50);
|
||||
|
@ -89,7 +89,7 @@ public class RandomStringUtilsTest {
|
|||
|
||||
r1 = RandomStringUtils.randomGraph(50);
|
||||
assertEquals(50, r1.length(), "randomGraph(50) length");
|
||||
for(int i = 0; i < r1.length(); i++) {
|
||||
for (int i = 0; i < r1.length(); i++) {
|
||||
assertTrue(r1.charAt(i) >= 33 && r1.charAt(i) <= 126, "char between 33 and 126");
|
||||
}
|
||||
r2 = RandomStringUtils.randomGraph(50);
|
||||
|
@ -97,7 +97,7 @@ public class RandomStringUtilsTest {
|
|||
|
||||
r1 = RandomStringUtils.randomNumeric(50);
|
||||
assertEquals(50, r1.length(), "randomNumeric(50)");
|
||||
for(int i = 0; i < r1.length(); i++) {
|
||||
for (int i = 0; i < r1.length(); i++) {
|
||||
assertTrue(Character.isDigit(r1.charAt(i)) && !Character.isLetter(r1.charAt(i)), "r1 contains numeric");
|
||||
}
|
||||
r2 = RandomStringUtils.randomNumeric(50);
|
||||
|
@ -105,7 +105,7 @@ public class RandomStringUtilsTest {
|
|||
|
||||
r1 = RandomStringUtils.randomPrint(50);
|
||||
assertEquals(50, r1.length(), "randomPrint(50) length");
|
||||
for(int i = 0; i < r1.length(); i++) {
|
||||
for (int i = 0; i < r1.length(); i++) {
|
||||
assertTrue(r1.charAt(i) >= 32 && r1.charAt(i) <= 126, "char between 32 and 126");
|
||||
}
|
||||
r2 = RandomStringUtils.randomPrint(50);
|
||||
|
@ -114,7 +114,7 @@ public class RandomStringUtilsTest {
|
|||
String set = "abcdefg";
|
||||
r1 = RandomStringUtils.random(50, set);
|
||||
assertEquals(50, r1.length(), "random(50, \"abcdefg\")");
|
||||
for(int i = 0; i < r1.length(); i++) {
|
||||
for (int i = 0; i < r1.length(); i++) {
|
||||
assertTrue(set.indexOf(r1.charAt(i)) > -1, "random char in set");
|
||||
}
|
||||
r2 = RandomStringUtils.random(50, set);
|
||||
|
@ -129,7 +129,7 @@ public class RandomStringUtilsTest {
|
|||
set = "stuvwxyz";
|
||||
r1 = RandomStringUtils.random(50, set.toCharArray());
|
||||
assertEquals(50, r1.length(), "random(50, \"stuvwxyz\")");
|
||||
for(int i = 0; i < r1.length(); i++) {
|
||||
for (int i = 0; i < r1.length(); i++) {
|
||||
assertTrue(set.indexOf(r1.charAt(i)) > -1, "random char in set");
|
||||
}
|
||||
r2 = RandomStringUtils.random(50, set);
|
||||
|
@ -142,8 +142,8 @@ public class RandomStringUtilsTest {
|
|||
assertTrue(!r1.equals(r2), "!r1.equals(r2)");
|
||||
|
||||
final long seed = System.currentTimeMillis();
|
||||
r1 = RandomStringUtils.random(50,0,0,true,true,null,new Random(seed));
|
||||
r2 = RandomStringUtils.random(50,0,0,true,true,null,new Random(seed));
|
||||
r1 = RandomStringUtils.random(50, 0, 0, true, true, null, new Random(seed));
|
||||
r2 = RandomStringUtils.random(50, 0, 0, true, true, null, new Random(seed));
|
||||
assertEquals(r1, r2, "r1.equals(r2)");
|
||||
|
||||
r1 = RandomStringUtils.random(0);
|
||||
|
@ -153,13 +153,13 @@ public class RandomStringUtilsTest {
|
|||
@Test
|
||||
public void testLANG805() {
|
||||
final long seed = System.currentTimeMillis();
|
||||
assertEquals("aaa", RandomStringUtils.random(3,0,0,false,false,new char[]{'a'},new Random(seed)));
|
||||
assertEquals("aaa", RandomStringUtils.random(3, 0, 0, false, false, new char[]{'a'}, new Random(seed)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLANG807() {
|
||||
IllegalArgumentException ex =
|
||||
assertThrows(IllegalArgumentException.class, () -> RandomStringUtils.random(3,5,5,false,false));
|
||||
assertThrows(IllegalArgumentException.class, () -> RandomStringUtils.random(3, 5, 5, false, false));
|
||||
final String msg = ex.getMessage();
|
||||
assertTrue(msg.contains("start"), "Message (" + msg + ") must contain 'start'");
|
||||
assertTrue(msg.contains("end"), "Message (" + msg + ") must contain 'end'");
|
||||
|
@ -212,7 +212,7 @@ public class RandomStringUtilsTest {
|
|||
*/
|
||||
@Test
|
||||
public void testRandomNumeric() {
|
||||
final char[] testChars = {'0','9'};
|
||||
final char[] testChars = {'0', '9'};
|
||||
final boolean[] found = {false, false};
|
||||
for (int i = 0; i < 100; i++) {
|
||||
final String randString = RandomStringUtils.randomNumeric(10);
|
||||
|
@ -439,7 +439,7 @@ public class RandomStringUtilsTest {
|
|||
final int[] counts = {0, 0, 0};
|
||||
final int[] expected = {200, 200, 200};
|
||||
for (int i = 0; i< 100; i++) {
|
||||
gen = RandomStringUtils.random(6,chars);
|
||||
gen = RandomStringUtils.random(6, chars);
|
||||
for (int j = 0; j < 6; j++) {
|
||||
switch (gen.charAt(j)) {
|
||||
case 'a': {
|
||||
|
@ -461,7 +461,7 @@ public class RandomStringUtilsTest {
|
|||
}
|
||||
}
|
||||
// Perform chi-square test with df = 3-1 = 2, testing at .001 level
|
||||
assertTrue(chiSquare(expected,counts) < 13.82, "test homogeneity -- will fail about 1 in 1000 times");
|
||||
assertTrue(chiSquare(expected, counts) < 13.82, "test homogeneity -- will fail about 1 in 1000 times");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -331,7 +331,7 @@ public class SerializationUtilsTest {
|
|||
public void testClone() {
|
||||
final Object test = SerializationUtils.clone(iMap);
|
||||
assertNotNull(test);
|
||||
assertTrue(test instanceof HashMap<?,?>);
|
||||
assertTrue(test instanceof HashMap<?, ?>);
|
||||
assertNotSame(test, iMap);
|
||||
final HashMap<?, ?> testMap = (HashMap<?, ?>) test;
|
||||
assertEquals(iString, testMap.get("FOO"));
|
||||
|
|
|
@ -236,11 +236,11 @@ public class StringEscapeUtilsTest {
|
|||
// Test all Character values:
|
||||
for (char i = Character.MIN_VALUE; i < Character.MAX_VALUE; i++) {
|
||||
final Character c1 = new Character(i);
|
||||
final Character c2 = new Character((char)(i+1));
|
||||
final Character c2 = new Character((char) (i+1));
|
||||
final String expected = c1.toString() + c2.toString();
|
||||
final String escapedC1 = "&#x" + Integer.toHexString((c1.charValue())) + ";";
|
||||
final String escapedC2 = "&#x" + Integer.toHexString((c2.charValue())) + ";";
|
||||
assertEquals(expected, StringEscapeUtils.unescapeHtml4(escapedC1 + escapedC2), "hex number unescape index " + (int)i);
|
||||
assertEquals(expected, StringEscapeUtils.unescapeHtml4(escapedC1 + escapedC2), "hex number unescape index " + (int) i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -477,7 +477,7 @@ public class StringEscapeUtilsTest {
|
|||
// COUNTING ROD UNIT DIGIT THREE
|
||||
// in Unicode
|
||||
// codepoint: U+1D362
|
||||
final byte[] data = new byte[] { (byte)0xF0, (byte)0x9D, (byte)0x8D, (byte)0xA2 };
|
||||
final byte[] data = new byte[] { (byte) 0xF0, (byte) 0x9D, (byte) 0x8D, (byte) 0xA2 };
|
||||
|
||||
final String original = new String(data, Charset.forName("UTF8"));
|
||||
|
||||
|
|
|
@ -140,8 +140,8 @@ public class StringUtilsEqualsIndexOfTest {
|
|||
assertFalse(StringUtils.equalsIgnoreCase(FOO, BAR));
|
||||
assertFalse(StringUtils.equalsIgnoreCase(FOO, null));
|
||||
assertFalse(StringUtils.equalsIgnoreCase(null, FOO));
|
||||
assertTrue(StringUtils.equalsIgnoreCase("",""));
|
||||
assertFalse(StringUtils.equalsIgnoreCase("abcd","abcd "));
|
||||
assertTrue(StringUtils.equalsIgnoreCase("", ""));
|
||||
assertFalse(StringUtils.equalsIgnoreCase("abcd", "abcd "));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -347,7 +347,7 @@ public class StringUtilsEqualsIndexOfTest {
|
|||
assertEquals(5, StringUtils.indexOf("aabaabaa", "b", 3));
|
||||
assertEquals(-1, StringUtils.indexOf("aabaabaa", "b", 9));
|
||||
assertEquals(2, StringUtils.indexOf("aabaabaa", "b", -1));
|
||||
assertEquals(2,StringUtils.indexOf("aabaabaa", "", 2));
|
||||
assertEquals(2, StringUtils.indexOf("aabaabaa", "", 2));
|
||||
|
||||
// Test that startIndex works correctly, i.e. cannot match before startIndex
|
||||
assertEquals(7, StringUtils.indexOf("12345678", "8", 5));
|
||||
|
@ -362,16 +362,16 @@ public class StringUtilsEqualsIndexOfTest {
|
|||
public void testIndexOfAny_StringCharArray() {
|
||||
assertEquals(-1, StringUtils.indexOfAny(null, (char[]) null));
|
||||
assertEquals(-1, StringUtils.indexOfAny(null, new char[0]));
|
||||
assertEquals(-1, StringUtils.indexOfAny(null, 'a','b'));
|
||||
assertEquals(-1, StringUtils.indexOfAny(null, 'a', 'b'));
|
||||
|
||||
assertEquals(-1, StringUtils.indexOfAny("", (char[]) null));
|
||||
assertEquals(-1, StringUtils.indexOfAny("", new char[0]));
|
||||
assertEquals(-1, StringUtils.indexOfAny("", 'a','b'));
|
||||
assertEquals(-1, StringUtils.indexOfAny("", 'a', 'b'));
|
||||
|
||||
assertEquals(-1, StringUtils.indexOfAny("zzabyycdxx", (char[]) null));
|
||||
assertEquals(-1, StringUtils.indexOfAny("zzabyycdxx", new char[0]));
|
||||
assertEquals(0, StringUtils.indexOfAny("zzabyycdxx", 'z','a'));
|
||||
assertEquals(3, StringUtils.indexOfAny("zzabyycdxx", 'b','y'));
|
||||
assertEquals(0, StringUtils.indexOfAny("zzabyycdxx", 'z', 'a'));
|
||||
assertEquals(3, StringUtils.indexOfAny("zzabyycdxx", 'b', 'y'));
|
||||
assertEquals(-1, StringUtils.indexOfAny("ab", 'z'));
|
||||
}
|
||||
|
||||
|
@ -436,16 +436,16 @@ public class StringUtilsEqualsIndexOfTest {
|
|||
public void testIndexOfAnyBut_StringCharArray() {
|
||||
assertEquals(-1, StringUtils.indexOfAnyBut(null, (char[]) null));
|
||||
assertEquals(-1, StringUtils.indexOfAnyBut(null));
|
||||
assertEquals(-1, StringUtils.indexOfAnyBut(null, 'a','b'));
|
||||
assertEquals(-1, StringUtils.indexOfAnyBut(null, 'a', 'b'));
|
||||
|
||||
assertEquals(-1, StringUtils.indexOfAnyBut("", (char[]) null));
|
||||
assertEquals(-1, StringUtils.indexOfAnyBut(""));
|
||||
assertEquals(-1, StringUtils.indexOfAnyBut("", 'a','b'));
|
||||
assertEquals(-1, StringUtils.indexOfAnyBut("", 'a', 'b'));
|
||||
|
||||
assertEquals(-1, StringUtils.indexOfAnyBut("zzabyycdxx", (char[]) null));
|
||||
assertEquals(-1, StringUtils.indexOfAnyBut("zzabyycdxx"));
|
||||
assertEquals(3, StringUtils.indexOfAnyBut("zzabyycdxx", 'z','a'));
|
||||
assertEquals(0, StringUtils.indexOfAnyBut("zzabyycdxx", 'b','y'));
|
||||
assertEquals(3, StringUtils.indexOfAnyBut("zzabyycdxx", 'z', 'a'));
|
||||
assertEquals(0, StringUtils.indexOfAnyBut("zzabyycdxx", 'b', 'y'));
|
||||
assertEquals(-1, StringUtils.indexOfAnyBut("aba", 'a', 'b'));
|
||||
assertEquals(0, StringUtils.indexOfAnyBut("aba", 'z'));
|
||||
}
|
||||
|
|
|
@ -85,9 +85,9 @@ public class StringUtilsStartsEndsWithTest {
|
|||
|
||||
@Test
|
||||
public void testStartsWithAny() {
|
||||
assertFalse(StringUtils.startsWithAny(null, (String[])null));
|
||||
assertFalse(StringUtils.startsWithAny(null, (String[]) null));
|
||||
assertFalse(StringUtils.startsWithAny(null, "abc"));
|
||||
assertFalse(StringUtils.startsWithAny("abcxyz", (String[])null));
|
||||
assertFalse(StringUtils.startsWithAny("abcxyz", (String[]) null));
|
||||
assertFalse(StringUtils.startsWithAny("abcxyz"));
|
||||
assertTrue(StringUtils.startsWithAny("abcxyz", "abc"));
|
||||
assertTrue(StringUtils.startsWithAny("abcxyz", null, "xyz", "abc"));
|
||||
|
@ -124,10 +124,10 @@ public class StringUtilsStartsEndsWithTest {
|
|||
assertFalse(StringUtils.endsWith(foobar, BAR), "endsWith(foobar, BAR)");
|
||||
assertFalse(StringUtils.endsWith(FOOBAR, bar), "endsWith(FOOBAR, bar)");
|
||||
|
||||
// "alpha,beta,gamma,delta".endsWith("delta")
|
||||
// "alpha, beta, gamma, delta".endsWith("delta")
|
||||
assertTrue(StringUtils.endsWith("\u03B1\u03B2\u03B3\u03B4", "\u03B4"),
|
||||
"endsWith(\u03B1\u03B2\u03B3\u03B4, \u03B4)");
|
||||
// "alpha,beta,gamma,delta".endsWith("gamma,DELTA")
|
||||
// "alpha, beta, gamma, delta".endsWith("gamma, DELTA")
|
||||
assertFalse(StringUtils.endsWith("\u03B1\u03B2\u03B3\u03B4", "\u03B3\u0394"),
|
||||
"endsWith(\u03B1\u03B2\u03B3\u03B4, \u03B3\u0394)");
|
||||
}
|
||||
|
@ -160,19 +160,19 @@ public class StringUtilsStartsEndsWithTest {
|
|||
assertTrue(StringUtils.endsWithIgnoreCase("ABCDEF", "def"));
|
||||
assertFalse(StringUtils.endsWithIgnoreCase("ABCDEF", "cde"));
|
||||
|
||||
// "alpha,beta,gamma,delta".endsWith("DELTA")
|
||||
// "alpha, beta, gamma, delta".endsWith("DELTA")
|
||||
assertTrue(StringUtils.endsWithIgnoreCase("\u03B1\u03B2\u03B3\u03B4", "\u0394"),
|
||||
"endsWith(\u03B1\u03B2\u03B3\u03B4, \u0394)");
|
||||
// "alpha,beta,gamma,delta".endsWith("GAMMA")
|
||||
// "alpha, beta, gamma, delta".endsWith("GAMMA")
|
||||
assertFalse(StringUtils.endsWithIgnoreCase("\u03B1\u03B2\u03B3\u03B4", "\u0393"),
|
||||
"endsWith(\u03B1\u03B2\u03B3\u03B4, \u0393)");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEndsWithAny() {
|
||||
assertFalse(StringUtils.endsWithAny(null, (String)null), "StringUtils.endsWithAny(null, null)");
|
||||
assertFalse(StringUtils.endsWithAny(null, (String) null), "StringUtils.endsWithAny(null, null)");
|
||||
assertFalse(StringUtils.endsWithAny(null, new String[] {"abc"}), "StringUtils.endsWithAny(null, new String[] {abc})");
|
||||
assertFalse(StringUtils.endsWithAny("abcxyz", (String)null), "StringUtils.endsWithAny(abcxyz, null)");
|
||||
assertFalse(StringUtils.endsWithAny("abcxyz", (String) null), "StringUtils.endsWithAny(abcxyz, null)");
|
||||
assertTrue(StringUtils.endsWithAny("abcxyz", new String[] {""}), "StringUtils.endsWithAny(abcxyz, new String[] {\"\"})");
|
||||
assertTrue(StringUtils.endsWithAny("abcxyz", new String[] {"xyz"}), "StringUtils.endsWithAny(abcxyz, new String[] {xyz})");
|
||||
assertTrue(StringUtils.endsWithAny("abcxyz", new String[] {null, "xyz", "abc"}), "StringUtils.endsWithAny(abcxyz, new String[] {null, xyz, abc})");
|
||||
|
|
|
@ -70,7 +70,7 @@ public class StringUtilsSubstringTest {
|
|||
assertEquals("o", StringUtils.substring(SENTENCE, -9, -8));
|
||||
assertEquals(SENTENCE, StringUtils.substring(SENTENCE, 0, 80));
|
||||
assertEquals("", StringUtils.substring(SENTENCE, 2, 2));
|
||||
assertEquals("b",StringUtils.substring("abc", -2, -1));
|
||||
assertEquals("b", StringUtils.substring("abc", -2, -1));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -3150,7 +3150,7 @@ public class StringUtilsTest {
|
|||
final int orphanedLowSurrogate = 0xDC00;
|
||||
final int supplementary = 0x2070E;
|
||||
|
||||
final int[] codePoints = {'a', orphanedHighSurrogate, 'b','c', supplementary,
|
||||
final int[] codePoints = {'a', orphanedHighSurrogate, 'b', 'c', supplementary,
|
||||
'd', orphanedLowSurrogate, 'e'};
|
||||
final String s = new String(codePoints, 0, codePoints.length);
|
||||
assertArrayEquals(codePoints, StringUtils.toCodePoints(s));
|
||||
|
|
|
@ -213,13 +213,13 @@ public class ThreadUtilsTest {
|
|||
t1.start();
|
||||
t2.start();
|
||||
assertEquals(1, ThreadUtils.findThreadsByName("thread1_XXOOPP__").size());
|
||||
assertEquals(1, ThreadUtils.findThreadsByName("thread1_XXOOPP__","thread_group_DDZZ99__").size());
|
||||
assertEquals(1, ThreadUtils.findThreadsByName("thread2_XXOOPP__","thread_group_DDZZ99__").size());
|
||||
assertEquals(0, ThreadUtils.findThreadsByName("thread1_XXOOPP__","non_existent_thread_group_JJHHZZ__").size());
|
||||
assertEquals(0, ThreadUtils.findThreadsByName("non_existent_thread_BBDDWW__","thread_group_DDZZ99__").size());
|
||||
assertEquals(1, ThreadUtils.findThreadsByName("thread1_XXOOPP__", "thread_group_DDZZ99__").size());
|
||||
assertEquals(1, ThreadUtils.findThreadsByName("thread2_XXOOPP__", "thread_group_DDZZ99__").size());
|
||||
assertEquals(0, ThreadUtils.findThreadsByName("thread1_XXOOPP__", "non_existent_thread_group_JJHHZZ__").size());
|
||||
assertEquals(0, ThreadUtils.findThreadsByName("non_existent_thread_BBDDWW__", "thread_group_DDZZ99__").size());
|
||||
assertEquals(1, ThreadUtils.findThreadGroupsByName("thread_group_DDZZ99__").size());
|
||||
assertEquals(0, ThreadUtils.findThreadGroupsByName("non_existent_thread_group_JJHHZZ__").size());
|
||||
assertNotNull(ThreadUtils.findThreadById(t1.getId(),threadGroup));
|
||||
assertNotNull(ThreadUtils.findThreadById(t1.getId(), threadGroup));
|
||||
} finally {
|
||||
t1.interrupt();
|
||||
t2.interrupt();
|
||||
|
@ -241,16 +241,16 @@ public class ThreadUtilsTest {
|
|||
t1.start();
|
||||
t2.start();
|
||||
assertEquals(1, ThreadUtils.findThreadsByName("thread1_XXOOPP__").size());
|
||||
assertEquals(1, ThreadUtils.findThreadsByName("thread1_XXOOPP__",threadGroup).size());
|
||||
assertEquals(1, ThreadUtils.findThreadsByName("thread2_XXOOPP__",threadGroup).size());
|
||||
assertEquals(0, ThreadUtils.findThreadsByName("thread1_XXOOPP__",deadThreadGroup).size());
|
||||
assertEquals(1, ThreadUtils.findThreadsByName("thread1_XXOOPP__", threadGroup).size());
|
||||
assertEquals(1, ThreadUtils.findThreadsByName("thread2_XXOOPP__", threadGroup).size());
|
||||
assertEquals(0, ThreadUtils.findThreadsByName("thread1_XXOOPP__", deadThreadGroup).size());
|
||||
} finally {
|
||||
t1.interrupt();
|
||||
t2.interrupt();
|
||||
t1.join();
|
||||
t2.join();
|
||||
threadGroup.destroy();
|
||||
assertEquals(0, ThreadUtils.findThreadsByName("thread2_XXOOPP__",threadGroup).size());
|
||||
assertEquals(0, ThreadUtils.findThreadsByName("thread2_XXOOPP__", threadGroup).size());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,10 +264,10 @@ public class ThreadUtilsTest {
|
|||
try {
|
||||
t1.start();
|
||||
t2.start();
|
||||
assertSame(t1, ThreadUtils.findThreadById(t1.getId(),"thread_group_DDZZ99__"));
|
||||
assertSame(t2, ThreadUtils.findThreadById(t2.getId(),"thread_group_DDZZ99__"));
|
||||
assertNull(ThreadUtils.findThreadById(nonExistingId,"non_existent_thread_group_JJHHZZ__"));
|
||||
assertNull(ThreadUtils.findThreadById(nonExistingId,"thread_group_DDZZ99__"));
|
||||
assertSame(t1, ThreadUtils.findThreadById(t1.getId(), "thread_group_DDZZ99__"));
|
||||
assertSame(t2, ThreadUtils.findThreadById(t2.getId(), "thread_group_DDZZ99__"));
|
||||
assertNull(ThreadUtils.findThreadById(nonExistingId, "non_existent_thread_group_JJHHZZ__"));
|
||||
assertNull(ThreadUtils.findThreadById(nonExistingId, "thread_group_DDZZ99__"));
|
||||
} finally {
|
||||
t1.interrupt();
|
||||
t2.interrupt();
|
||||
|
@ -297,7 +297,7 @@ public class ThreadUtilsTest {
|
|||
final ThreadGroup threadGroup6 = new ThreadGroup(threadGroup4, "thread_group_6__");
|
||||
final ThreadGroup threadGroup7 = new ThreadGroup(threadGroup4, "thread_group_7__");
|
||||
final ThreadGroup threadGroup7Doubled = new ThreadGroup(threadGroup4, "thread_group_7__");
|
||||
final List<ThreadGroup> threadGroups = Arrays.asList(threadGroup1,threadGroup2,threadGroup3,threadGroup4,threadGroup5,threadGroup6, threadGroup7, threadGroup7Doubled);
|
||||
final List<ThreadGroup> threadGroups = Arrays.asList(threadGroup1, threadGroup2, threadGroup3, threadGroup4, threadGroup5, threadGroup6, threadGroup7, threadGroup7Doubled);
|
||||
|
||||
final Thread t1 = new TestThread("thread1_X__");
|
||||
final Thread t2 = new TestThread(threadGroup1, "thread2_X__");
|
||||
|
@ -311,7 +311,7 @@ public class ThreadUtilsTest {
|
|||
final Thread t10 = new TestThread(threadGroup3, "thread10_X__");
|
||||
final Thread t11 = new TestThread(threadGroup7, "thread11_X__");
|
||||
final Thread t11Doubled = new TestThread(threadGroup7Doubled, "thread11_X__");
|
||||
final List<Thread> threads = Arrays.asList(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10, t11, t11Doubled);
|
||||
final List<Thread> threads = Arrays.asList(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t11Doubled);
|
||||
|
||||
try {
|
||||
for (final Thread thread : threads) {
|
||||
|
@ -362,7 +362,7 @@ public class ThreadUtilsTest {
|
|||
public void run() {
|
||||
latch.countDown();
|
||||
try {
|
||||
synchronized(this){
|
||||
synchronized(this) {
|
||||
this.wait();
|
||||
}
|
||||
} catch (final InterruptedException e) {
|
||||
|
|
|
@ -218,7 +218,7 @@ public class CompareToBuilderTest {
|
|||
|
||||
// transitive
|
||||
if (CompareToBuilder.reflectionCompare(x, y, testTransients, null, excludeFields) > 0
|
||||
&& CompareToBuilder.reflectionCompare(y, z, testTransients, null, excludeFields) > 0){
|
||||
&& CompareToBuilder.reflectionCompare(y, z, testTransients, null, excludeFields) > 0) {
|
||||
assertTrue(CompareToBuilder.reflectionCompare(x, z, testTransients, null, excludeFields) > 0);
|
||||
}
|
||||
|
||||
|
@ -745,9 +745,9 @@ public class CompareToBuilderTest {
|
|||
final short[][] array3 = new short[2][3];
|
||||
for (short i = 0; i < array1.length; ++i) {
|
||||
for (short j = 0; j < array1[0].length; j++) {
|
||||
array1[i][j] = (short)((i + 1) * (j + 1));
|
||||
array2[i][j] = (short)((i + 1) * (j + 1));
|
||||
array3[i][j] = (short)((i + 1) * (j + 1));
|
||||
array1[i][j] = (short) ((i + 1) * (j + 1));
|
||||
array2[i][j] = (short) ((i + 1) * (j + 1));
|
||||
array3[i][j] = (short) ((i + 1) * (j + 1));
|
||||
}
|
||||
}
|
||||
array3[1][2] = 100;
|
||||
|
@ -769,9 +769,9 @@ public class CompareToBuilderTest {
|
|||
final char[][] array3 = new char[2][3];
|
||||
for (short i = 0; i < array1.length; ++i) {
|
||||
for (short j = 0; j < array1[0].length; j++) {
|
||||
array1[i][j] = (char)((i + 1) * (j + 1));
|
||||
array2[i][j] = (char)((i + 1) * (j + 1));
|
||||
array3[i][j] = (char)((i + 1) * (j + 1));
|
||||
array1[i][j] = (char) ((i + 1) * (j + 1));
|
||||
array2[i][j] = (char) ((i + 1) * (j + 1));
|
||||
array3[i][j] = (char) ((i + 1) * (j + 1));
|
||||
}
|
||||
}
|
||||
array3[1][2] = 100;
|
||||
|
@ -793,9 +793,9 @@ public class CompareToBuilderTest {
|
|||
final byte[][] array3 = new byte[2][3];
|
||||
for (byte i = 0; i < array1.length; ++i) {
|
||||
for (byte j = 0; j < array1[0].length; j++) {
|
||||
array1[i][j] = (byte)((i + 1) * (j + 1));
|
||||
array2[i][j] = (byte)((i + 1) * (j + 1));
|
||||
array3[i][j] = (byte)((i + 1) * (j + 1));
|
||||
array1[i][j] = (byte) ((i + 1) * (j + 1));
|
||||
array2[i][j] = (byte) ((i + 1) * (j + 1));
|
||||
array3[i][j] = (byte) ((i + 1) * (j + 1));
|
||||
}
|
||||
}
|
||||
array3[1][2] = 100;
|
||||
|
|
|
@ -197,9 +197,9 @@ public class JsonToStringStyleTest {
|
|||
|
||||
@Test
|
||||
public void testNestingPerson() {
|
||||
final Person p = new Person(){
|
||||
final Person p = new Person() {
|
||||
@Override
|
||||
public String toString(){
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this).append("name", this.name)
|
||||
.append("age", this.age).append("smoker", this.smoker)
|
||||
.toString();
|
||||
|
@ -301,16 +301,16 @@ public class JsonToStringStyleTest {
|
|||
|
||||
@Test
|
||||
public void testLANG1395() {
|
||||
assertEquals("{\"name\":\"value\"}",new ToStringBuilder(base).append("name","value").toString());
|
||||
assertEquals("{\"name\":\"\"}",new ToStringBuilder(base).append("name","").toString());
|
||||
assertEquals("{\"name\":\"\\\"\"}",new ToStringBuilder(base).append("name",'"').toString());
|
||||
assertEquals("{\"name\":\"\\\\\"}",new ToStringBuilder(base).append("name",'\\').toString());
|
||||
assertEquals("{\"name\":\"Let's \\\"quote\\\" this\"}",new ToStringBuilder(base).append("name","Let's \"quote\" this").toString());
|
||||
assertEquals("{\"name\":\"value\"}", new ToStringBuilder(base).append("name", "value").toString());
|
||||
assertEquals("{\"name\":\"\"}", new ToStringBuilder(base).append("name", "").toString());
|
||||
assertEquals("{\"name\":\"\\\"\"}", new ToStringBuilder(base).append("name", '"').toString());
|
||||
assertEquals("{\"name\":\"\\\\\"}", new ToStringBuilder(base).append("name", '\\').toString());
|
||||
assertEquals("{\"name\":\"Let's \\\"quote\\\" this\"}", new ToStringBuilder(base).append("name", "Let's \"quote\" this").toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLANG1396() {
|
||||
assertEquals("{\"Let's \\\"quote\\\" this\":\"value\"}",new ToStringBuilder(base).append("Let's \"quote\" this","value").toString());
|
||||
assertEquals("{\"Let's \\\"quote\\\" this\":\"value\"}", new ToStringBuilder(base).append("Let's \"quote\" this", "value").toString());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,7 +44,7 @@ public class ReflectionToStringBuilderExcludeNullValuesTest {
|
|||
private final TestFixture BOTH_NULL = new TestFixture(null, null);
|
||||
|
||||
@Test
|
||||
public void test_NonExclude(){
|
||||
public void test_NonExclude() {
|
||||
//normal case=
|
||||
String toString = ReflectionToStringBuilder.toString(BOTH_NON_NULL, null, false, false, false, null);
|
||||
assertTrue(toString.contains(INTEGER_FIELD_NAME));
|
||||
|
@ -67,7 +67,7 @@ public class ReflectionToStringBuilderExcludeNullValuesTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_excludeNull(){
|
||||
public void test_excludeNull() {
|
||||
|
||||
//test normal case
|
||||
String toString = ReflectionToStringBuilder.toString(BOTH_NON_NULL, null, false, false, true, null);
|
||||
|
@ -91,7 +91,7 @@ public class ReflectionToStringBuilderExcludeNullValuesTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_ConstructorOption(){
|
||||
public void test_ConstructorOption() {
|
||||
ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NON_NULL, null, null, null, false, false, true);
|
||||
assertTrue(builder.isExcludeNullValues());
|
||||
String toString = builder.toString();
|
||||
|
@ -115,7 +115,7 @@ public class ReflectionToStringBuilderExcludeNullValuesTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_ConstructorOptionNormal(){
|
||||
public void test_ConstructorOptionNormal() {
|
||||
final ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false, false);
|
||||
assertFalse(builder.isExcludeNullValues());
|
||||
String toString = builder.toString();
|
||||
|
@ -140,7 +140,7 @@ public class ReflectionToStringBuilderExcludeNullValuesTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void test_ConstructorOption_ExcludeNull(){
|
||||
public void test_ConstructorOption_ExcludeNull() {
|
||||
ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false, false);
|
||||
builder.setExcludeNullValues(true);
|
||||
assertTrue(builder.isExcludeNullValues());
|
||||
|
|
|
@ -46,7 +46,7 @@ public class ToStringBuilderTest {
|
|||
* All tests should leave the registry empty.
|
||||
*/
|
||||
@AfterEach
|
||||
public void after(){
|
||||
public void after() {
|
||||
validateNullToStringStyleRegistry();
|
||||
}
|
||||
|
||||
|
@ -512,7 +512,7 @@ public class ToStringBuilderTest {
|
|||
this.typeIsSelf = this;
|
||||
}
|
||||
|
||||
public String getOtherType(){
|
||||
public String getOtherType() {
|
||||
return this.otherType;
|
||||
}
|
||||
|
||||
|
@ -845,7 +845,7 @@ public class ToStringBuilderTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testConstructToStringBuilder(){
|
||||
public void testConstructToStringBuilder() {
|
||||
final ToStringBuilder stringBuilder1 = new ToStringBuilder(base, null, null);
|
||||
final ToStringBuilder stringBuilder2 = new ToStringBuilder(base, ToStringStyle.DEFAULT_STYLE, new StringBuffer(1024));
|
||||
assertEquals(ToStringStyle.DEFAULT_STYLE, stringBuilder1.getStyle());
|
||||
|
|
|
@ -82,7 +82,9 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<
|
|||
public void testContextedExceptionStringThrowableContext() {
|
||||
// Use an anonymous subclass to make sure users can provide custom implementations
|
||||
exceptionContext = new ContextedRuntimeException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE),
|
||||
new DefaultExceptionContext() {private static final long serialVersionUID = 1L;});
|
||||
new DefaultExceptionContext() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
});
|
||||
final String message = exceptionContext.getMessage();
|
||||
final String trace = ExceptionUtils.getStackTrace(exceptionContext);
|
||||
assertTrue(trace.contains("ContextedException"));
|
||||
|
|
|
@ -745,8 +745,8 @@ public class FractionTest {
|
|||
|
||||
// if this fraction is added naively, it will overflow.
|
||||
// check that it doesn't.
|
||||
f1 = Fraction.getFraction(1,32768*3);
|
||||
f2 = Fraction.getFraction(1,59049);
|
||||
f1 = Fraction.getFraction(1, 32768*3);
|
||||
f2 = Fraction.getFraction(1, 59049);
|
||||
f = f1.add(f2);
|
||||
assertEquals(52451, f.getNumerator());
|
||||
assertEquals(1934917632, f.getDenominator());
|
||||
|
@ -769,7 +769,7 @@ public class FractionTest {
|
|||
// denominator should not be a multiple of 2 or 3 to trigger overflow
|
||||
assertThrows(
|
||||
ArithmeticException.class,
|
||||
() -> Fraction.getFraction(Integer.MIN_VALUE, 5).add(Fraction.getFraction(-1,5)));
|
||||
() -> Fraction.getFraction(Integer.MIN_VALUE, 5).add(Fraction.getFraction(-1, 5)));
|
||||
|
||||
final Fraction maxValue = Fraction.getFraction(-Integer.MAX_VALUE, 1);
|
||||
assertThrows(ArithmeticException.class, () -> maxValue.add(maxValue));
|
||||
|
@ -777,8 +777,8 @@ public class FractionTest {
|
|||
final Fraction negativeMaxValue = Fraction.getFraction(-Integer.MAX_VALUE, 1);
|
||||
assertThrows(ArithmeticException.class, () -> negativeMaxValue.add(negativeMaxValue));
|
||||
|
||||
final Fraction f3 = Fraction.getFraction(3,327680);
|
||||
final Fraction f4 = Fraction.getFraction(2,59049);
|
||||
final Fraction f3 = Fraction.getFraction(3, 327680);
|
||||
final Fraction f4 = Fraction.getFraction(2, 59049);
|
||||
assertThrows(ArithmeticException.class, () -> f3.add(f4)); // should overflow
|
||||
}
|
||||
|
||||
|
@ -840,8 +840,8 @@ public class FractionTest {
|
|||
|
||||
// if this fraction is subtracted naively, it will overflow.
|
||||
// check that it doesn't.
|
||||
f1 = Fraction.getFraction(1,32768*3);
|
||||
f2 = Fraction.getFraction(1,59049);
|
||||
f1 = Fraction.getFraction(1, 32768*3);
|
||||
f2 = Fraction.getFraction(1, 59049);
|
||||
f = f1.subtract(f2);
|
||||
assertEquals(-13085, f.getNumerator());
|
||||
assertEquals(1934917632, f.getDenominator());
|
||||
|
@ -867,7 +867,7 @@ public class FractionTest {
|
|||
// denominator should not be a multiple of 2 or 3 to trigger overflow
|
||||
assertThrows(
|
||||
ArithmeticException.class,
|
||||
() -> Fraction.getFraction(Integer.MIN_VALUE, 5).subtract(Fraction.getFraction(1,5)));
|
||||
() -> Fraction.getFraction(Integer.MIN_VALUE, 5).subtract(Fraction.getFraction(1, 5)));
|
||||
|
||||
assertThrows(
|
||||
ArithmeticException.class, () -> Fraction.getFraction(Integer.MIN_VALUE, 1).subtract(Fraction.ONE));
|
||||
|
@ -879,7 +879,7 @@ public class FractionTest {
|
|||
// Should overflow
|
||||
assertThrows(
|
||||
ArithmeticException.class,
|
||||
() -> Fraction.getFraction(3,327680).subtract(Fraction.getFraction(2,59049)));
|
||||
() -> Fraction.getFraction(3, 327680).subtract(Fraction.getFraction(2, 59049)));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -65,8 +65,8 @@ public class NumberUtilsTest {
|
|||
*/
|
||||
@Test
|
||||
public void testToIntStringI() {
|
||||
assertEquals(12345, NumberUtils.toInt("12345", 5), "toInt(String,int) 1 failed");
|
||||
assertEquals(5, NumberUtils.toInt("1234.5", 5), "toInt(String,int) 2 failed");
|
||||
assertEquals(12345, NumberUtils.toInt("12345", 5), "toInt(String, int) 1 failed");
|
||||
assertEquals(5, NumberUtils.toInt("1234.5", 5), "toInt(String, int) 2 failed");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -89,8 +89,8 @@ public class NumberUtilsTest {
|
|||
*/
|
||||
@Test
|
||||
public void testToLongStringL() {
|
||||
assertEquals(12345L, NumberUtils.toLong("12345", 5L), "toLong(String,long) 1 failed");
|
||||
assertEquals(5L, NumberUtils.toLong("1234.5", 5L), "toLong(String,long) 2 failed");
|
||||
assertEquals(12345L, NumberUtils.toLong("12345", 5L), "toLong(String, long) 1 failed");
|
||||
assertEquals(5L, NumberUtils.toLong("1234.5", 5L), "toLong(String, long) 2 failed");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -118,19 +118,19 @@ public class NumberUtilsTest {
|
|||
*/
|
||||
@Test
|
||||
public void testToFloatStringF() {
|
||||
assertTrue(NumberUtils.toFloat("1.2345", 5.1f) == 1.2345f, "toFloat(String,int) 1 failed");
|
||||
assertTrue(NumberUtils.toFloat("a", 5.0f) == 5.0f, "toFloat(String,int) 2 failed");
|
||||
assertTrue(NumberUtils.toFloat("1.2345", 5.1f) == 1.2345f, "toFloat(String, int) 1 failed");
|
||||
assertTrue(NumberUtils.toFloat("a", 5.0f) == 5.0f, "toFloat(String, int) 2 failed");
|
||||
// LANG-1060
|
||||
assertTrue(NumberUtils.toFloat("-001Z.2345", 5.0f) == 5.0f, "toFloat(String,int) 3 failed");
|
||||
assertTrue(NumberUtils.toFloat("+001AB.2345", 5.0f) == 5.0f, "toFloat(String,int) 4 failed");
|
||||
assertTrue(NumberUtils.toFloat("001Z.2345", 5.0f) == 5.0f, "toFloat(String,int) 5 failed");
|
||||
assertTrue(NumberUtils.toFloat("-001Z.2345", 5.0f) == 5.0f, "toFloat(String, int) 3 failed");
|
||||
assertTrue(NumberUtils.toFloat("+001AB.2345", 5.0f) == 5.0f, "toFloat(String, int) 4 failed");
|
||||
assertTrue(NumberUtils.toFloat("001Z.2345", 5.0f) == 5.0f, "toFloat(String, int) 5 failed");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for {(@link NumberUtils#createNumber(String)}
|
||||
*/
|
||||
@Test
|
||||
public void testStringCreateNumberEnsureNoPrecisionLoss(){
|
||||
public void testStringCreateNumberEnsureNoPrecisionLoss() {
|
||||
final String shouldBeFloat = "1.23";
|
||||
final String shouldBeDouble = "3.40282354e+38";
|
||||
final String shouldBeBigDecimal = "1.797693134862315759e+308";
|
||||
|
@ -173,13 +173,13 @@ public class NumberUtilsTest {
|
|||
*/
|
||||
@Test
|
||||
public void testStringToDoubleStringD() {
|
||||
assertTrue(NumberUtils.toDouble("1.2345", 5.1d) == 1.2345d, "toDouble(String,int) 1 failed");
|
||||
assertTrue(NumberUtils.toDouble("a", 5.0d) == 5.0d, "toDouble(String,int) 2 failed");
|
||||
assertTrue(NumberUtils.toDouble("1.2345", 5.1d) == 1.2345d, "toDouble(String, int) 1 failed");
|
||||
assertTrue(NumberUtils.toDouble("a", 5.0d) == 5.0d, "toDouble(String, int) 2 failed");
|
||||
// LANG-1060
|
||||
assertTrue(NumberUtils.toDouble("001.2345", 5.1d) == 1.2345d, "toDouble(String,int) 3 failed");
|
||||
assertTrue(NumberUtils.toDouble("-001.2345", 5.1d) == -1.2345d, "toDouble(String,int) 4 failed");
|
||||
assertTrue(NumberUtils.toDouble("+001.2345", 5.1d) == 1.2345d, "toDouble(String,int) 5 failed");
|
||||
assertTrue(NumberUtils.toDouble("000.00", 5.1d) == 0d, "toDouble(String,int) 7 failed");
|
||||
assertTrue(NumberUtils.toDouble("001.2345", 5.1d) == 1.2345d, "toDouble(String, int) 3 failed");
|
||||
assertTrue(NumberUtils.toDouble("-001.2345", 5.1d) == -1.2345d, "toDouble(String, int) 4 failed");
|
||||
assertTrue(NumberUtils.toDouble("+001.2345", 5.1d) == 1.2345d, "toDouble(String, int) 5 failed");
|
||||
assertTrue(NumberUtils.toDouble("000.00", 5.1d) == 0d, "toDouble(String, int) 7 failed");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -216,8 +216,8 @@ public class NumberUtilsTest {
|
|||
*/
|
||||
@Test
|
||||
public void testToByteStringI() {
|
||||
assertEquals(123, NumberUtils.toByte("123", (byte) 5), "toByte(String,byte) 1 failed");
|
||||
assertEquals(5, NumberUtils.toByte("12.3", (byte) 5), "toByte(String,byte) 2 failed");
|
||||
assertEquals(123, NumberUtils.toByte("123", (byte) 5), "toByte(String, byte) 1 failed");
|
||||
assertEquals(5, NumberUtils.toByte("12.3", (byte) 5), "toByte(String, byte) 2 failed");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -236,8 +236,8 @@ public class NumberUtilsTest {
|
|||
*/
|
||||
@Test
|
||||
public void testToShortStringI() {
|
||||
assertEquals(12345, NumberUtils.toShort("12345", (short) 5), "toShort(String,short) 1 failed");
|
||||
assertEquals(5, NumberUtils.toShort("1234.5", (short) 5), "toShort(String,short) 2 failed");
|
||||
assertEquals(12345, NumberUtils.toShort("12345", (short) 5), "toShort(String, short) 1 failed");
|
||||
assertEquals(5, NumberUtils.toShort("1234.5", (short) 5), "toShort(String, short) 2 failed");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -429,7 +429,7 @@ public class NumberUtilsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testLang1087(){
|
||||
public void testLang1087() {
|
||||
// no sign cases
|
||||
assertEquals(Float.class, NumberUtils.createNumber("0.0").getClass());
|
||||
assertEquals(Float.valueOf("0.0"), NumberUtils.createNumber("0.0"));
|
||||
|
@ -544,16 +544,16 @@ public class NumberUtilsTest {
|
|||
|
||||
assertEquals(Long.valueOf(0x7fffffffffffffffL), NumberUtils.createNumber("0x7fffffffffffffff"));
|
||||
// Does not appear to be a way to create a literal BigInteger of this magnitude
|
||||
assertEquals(new BigInteger("7fffffffffffffff0",16), NumberUtils.createNumber("0x7fffffffffffffff0"));
|
||||
assertEquals(new BigInteger("7fffffffffffffff0", 16), NumberUtils.createNumber("0x7fffffffffffffff0"));
|
||||
|
||||
assertEquals(Long.valueOf(0x7fffffffffffffffL), NumberUtils.createNumber("#7fffffffffffffff"));
|
||||
assertEquals(new BigInteger("7fffffffffffffff0",16), NumberUtils.createNumber("#7fffffffffffffff0"));
|
||||
assertEquals(new BigInteger("7fffffffffffffff0", 16), NumberUtils.createNumber("#7fffffffffffffff0"));
|
||||
|
||||
assertEquals(Integer.valueOf(017777777777), NumberUtils.createNumber("017777777777")); // 31 bits
|
||||
assertEquals(Long.valueOf(037777777777L), NumberUtils.createNumber("037777777777")); // 32 bits
|
||||
|
||||
assertEquals(Long.valueOf(0777777777777777777777L), NumberUtils.createNumber("0777777777777777777777")); // 63 bits
|
||||
assertEquals(new BigInteger("1777777777777777777777",8), NumberUtils.createNumber("01777777777777777777777"));// 64 bits
|
||||
assertEquals(new BigInteger("1777777777777777777777", 8), NumberUtils.createNumber("01777777777777777777777")); // 64 bits
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -935,20 +935,20 @@ public class NumberUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testMinimumLong() {
|
||||
assertEquals(12345L, NumberUtils.min(12345L, 12345L + 1L, 12345L + 2L), "minimum(long,long,long) 1 failed");
|
||||
assertEquals(12345L, NumberUtils.min(12345L + 1L, 12345L, 12345 + 2L), "minimum(long,long,long) 2 failed");
|
||||
assertEquals(12345L, NumberUtils.min(12345L + 1L, 12345L + 2L, 12345L), "minimum(long,long,long) 3 failed");
|
||||
assertEquals(12345L, NumberUtils.min(12345L + 1L, 12345L, 12345L), "minimum(long,long,long) 4 failed");
|
||||
assertEquals(12345L, NumberUtils.min(12345L, 12345L, 12345L), "minimum(long,long,long) 5 failed");
|
||||
assertEquals(12345L, NumberUtils.min(12345L, 12345L + 1L, 12345L + 2L), "minimum(long, long, long) 1 failed");
|
||||
assertEquals(12345L, NumberUtils.min(12345L + 1L, 12345L, 12345 + 2L), "minimum(long, long, long) 2 failed");
|
||||
assertEquals(12345L, NumberUtils.min(12345L + 1L, 12345L + 2L, 12345L), "minimum(long, long, long) 3 failed");
|
||||
assertEquals(12345L, NumberUtils.min(12345L + 1L, 12345L, 12345L), "minimum(long, long, long) 4 failed");
|
||||
assertEquals(12345L, NumberUtils.min(12345L, 12345L, 12345L), "minimum(long, long, long) 5 failed");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimumInt() {
|
||||
assertEquals(12345, NumberUtils.min(12345, 12345 + 1, 12345 + 2), "minimum(int,int,int) 1 failed");
|
||||
assertEquals(12345, NumberUtils.min(12345 + 1, 12345, 12345 + 2), "minimum(int,int,int) 2 failed");
|
||||
assertEquals(12345, NumberUtils.min(12345 + 1, 12345 + 2, 12345), "minimum(int,int,int) 3 failed");
|
||||
assertEquals(12345, NumberUtils.min(12345 + 1, 12345, 12345), "minimum(int,int,int) 4 failed");
|
||||
assertEquals(12345, NumberUtils.min(12345, 12345, 12345), "minimum(int,int,int) 5 failed");
|
||||
assertEquals(12345, NumberUtils.min(12345, 12345 + 1, 12345 + 2), "minimum(int, int, int) 1 failed");
|
||||
assertEquals(12345, NumberUtils.min(12345 + 1, 12345, 12345 + 2), "minimum(int, int, int) 2 failed");
|
||||
assertEquals(12345, NumberUtils.min(12345 + 1, 12345 + 2, 12345), "minimum(int, int, int) 3 failed");
|
||||
assertEquals(12345, NumberUtils.min(12345 + 1, 12345, 12345), "minimum(int, int, int) 4 failed");
|
||||
assertEquals(12345, NumberUtils.min(12345, 12345, 12345), "minimum(int, int, int) 5 failed");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -956,10 +956,10 @@ public class NumberUtilsTest {
|
|||
final short low = 1234;
|
||||
final short mid = 1234 + 1;
|
||||
final short high = 1234 + 2;
|
||||
assertEquals(low, NumberUtils.min(low, mid, high), "minimum(short,short,short) 1 failed");
|
||||
assertEquals(low, NumberUtils.min(mid, low, high), "minimum(short,short,short) 2 failed");
|
||||
assertEquals(low, NumberUtils.min(mid, high, low), "minimum(short,short,short) 3 failed");
|
||||
assertEquals(low, NumberUtils.min(low, mid, low), "minimum(short,short,short) 4 failed");
|
||||
assertEquals(low, NumberUtils.min(low, mid, high), "minimum(short, short, short) 1 failed");
|
||||
assertEquals(low, NumberUtils.min(mid, low, high), "minimum(short, short, short) 2 failed");
|
||||
assertEquals(low, NumberUtils.min(mid, high, low), "minimum(short, short, short) 3 failed");
|
||||
assertEquals(low, NumberUtils.min(low, mid, low), "minimum(short, short, short) 4 failed");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -967,10 +967,10 @@ public class NumberUtilsTest {
|
|||
final byte low = 123;
|
||||
final byte mid = 123 + 1;
|
||||
final byte high = 123 + 2;
|
||||
assertEquals(low, NumberUtils.min(low, mid, high), "minimum(byte,byte,byte) 1 failed");
|
||||
assertEquals(low, NumberUtils.min(mid, low, high), "minimum(byte,byte,byte) 2 failed");
|
||||
assertEquals(low, NumberUtils.min(mid, high, low), "minimum(byte,byte,byte) 3 failed");
|
||||
assertEquals(low, NumberUtils.min(low, mid, low), "minimum(byte,byte,byte) 4 failed");
|
||||
assertEquals(low, NumberUtils.min(low, mid, high), "minimum(byte, byte, byte) 1 failed");
|
||||
assertEquals(low, NumberUtils.min(mid, low, high), "minimum(byte, byte, byte) 2 failed");
|
||||
assertEquals(low, NumberUtils.min(mid, high, low), "minimum(byte, byte, byte) 3 failed");
|
||||
assertEquals(low, NumberUtils.min(low, mid, low), "minimum(byte, byte, byte) 4 failed");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -999,20 +999,20 @@ public class NumberUtilsTest {
|
|||
|
||||
@Test
|
||||
public void testMaximumLong() {
|
||||
assertEquals(12345L, NumberUtils.max(12345L, 12345L - 1L, 12345L - 2L), "maximum(long,long,long) 1 failed");
|
||||
assertEquals(12345L, NumberUtils.max(12345L - 1L, 12345L, 12345L - 2L), "maximum(long,long,long) 2 failed");
|
||||
assertEquals(12345L, NumberUtils.max(12345L - 1L, 12345L - 2L, 12345L), "maximum(long,long,long) 3 failed");
|
||||
assertEquals(12345L, NumberUtils.max(12345L - 1L, 12345L, 12345L), "maximum(long,long,long) 4 failed");
|
||||
assertEquals(12345L, NumberUtils.max(12345L, 12345L, 12345L), "maximum(long,long,long) 5 failed");
|
||||
assertEquals(12345L, NumberUtils.max(12345L, 12345L - 1L, 12345L - 2L), "maximum(long, long, long) 1 failed");
|
||||
assertEquals(12345L, NumberUtils.max(12345L - 1L, 12345L, 12345L - 2L), "maximum(long, long, long) 2 failed");
|
||||
assertEquals(12345L, NumberUtils.max(12345L - 1L, 12345L - 2L, 12345L), "maximum(long, long, long) 3 failed");
|
||||
assertEquals(12345L, NumberUtils.max(12345L - 1L, 12345L, 12345L), "maximum(long, long, long) 4 failed");
|
||||
assertEquals(12345L, NumberUtils.max(12345L, 12345L, 12345L), "maximum(long, long, long) 5 failed");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMaximumInt() {
|
||||
assertEquals(12345, NumberUtils.max(12345, 12345 - 1, 12345 - 2), "maximum(int,int,int) 1 failed");
|
||||
assertEquals(12345, NumberUtils.max(12345 - 1, 12345, 12345 - 2), "maximum(int,int,int) 2 failed");
|
||||
assertEquals(12345, NumberUtils.max(12345 - 1, 12345 - 2, 12345), "maximum(int,int,int) 3 failed");
|
||||
assertEquals(12345, NumberUtils.max(12345 - 1, 12345, 12345), "maximum(int,int,int) 4 failed");
|
||||
assertEquals(12345, NumberUtils.max(12345, 12345, 12345), "maximum(int,int,int) 5 failed");
|
||||
assertEquals(12345, NumberUtils.max(12345, 12345 - 1, 12345 - 2), "maximum(int, int, int) 1 failed");
|
||||
assertEquals(12345, NumberUtils.max(12345 - 1, 12345, 12345 - 2), "maximum(int, int, int) 2 failed");
|
||||
assertEquals(12345, NumberUtils.max(12345 - 1, 12345 - 2, 12345), "maximum(int, int, int) 3 failed");
|
||||
assertEquals(12345, NumberUtils.max(12345 - 1, 12345, 12345), "maximum(int, int, int) 4 failed");
|
||||
assertEquals(12345, NumberUtils.max(12345, 12345, 12345), "maximum(int, int, int) 5 failed");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1020,10 +1020,10 @@ public class NumberUtilsTest {
|
|||
final short low = 1234;
|
||||
final short mid = 1234 + 1;
|
||||
final short high = 1234 + 2;
|
||||
assertEquals(high, NumberUtils.max(low, mid, high), "maximum(short,short,short) 1 failed");
|
||||
assertEquals(high, NumberUtils.max(mid, low, high), "maximum(short,short,short) 2 failed");
|
||||
assertEquals(high, NumberUtils.max(mid, high, low), "maximum(short,short,short) 3 failed");
|
||||
assertEquals(high, NumberUtils.max(high, mid, high), "maximum(short,short,short) 4 failed");
|
||||
assertEquals(high, NumberUtils.max(low, mid, high), "maximum(short, short, short) 1 failed");
|
||||
assertEquals(high, NumberUtils.max(mid, low, high), "maximum(short, short, short) 2 failed");
|
||||
assertEquals(high, NumberUtils.max(mid, high, low), "maximum(short, short, short) 3 failed");
|
||||
assertEquals(high, NumberUtils.max(high, mid, high), "maximum(short, short, short) 4 failed");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1031,10 +1031,10 @@ public class NumberUtilsTest {
|
|||
final byte low = 123;
|
||||
final byte mid = 123 + 1;
|
||||
final byte high = 123 + 2;
|
||||
assertEquals(high, NumberUtils.max(low, mid, high), "maximum(byte,byte,byte) 1 failed");
|
||||
assertEquals(high, NumberUtils.max(mid, low, high), "maximum(byte,byte,byte) 2 failed");
|
||||
assertEquals(high, NumberUtils.max(mid, high, low), "maximum(byte,byte,byte) 3 failed");
|
||||
assertEquals(high, NumberUtils.max(high, mid, high), "maximum(byte,byte,byte) 4 failed");
|
||||
assertEquals(high, NumberUtils.max(low, mid, high), "maximum(byte, byte, byte) 1 failed");
|
||||
assertEquals(high, NumberUtils.max(mid, low, high), "maximum(byte, byte, byte) 2 failed");
|
||||
assertEquals(high, NumberUtils.max(mid, high, low), "maximum(byte, byte, byte) 3 failed");
|
||||
assertEquals(high, NumberUtils.max(high, mid, high), "maximum(byte, byte, byte) 4 failed");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1464,7 +1464,7 @@ public class NumberUtilsTest {
|
|||
assertFalse( NumberUtils.isParsable("0xC1AB") );
|
||||
assertFalse( NumberUtils.isParsable("65CBA2") );
|
||||
assertFalse( NumberUtils.isParsable("pendro") );
|
||||
assertFalse( NumberUtils.isParsable("64,2") );
|
||||
assertFalse( NumberUtils.isParsable("64, 2") );
|
||||
assertFalse( NumberUtils.isParsable("64.2.2") );
|
||||
assertFalse( NumberUtils.isParsable("64.") );
|
||||
assertFalse( NumberUtils.isParsable("64L") );
|
||||
|
@ -1576,15 +1576,15 @@ public class NumberUtilsTest {
|
|||
|
||||
@Test
|
||||
public void compareShort() {
|
||||
assertTrue(NumberUtils.compare((short)-3, (short)0) < 0);
|
||||
assertTrue(NumberUtils.compare((short) -3, (short) 0) < 0);
|
||||
assertEquals(0, NumberUtils.compare((short) 113, (short) 113));
|
||||
assertTrue(NumberUtils.compare((short)213, (short)32) > 0);
|
||||
assertTrue(NumberUtils.compare((short) 213, (short) 32) > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void compareByte() {
|
||||
assertTrue(NumberUtils.compare((byte)-3, (byte)0) < 0);
|
||||
assertTrue(NumberUtils.compare((byte) -3, (byte) 0) < 0);
|
||||
assertEquals(0, NumberUtils.compare((byte) 113, (byte) 113));
|
||||
assertTrue(NumberUtils.compare((byte)123, (byte)32) > 0);
|
||||
assertTrue(NumberUtils.compare((byte) 123, (byte) 32) > 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class MutableByteTest {
|
|||
|
||||
@Test
|
||||
public void testConstructorNull() {
|
||||
assertThrows(NullPointerException.class, () -> new MutableByte((Number)null));
|
||||
assertThrows(NullPointerException.class, () -> new MutableByte((Number) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -202,7 +202,7 @@ public class MutableByteTest {
|
|||
@Test
|
||||
public void testAddValuePrimitive() {
|
||||
final MutableByte mutNum = new MutableByte((byte) 1);
|
||||
mutNum.add((byte)1);
|
||||
mutNum.add((byte) 1);
|
||||
|
||||
assertEquals((byte) 2, mutNum.byteValue());
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ public class MutableByteTest {
|
|||
|
||||
@Test
|
||||
public void testGetAndAddValuePrimitive() {
|
||||
final MutableByte mutableByte = new MutableByte((byte)0);
|
||||
final MutableByte mutableByte = new MutableByte((byte) 0);
|
||||
final byte result = mutableByte.getAndAdd((byte) 1);
|
||||
|
||||
assertEquals((byte) 0, result);
|
||||
|
@ -226,7 +226,7 @@ public class MutableByteTest {
|
|||
|
||||
@Test
|
||||
public void testGetAndAddValueObject() {
|
||||
final MutableByte mutableByte = new MutableByte((byte)0);
|
||||
final MutableByte mutableByte = new MutableByte((byte) 0);
|
||||
final byte result = mutableByte.getAndAdd(Byte.valueOf((byte) 1));
|
||||
|
||||
assertEquals((byte) 0, result);
|
||||
|
@ -235,7 +235,7 @@ public class MutableByteTest {
|
|||
|
||||
@Test
|
||||
public void testAddAndGetValuePrimitive() {
|
||||
final MutableByte mutableByte = new MutableByte((byte)0);
|
||||
final MutableByte mutableByte = new MutableByte((byte) 0);
|
||||
final byte result = mutableByte.addAndGet((byte) 1);
|
||||
|
||||
assertEquals((byte) 1, result);
|
||||
|
@ -244,7 +244,7 @@ public class MutableByteTest {
|
|||
|
||||
@Test
|
||||
public void testAddAndGetValueObject() {
|
||||
final MutableByte mutableByte = new MutableByte((byte)0);
|
||||
final MutableByte mutableByte = new MutableByte((byte) 0);
|
||||
final byte result = mutableByte.addAndGet(Byte.valueOf((byte) 1));
|
||||
|
||||
assertEquals((byte) 1, result);
|
||||
|
|
|
@ -47,7 +47,7 @@ public class MutableDoubleTest {
|
|||
|
||||
@Test
|
||||
public void testConstructorNull() {
|
||||
assertThrows(NullPointerException.class, () -> new MutableDouble((Number)null));
|
||||
assertThrows(NullPointerException.class, () -> new MutableDouble((Number) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -47,7 +47,7 @@ public class MutableFloatTest {
|
|||
|
||||
@Test
|
||||
public void testConstructorNull() {
|
||||
assertThrows(NullPointerException.class, () -> new MutableFloat((Number)null));
|
||||
assertThrows(NullPointerException.class, () -> new MutableFloat((Number) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -47,7 +47,7 @@ public class MutableIntTest {
|
|||
|
||||
@Test
|
||||
public void testConstructorNull() {
|
||||
assertThrows(NullPointerException.class, () -> new MutableInt((Number)null));
|
||||
assertThrows(NullPointerException.class, () -> new MutableInt((Number) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -47,7 +47,7 @@ public class MutableLongTest {
|
|||
|
||||
@Test
|
||||
public void testConstructorNull() {
|
||||
assertThrows(NullPointerException.class, () -> new MutableLong((Number)null));
|
||||
assertThrows(NullPointerException.class, () -> new MutableLong((Number) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -43,7 +43,7 @@ public class MutableShortTest {
|
|||
|
||||
assertEquals((short) 2, new MutableShort("2").shortValue());
|
||||
|
||||
assertThrows(NullPointerException.class, () -> new MutableShort((Number)null));
|
||||
assertThrows(NullPointerException.class, () -> new MutableShort((Number) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -203,7 +203,7 @@ public class MutableShortTest {
|
|||
|
||||
@Test
|
||||
public void testGetAndAddValuePrimitive() {
|
||||
final MutableShort mutableShort = new MutableShort((short)0);
|
||||
final MutableShort mutableShort = new MutableShort((short) 0);
|
||||
final short result = mutableShort.getAndAdd((short) 1);
|
||||
|
||||
assertEquals((short) 0, result);
|
||||
|
@ -212,7 +212,7 @@ public class MutableShortTest {
|
|||
|
||||
@Test
|
||||
public void testGetAndAddValueObject() {
|
||||
final MutableShort mutableShort = new MutableShort((short)0);
|
||||
final MutableShort mutableShort = new MutableShort((short) 0);
|
||||
final short result = mutableShort.getAndAdd(Short.valueOf((short) 1));
|
||||
|
||||
assertEquals((short) 0, result);
|
||||
|
|
|
@ -90,7 +90,7 @@ public class ConstructorUtilsTest {
|
|||
public TestBean(final Integer first, final int... args) {
|
||||
toString = "(Integer, String...)";
|
||||
varArgs = new String[args.length];
|
||||
for(int i = 0; i< args.length; ++i) {
|
||||
for (int i = 0; i< args.length; ++i) {
|
||||
varArgs[i] = Integer.toString(args[i]);
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ public class ConstructorUtilsTest {
|
|||
|
||||
assertThrows(
|
||||
NoSuchMethodException.class,
|
||||
() -> ConstructorUtils.invokeExactConstructor(TestBean.class,NumberUtils.BYTE_ONE));
|
||||
() -> ConstructorUtils.invokeExactConstructor(TestBean.class, NumberUtils.BYTE_ONE));
|
||||
assertThrows(
|
||||
NoSuchMethodException.class,
|
||||
() -> ConstructorUtils.invokeExactConstructor(TestBean.class, NumberUtils.LONG_ONE));
|
||||
|
|
|
@ -231,7 +231,7 @@ public class FieldUtilsTest {
|
|||
FieldUtilsTest.class.getDeclaredField("privatelyShadowedChild")
|
||||
);
|
||||
final List<Field> fieldUtilsTestAnnotatedFields = FieldUtils.getFieldsListWithAnnotation(FieldUtilsTest.class, Annotated.class);
|
||||
assertEquals(annotatedFields.size(),fieldUtilsTestAnnotatedFields.size());
|
||||
assertEquals(annotatedFields.size(), fieldUtilsTestAnnotatedFields.size());
|
||||
assertTrue(fieldUtilsTestAnnotatedFields.contains(annotatedFields.get(0)));
|
||||
assertTrue(fieldUtilsTestAnnotatedFields.contains(annotatedFields.get(1)));
|
||||
}
|
||||
|
|
|
@ -744,7 +744,7 @@ public class TypeUtilsTest<B> {
|
|||
@Test
|
||||
public void testLang1114() throws Exception {
|
||||
final Type nonWildcardType = getClass().getDeclaredField("wildcardComparable").getGenericType();
|
||||
final Type wildcardType = ((ParameterizedType)nonWildcardType).getActualTypeArguments()[0];
|
||||
final Type wildcardType = ((ParameterizedType) nonWildcardType).getActualTypeArguments()[0];
|
||||
|
||||
assertFalse(TypeUtils.equals(wildcardType, nonWildcardType));
|
||||
assertFalse(TypeUtils.equals(nonWildcardType, wildcardType));
|
||||
|
|
|
@ -405,7 +405,7 @@ public class ExtendedMessageFormatTest {
|
|||
|
||||
@Override
|
||||
public StringBuffer format(final Object obj, final StringBuffer toAppendTo, final FieldPosition pos) {
|
||||
return toAppendTo.append(((String)obj).toLowerCase(Locale.ROOT));
|
||||
return toAppendTo.append(((String) obj).toLowerCase(Locale.ROOT));
|
||||
}
|
||||
@Override
|
||||
public Object parseObject(final String source, final ParsePosition pos) {
|
||||
|
|
|
@ -202,7 +202,7 @@ public class StrBuilderAppendInsertTest {
|
|||
sb.append("abcbardef", 3, 3);
|
||||
assertEquals("foobar", sb.toString());
|
||||
|
||||
sb.append( (CharSequence)"abcbardef", 4, 3);
|
||||
sb.append((CharSequence) "abcbardef", 4, 3);
|
||||
assertEquals("foobarard", sb.toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -418,11 +418,11 @@ public class StrBuilderTest {
|
|||
assertThrows(
|
||||
IndexOutOfBoundsException.class,
|
||||
() -> sb.setCharAt(0, 'f'),
|
||||
"setCharAt(0,) expected IndexOutOfBoundsException");
|
||||
"setCharAt(0, ) expected IndexOutOfBoundsException");
|
||||
assertThrows(
|
||||
IndexOutOfBoundsException.class,
|
||||
() -> sb.setCharAt(-1, 'f'),
|
||||
"setCharAt(-1,) expected IndexOutOfBoundsException");
|
||||
"setCharAt(-1, ) expected IndexOutOfBoundsException");
|
||||
sb.append("foo");
|
||||
sb.setCharAt(0, 'b');
|
||||
sb.setCharAt(1, 'a');
|
||||
|
@ -430,7 +430,7 @@ public class StrBuilderTest {
|
|||
assertThrows(
|
||||
IndexOutOfBoundsException.class,
|
||||
() -> sb.setCharAt(3, '!'),
|
||||
"setCharAt(3,) expected IndexOutOfBoundsException");
|
||||
"setCharAt(3, ) expected IndexOutOfBoundsException");
|
||||
assertEquals("bar", sb.toString());
|
||||
}
|
||||
|
||||
|
@ -467,19 +467,19 @@ public class StrBuilderTest {
|
|||
|
||||
sb.append("junit");
|
||||
char[] a = sb.toCharArray(0, 20); // too large test
|
||||
assertEquals(5, a.length, "toCharArray(int,int) result incorrect length");
|
||||
assertTrue(Arrays.equals("junit".toCharArray(), a), "toCharArray(int,int) result does not match");
|
||||
assertEquals(5, a.length, "toCharArray(int, int) result incorrect length");
|
||||
assertTrue(Arrays.equals("junit".toCharArray(), a), "toCharArray(int, int) result does not match");
|
||||
|
||||
a = sb.toCharArray(0, 4);
|
||||
assertEquals(4, a.length, "toCharArray(int,int) result incorrect length");
|
||||
assertTrue(Arrays.equals("juni".toCharArray(), a), "toCharArray(int,int) result does not match");
|
||||
assertEquals(4, a.length, "toCharArray(int, int) result incorrect length");
|
||||
assertTrue(Arrays.equals("juni".toCharArray(), a), "toCharArray(int, int) result does not match");
|
||||
|
||||
a = sb.toCharArray(0, 4);
|
||||
assertEquals(4, a.length, "toCharArray(int,int) result incorrect length");
|
||||
assertTrue(Arrays.equals("juni".toCharArray(), a), "toCharArray(int,int) result does not match");
|
||||
assertEquals(4, a.length, "toCharArray(int, int) result incorrect length");
|
||||
assertTrue(Arrays.equals("juni".toCharArray(), a), "toCharArray(int, int) result does not match");
|
||||
|
||||
a = sb.toCharArray(0, 1);
|
||||
assertNotNull(a, "toCharArray(int,int) result is null");
|
||||
assertNotNull(a, "toCharArray(int, int) result is null");
|
||||
|
||||
assertThrows(
|
||||
IndexOutOfBoundsException.class, () -> sb.toCharArray(-1, 5), "no string index out of bound on -1");
|
||||
|
@ -500,12 +500,12 @@ public class StrBuilderTest {
|
|||
sb.append("junit");
|
||||
a = sb.getChars(input);
|
||||
assertSame(input, a);
|
||||
assertTrue(Arrays.equals(new char[] {'j','u','n','i','t',0,0,0,0,0},a));
|
||||
assertTrue(Arrays.equals(new char[] {'j', 'u', 'n', 'i', 't', 0, 0, 0, 0, 0}, a));
|
||||
|
||||
a = sb.getChars(null);
|
||||
assertNotSame(input,a);
|
||||
assertEquals(5,a.length);
|
||||
assertTrue(Arrays.equals("junit".toCharArray(),a));
|
||||
assertNotSame(input, a);
|
||||
assertEquals(5, a.length);
|
||||
assertTrue(Arrays.equals("junit".toCharArray(), a));
|
||||
|
||||
input = new char[5];
|
||||
a = sb.getChars(input);
|
||||
|
@ -522,17 +522,17 @@ public class StrBuilderTest {
|
|||
|
||||
sb.append("junit");
|
||||
char[] a = new char[5];
|
||||
sb.getChars(0,5,a,0);
|
||||
assertTrue(Arrays.equals(new char[] {'j','u','n','i','t'},a));
|
||||
sb.getChars(0, 5, a, 0);
|
||||
assertTrue(Arrays.equals(new char[] {'j', 'u', 'n', 'i', 't'}, a));
|
||||
|
||||
final char[] b = new char[5];
|
||||
sb.getChars(0,2,b,3);
|
||||
assertTrue(Arrays.equals(new char[] {0,0,0,'j','u'},b));
|
||||
sb.getChars(0, 2, b, 3);
|
||||
assertTrue(Arrays.equals(new char[] {0, 0, 0, 'j', 'u'}, b));
|
||||
|
||||
assertThrows(IndexOutOfBoundsException.class, () -> sb.getChars(-1,0,b,0));
|
||||
assertThrows(IndexOutOfBoundsException.class, () -> sb.getChars(0,-1,b,0));
|
||||
assertThrows(IndexOutOfBoundsException.class, () -> sb.getChars(0,20,b,0));
|
||||
assertThrows(IndexOutOfBoundsException.class, () -> sb.getChars(4,2,b,0));
|
||||
assertThrows(IndexOutOfBoundsException.class, () -> sb.getChars(-1, 0, b, 0));
|
||||
assertThrows(IndexOutOfBoundsException.class, () -> sb.getChars(0, -1, b, 0));
|
||||
assertThrows(IndexOutOfBoundsException.class, () -> sb.getChars(0, 20, b, 0));
|
||||
assertThrows(IndexOutOfBoundsException.class, () -> sb.getChars(4, 2, b, 0));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
@ -1141,7 +1141,7 @@ public class StrBuilderTest {
|
|||
assertEquals ("hello", sb.subSequence(0, 5));
|
||||
assertEquals ("hello goodbye".subSequence(0, 6), sb.subSequence(0, 6));
|
||||
assertEquals ("goodbye", sb.subSequence(6, 13));
|
||||
assertEquals ("hello goodbye".subSequence(6,13), sb.subSequence(6, 13));
|
||||
assertEquals ("hello goodbye".subSequence(6, 13), sb.subSequence(6, 13));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1163,7 +1163,7 @@ public class StrBuilderTest {
|
|||
assertEquals ("hello goodbye".substring(0, 6), sb.substring(0, 6));
|
||||
|
||||
assertEquals ("goodbye", sb.substring(6, 13));
|
||||
assertEquals ("hello goodbye".substring(6,13), sb.substring(6, 13));
|
||||
assertEquals ("hello goodbye".substring(6, 13), sb.substring(6, 13));
|
||||
|
||||
assertEquals ("goodbye", sb.substring(6, 20));
|
||||
|
||||
|
|
|
@ -580,7 +580,7 @@ public class StrSubstitutorTest {
|
|||
* Test the replace of a properties object
|
||||
*/
|
||||
@Test
|
||||
public void testSubstituteDefaultProperties(){
|
||||
public void testSubstituteDefaultProperties() {
|
||||
final String org = "${doesnotwork}";
|
||||
System.setProperty("doesnotwork", "It works!");
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ public class StrTokenizerTest {
|
|||
tok.setIgnoreEmptyTokens(false);
|
||||
final String tokens[] = tok.getTokenArray();
|
||||
|
||||
final String expected[] = new String[]{"a", "b", "c", "d;\"e", "f", "", "", "",};
|
||||
final String expected[] = new String[]{"a", "b", "c", "d;\"e", "f", "", "", ""};
|
||||
|
||||
assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens));
|
||||
for (int i = 0; i < expected.length; i++) {
|
||||
|
@ -81,7 +81,7 @@ public class StrTokenizerTest {
|
|||
tok.setIgnoreEmptyTokens(false);
|
||||
final String tokens[] = tok.getTokenArray();
|
||||
|
||||
final String expected[] = new String[]{"a", "b", "c ", "d;\"e", "f", " ", " ", "",};
|
||||
final String expected[] = new String[]{"a", "b", "c ", "d;\"e", "f", " ", " ", ""};
|
||||
|
||||
assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens));
|
||||
for (int i = 0; i < expected.length; i++) {
|
||||
|
@ -102,7 +102,7 @@ public class StrTokenizerTest {
|
|||
tok.setIgnoreEmptyTokens(false);
|
||||
final String tokens[] = tok.getTokenArray();
|
||||
|
||||
final String expected[] = new String[]{"a", "b", " c", "d;\"e", "f", " ", " ", "",};
|
||||
final String expected[] = new String[]{"a", "b", " c", "d;\"e", "f", " ", " ", ""};
|
||||
|
||||
assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens));
|
||||
for (int i = 0; i < expected.length; i++) {
|
||||
|
@ -123,7 +123,7 @@ public class StrTokenizerTest {
|
|||
tok.setIgnoreEmptyTokens(true);
|
||||
final String tokens[] = tok.getTokenArray();
|
||||
|
||||
final String expected[] = new String[]{"a", "b", "c", "d;\"e", "f",};
|
||||
final String expected[] = new String[]{"a", "b", "c", "d;\"e", "f"};
|
||||
|
||||
assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens));
|
||||
for (int i = 0; i < expected.length; i++) {
|
||||
|
@ -145,7 +145,7 @@ public class StrTokenizerTest {
|
|||
tok.setEmptyTokenAsNull(true);
|
||||
final String tokens[] = tok.getTokenArray();
|
||||
|
||||
final String expected[] = new String[]{"a", "b", "c", "d;\"e", "f", null, null, null,};
|
||||
final String expected[] = new String[]{"a", "b", "c", "d;\"e", "f", null, null, null};
|
||||
|
||||
assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens));
|
||||
for (int i = 0; i < expected.length; i++) {
|
||||
|
@ -167,7 +167,7 @@ public class StrTokenizerTest {
|
|||
// tok.setTreatingEmptyAsNull(true);
|
||||
final String tokens[] = tok.getTokenArray();
|
||||
|
||||
final String expected[] = new String[]{"a", "b", " c", "d;\"e", "f", null, null, null,};
|
||||
final String expected[] = new String[]{"a", "b", " c", "d;\"e", "f", null, null, null};
|
||||
|
||||
int nextCount = 0;
|
||||
while (tok.hasNext()) {
|
||||
|
@ -200,7 +200,7 @@ public class StrTokenizerTest {
|
|||
tok.setIgnoreEmptyTokens(false);
|
||||
final String tokens[] = tok.getTokenArray();
|
||||
|
||||
final String expected[] = new String[]{"a", "", "", "b", "c", "d e", "f", "",};
|
||||
final String expected[] = new String[]{"a", "", "", "b", "c", "d e", "f", ""};
|
||||
|
||||
assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens));
|
||||
for (int i = 0; i < expected.length; i++) {
|
||||
|
@ -221,7 +221,7 @@ public class StrTokenizerTest {
|
|||
tok.setIgnoreEmptyTokens(true);
|
||||
final String tokens[] = tok.getTokenArray();
|
||||
|
||||
final String expected[] = new String[]{"a", "b", "c", "d e", "f",};
|
||||
final String expected[] = new String[]{"a", "b", "c", "d e", "f"};
|
||||
|
||||
assertEquals(expected.length, tokens.length, ArrayUtils.toString(tokens));
|
||||
for (int i = 0; i < expected.length; i++) {
|
||||
|
|
|
@ -424,7 +424,7 @@ public class WordUtilsTest {
|
|||
// Prior to fix, this was throwing StringIndexOutOfBoundsException
|
||||
WordUtils.wrap("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "
|
||||
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "
|
||||
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",70);
|
||||
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 70);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -37,11 +37,11 @@ public class EntityArraysTest {
|
|||
|
||||
// LANG-659 - check arrays for duplicate entries
|
||||
@Test
|
||||
public void testHTML40_EXTENDED_ESCAPE(){
|
||||
public void testHTML40_EXTENDED_ESCAPE() {
|
||||
final Set<String> col0 = new HashSet<>();
|
||||
final Set<String> col1 = new HashSet<>();
|
||||
final String [][] sa = EntityArrays.HTML40_EXTENDED_ESCAPE();
|
||||
for(int i =0; i <sa.length; i++){
|
||||
for (int i =0; i <sa.length; i++) {
|
||||
assertTrue(col0.add(sa[i][0]), "Already added entry 0: "+i+" "+sa[i][0]);
|
||||
assertTrue(col1.add(sa[i][1]), "Already added entry 1: "+i+" "+sa[i][1]);
|
||||
}
|
||||
|
@ -49,12 +49,12 @@ public class EntityArraysTest {
|
|||
|
||||
// LANG-658 - check arrays for duplicate entries
|
||||
@Test
|
||||
public void testISO8859_1_ESCAPE(){
|
||||
public void testISO8859_1_ESCAPE() {
|
||||
final Set<String> col0 = new HashSet<>();
|
||||
final Set<String> col1 = new HashSet<>();
|
||||
final String [][] sa = EntityArrays.ISO8859_1_ESCAPE();
|
||||
boolean success = true;
|
||||
for(int i =0; i <sa.length; i++){
|
||||
for (int i =0; i <sa.length; i++) {
|
||||
final boolean add0 = col0.add(sa[i][0]);
|
||||
final boolean add1 = col1.add(sa[i][1]);
|
||||
if (!add0) {
|
||||
|
|
|
@ -319,9 +319,9 @@ public class DateUtilsFragmentTest {
|
|||
public void testMinutesOfDayWithDate() {
|
||||
long testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.DATE);
|
||||
final long expectedValue = minutes + ((hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_MINUTE;
|
||||
assertEquals(expectedValue,testResult);
|
||||
assertEquals(expectedValue, testResult);
|
||||
testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.DAY_OF_YEAR);
|
||||
assertEquals(expectedValue,testResult);
|
||||
assertEquals(expectedValue, testResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -337,9 +337,9 @@ public class DateUtilsFragmentTest {
|
|||
public void testHoursOfDayWithDate() {
|
||||
long testResult = DateUtils.getFragmentInHours(aDate, Calendar.DATE);
|
||||
final long expectedValue = hours;
|
||||
assertEquals(expectedValue,testResult);
|
||||
assertEquals(expectedValue, testResult);
|
||||
testResult = DateUtils.getFragmentInHours(aDate, Calendar.DAY_OF_YEAR);
|
||||
assertEquals(expectedValue,testResult);
|
||||
assertEquals(expectedValue, testResult);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1521,7 +1521,7 @@ public class DateUtilsTest {
|
|||
it3.next();
|
||||
assertThrows(UnsupportedOperationException.class, it3::remove);
|
||||
|
||||
now.add(Calendar.DATE,1);
|
||||
now.add(Calendar.DATE, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -435,9 +435,9 @@ public class DurationFormatUtilsTest {
|
|||
// Testing the under a day range in DurationFormatUtils.formatPeriod
|
||||
@Test
|
||||
public void testLowDurations() {
|
||||
for(int hr=0; hr < 24; hr++) {
|
||||
for(int min=0; min < 60; min++) {
|
||||
for(int sec=0; sec < 60; sec++) {
|
||||
for (int hr=0; hr < 24; hr++) {
|
||||
for (int min=0; min < 60; min++) {
|
||||
for (int sec=0; sec < 60; sec++) {
|
||||
assertEqualDuration( hr + ":" + min + ":" + sec,
|
||||
new int[] { 2000, 0, 1, 0, 0, 0, 0 },
|
||||
new int[] { 2000, 0, 1, hr, min, sec },
|
||||
|
|
|
@ -256,11 +256,11 @@ public class FastDateFormatTest {
|
|||
final AtomicInteger failures= new AtomicInteger(0);
|
||||
final AtomicLongArray totalElapsed= new AtomicLongArray(2);
|
||||
|
||||
for(int i= 0; i<NTHREADS; ++i) {
|
||||
for (int i= 0; i<NTHREADS; ++i) {
|
||||
pool.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for(int j= 0; j<NROUNDS; ++j) {
|
||||
for (int j= 0; j<NROUNDS; ++j) {
|
||||
try {
|
||||
final Date date= new Date();
|
||||
|
||||
|
@ -272,7 +272,7 @@ public class FastDateFormatTest {
|
|||
final Object pd= parser.parseObject(formattedDate);
|
||||
totalElapsed.addAndGet(1, System.currentTimeMillis() - t1);
|
||||
|
||||
if(!date.equals(pd)) {
|
||||
if (!date.equals(pd)) {
|
||||
failures.incrementAndGet();
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
|
@ -287,7 +287,7 @@ public class FastDateFormatTest {
|
|||
// depending on the performance of the machine used to run the parsing,
|
||||
// the tests can run for a while. It should however complete within
|
||||
// 30 seconds. Might need increase on very slow machines.
|
||||
if(!pool.awaitTermination(30, TimeUnit.SECONDS)) {
|
||||
if (!pool.awaitTermination(30, TimeUnit.SECONDS)) {
|
||||
pool.shutdownNow();
|
||||
fail("did not complete tasks");
|
||||
}
|
||||
|
|
|
@ -102,14 +102,14 @@ public class FastDateParserTest {
|
|||
getInstance(MDY_SLASH, REYKJAVIK, SWEDEN)
|
||||
};
|
||||
|
||||
final Map<DateParser,Integer> map= new HashMap<>();
|
||||
final Map<DateParser, Integer> map= new HashMap<>();
|
||||
int i= 0;
|
||||
for(final DateParser parser:parsers) {
|
||||
for (final DateParser parser:parsers) {
|
||||
map.put(parser, Integer.valueOf(i++));
|
||||
}
|
||||
|
||||
i= 0;
|
||||
for(final DateParser parser:parsers) {
|
||||
for (final DateParser parser:parsers) {
|
||||
assertEquals(i++, map.get(parser).intValue());
|
||||
}
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ public class FastDateParserTest {
|
|||
|
||||
// http://docs.oracle.com/javase/6/docs/technotes/guides/intl/calendar.doc.html
|
||||
if (locale.equals(FastDateParser.JAPANESE_IMPERIAL)) {
|
||||
if(year < 1868) {
|
||||
if (year < 1868) {
|
||||
cal.set(Calendar.ERA, 0);
|
||||
cal.set(Calendar.YEAR, 1868-year);
|
||||
}
|
||||
|
@ -236,10 +236,10 @@ public class FastDateParserTest {
|
|||
@Test
|
||||
// Check that all Locales can parse the formats we use
|
||||
public void testParses() throws Exception {
|
||||
for(final String format : new String[]{LONG_FORMAT, SHORT_FORMAT}) {
|
||||
for(final Locale locale : Locale.getAvailableLocales()) {
|
||||
for(final TimeZone tz : new TimeZone[]{NEW_YORK, REYKJAVIK, GMT}) {
|
||||
for(final int year : new int[]{2003, 1940, 1868, 1867, 1, -1, -1940}) {
|
||||
for (final String format : new String[]{LONG_FORMAT, SHORT_FORMAT}) {
|
||||
for (final Locale locale : Locale.getAvailableLocales()) {
|
||||
for (final TimeZone tz : new TimeZone[]{NEW_YORK, REYKJAVIK, GMT}) {
|
||||
for (final int year : new int[]{2003, 1940, 1868, 1867, 1, -1, -1940}) {
|
||||
final Calendar cal= getEraStart(year, tz, locale);
|
||||
final Date centuryStart= cal.getTime();
|
||||
|
||||
|
@ -260,10 +260,10 @@ public class FastDateParserTest {
|
|||
@Test
|
||||
public void testTzParses() throws Exception {
|
||||
// Check that all Locales can parse the time formats we use
|
||||
for(final Locale locale : Locale.getAvailableLocales()) {
|
||||
for (final Locale locale : Locale.getAvailableLocales()) {
|
||||
final FastDateParser fdp= new FastDateParser("yyyy/MM/dd z", TimeZone.getDefault(), locale);
|
||||
|
||||
for(final TimeZone tz : new TimeZone[]{NEW_YORK, REYKJAVIK, GMT}) {
|
||||
for (final TimeZone tz : new TimeZone[]{NEW_YORK, REYKJAVIK, GMT}) {
|
||||
final Calendar cal= Calendar.getInstance(tz, locale);
|
||||
cal.clear();
|
||||
cal.set(Calendar.YEAR, 2000);
|
||||
|
@ -327,7 +327,7 @@ public class FastDateParserTest {
|
|||
cal.set(Calendar.ERA, GregorianCalendar.BC);
|
||||
}
|
||||
|
||||
for(final Locale locale : Locale.getAvailableLocales() ) {
|
||||
for (final Locale locale : Locale.getAvailableLocales() ) {
|
||||
// ja_JP_JP cannot handle dates before 1868 properly
|
||||
if (eraBC && locale.equals(FastDateParser.JAPANESE_IMPERIAL)) {
|
||||
continue;
|
||||
|
@ -395,13 +395,13 @@ public class FastDateParserTest {
|
|||
|
||||
@Test
|
||||
public void testSpecialCharacters() throws Exception {
|
||||
testSdfAndFdp("q" ,"", true); // bad pattern character (at present)
|
||||
testSdfAndFdp("Q" ,"", true); // bad pattern character
|
||||
testSdfAndFdp("$" ,"$", false); // OK
|
||||
testSdfAndFdp("?.d" ,"?.12", false); // OK
|
||||
testSdfAndFdp("q" , "", true); // bad pattern character (at present)
|
||||
testSdfAndFdp("Q" , "", true); // bad pattern character
|
||||
testSdfAndFdp("$" , "$", false); // OK
|
||||
testSdfAndFdp("?.d" , "?.12", false); // OK
|
||||
testSdfAndFdp("''yyyyMMdd'A''B'HHmmssSSS''", "'20030210A'B153320989'", false); // OK
|
||||
testSdfAndFdp("''''yyyyMMdd'A''B'HHmmssSSS''", "''20030210A'B153320989'", false); // OK
|
||||
testSdfAndFdp("'$\\Ed'" ,"$\\Ed", false); // OK
|
||||
testSdfAndFdp("'$\\Ed'" , "$\\Ed", false); // OK
|
||||
|
||||
// quoted charaters are case sensitive
|
||||
testSdfAndFdp("'QED'", "QED", false);
|
||||
|
@ -413,13 +413,13 @@ public class FastDateParserTest {
|
|||
|
||||
@Test
|
||||
public void testLANG_832() throws Exception {
|
||||
testSdfAndFdp("'d'd" ,"d3", false); // OK
|
||||
testSdfAndFdp("'d'd'","d3", true); // should fail (unterminated quote)
|
||||
testSdfAndFdp("'d'd" , "d3", false); // OK
|
||||
testSdfAndFdp("'d'd'", "d3", true); // should fail (unterminated quote)
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLANG_831() throws Exception {
|
||||
testSdfAndFdp("M E","3 Tue", true);
|
||||
testSdfAndFdp("M E", "3 Tue", true);
|
||||
}
|
||||
|
||||
private void testSdfAndFdp(final String format, final String date, final boolean shouldFail)
|
||||
|
@ -433,7 +433,7 @@ public class FastDateParserTest {
|
|||
final SimpleDateFormat sdf = new SimpleDateFormat(format, Locale.US);
|
||||
sdf.setTimeZone(NEW_YORK);
|
||||
dsdf = sdf.parse(date);
|
||||
assertFalse(shouldFail, "Expected SDF failure, but got " + dsdf + " for ["+format+","+date+"]");
|
||||
assertFalse(shouldFail, "Expected SDF failure, but got " + dsdf + " for ["+format+", "+date+"]");
|
||||
} catch (final Exception e) {
|
||||
s = e;
|
||||
if (!shouldFail) {
|
||||
|
@ -444,7 +444,7 @@ public class FastDateParserTest {
|
|||
try {
|
||||
final DateParser fdp = getInstance(format, NEW_YORK, Locale.US);
|
||||
dfdp = fdp.parse(date);
|
||||
assertFalse(shouldFail, "Expected FDF failure, but got " + dfdp + " for ["+format+","+date+"]");
|
||||
assertFalse(shouldFail, "Expected FDF failure, but got " + dfdp + " for ["+format+", "+date+"]");
|
||||
} catch (final Exception e) {
|
||||
f = e;
|
||||
if (!shouldFail) {
|
||||
|
|
Loading…
Reference in New Issue