diff options
author | Benedikt Ritter <britter@apache.org> | 2017-06-06 15:12:06 +0200 |
---|---|---|
committer | Benedikt Ritter <britter@apache.org> | 2017-06-06 15:12:06 +0200 |
commit | 1da8ccdbfe2faa3e6801fe44eaf3c336aab48bec (patch) | |
tree | 04fad3070f3da1b65720dfb558d826e2c39d4d99 /src | |
parent | fa91c1b28647bd4217b0c325249aff9638fbeb6a (diff) | |
download | apache-commons-lang-1da8ccdbfe2faa3e6801fe44eaf3c336aab48bec.tar.gz |
Make sure lines in files don't have trailing white spaces and remove all trailing white spaces
Diffstat (limited to 'src')
216 files changed, 4106 insertions, 4106 deletions
diff --git a/src/main/java/org/apache/commons/lang3/ArrayUtils.java b/src/main/java/org/apache/commons/lang3/ArrayUtils.java index f0e9f6b82..35172fcdb 100644 --- a/src/main/java/org/apache/commons/lang3/ArrayUtils.java +++ b/src/main/java/org/apache/commons/lang3/ArrayUtils.java @@ -480,9 +480,9 @@ public class ArrayUtils { return type.cast(Array.newInstance(type.getComponentType(), 0)); } return array; - } - - + } + + /** * <p>Defensive programming technique to change a {@code null} * reference to an empty one. @@ -1536,10 +1536,10 @@ public class ArrayUtils { /** * <p> * Reverses the order of the given array in the given range. - * + * * <p> * This method does nothing for a {@code null} input array. - * + * * @param array * the array to reverse, may be {@code null} * @param startIndexInclusive @@ -1569,10 +1569,10 @@ public class ArrayUtils { /** * <p> * Reverses the order of the given array in the given range. - * + * * <p> * This method does nothing for a {@code null} input array. - * + * * @param array * the array to reverse, may be {@code null} * @param startIndexInclusive @@ -1602,10 +1602,10 @@ public class ArrayUtils { /** * <p> * Reverses the order of the given array in the given range. - * + * * <p> * This method does nothing for a {@code null} input array. - * + * * @param array * the array to reverse, may be {@code null} * @param startIndexInclusive @@ -1635,10 +1635,10 @@ public class ArrayUtils { /** * <p> * Reverses the order of the given array in the given range. - * + * * <p> * This method does nothing for a {@code null} input array. - * + * * @param array * the array to reverse, may be {@code null} * @param startIndexInclusive @@ -1668,10 +1668,10 @@ public class ArrayUtils { /** * <p> * Reverses the order of the given array in the given range. - * + * * <p> * This method does nothing for a {@code null} input array. - * + * * @param array * the array to reverse, may be {@code null} * @param startIndexInclusive @@ -1701,10 +1701,10 @@ public class ArrayUtils { /** * <p> * Reverses the order of the given array in the given range. - * + * * <p> * This method does nothing for a {@code null} input array. - * + * * @param array * the array to reverse, may be {@code null} * @param startIndexInclusive @@ -1734,10 +1734,10 @@ public class ArrayUtils { /** * <p> * Reverses the order of the given array in the given range. - * + * * <p> * This method does nothing for a {@code null} input array. - * + * * @param array * the array to reverse, may be {@code null} * @param startIndexInclusive @@ -1767,10 +1767,10 @@ public class ArrayUtils { /** * <p> * Reverses the order of the given array in the given range. - * + * * <p> * This method does nothing for a {@code null} input array. - * + * * @param array * the array to reverse, may be {@code null} * @param startIndexInclusive @@ -1800,10 +1800,10 @@ public class ArrayUtils { /** * <p> * Reverses the order of the given array in the given range. - * + * * <p> * This method does nothing for a {@code null} input array. - * + * * @param array * the array to reverse, may be {@code null} * @param startIndexInclusive @@ -1838,7 +1838,7 @@ public class ArrayUtils { * <p>There is no special handling for multi-dimensional arrays. This method * does nothing for a {@code null} or empty input array or for overflow indices. * Negative indices are promoted to 0(zero).</p> - * + * * Examples: * <ul> * <li>ArrayUtils.swap(["1", "2", "3"], 0, 2) -> ["3", "2", "1"]</li> @@ -1951,7 +1951,7 @@ public class ArrayUtils { * <p>There is no special handling for multi-dimensional arrays. This method * does nothing for a {@code null} or empty input array or for overflow indices. * Negative indices are promoted to 0(zero).</p> - * + * * Examples: * <ul> * <li>ArrayUtils.swap([1, 2, 3], 0, 2) -> [3, 2, 1]</li> @@ -2093,7 +2093,7 @@ public class ArrayUtils { * of the sub-arrays to swap falls outside of the given array, then the * swap is stopped at the end of the array and as many as possible elements * are swapped.</p> - * + * * Examples: * <ul> * <li>ArrayUtils.swap([true, false, true, false], 0, 2, 1) -> [true, false, true, false]</li> @@ -2177,7 +2177,7 @@ public class ArrayUtils { * of the sub-arrays to swap falls outside of the given array, then the * swap is stopped at the end of the array and as many as possible elements * are swapped.</p> - * + * * Examples: * <ul> * <li>ArrayUtils.swap([1, 2, 3, 4], 0, 2, 1) -> [3, 2, 1, 4]</li> @@ -2645,7 +2645,7 @@ public class ArrayUtils { * * <p>There is no special handling for multi-dimensional arrays. This method * does nothing for {@code null} or empty input arrays.</p> - * + * * @param array * the array to shift, may be {@code null} * @param startIndexInclusive @@ -2668,10 +2668,10 @@ public class ArrayUtils { } if (startIndexInclusive < 0) { startIndexInclusive = 0; - } + } if (endIndexExclusive >= array.length) { endIndexExclusive = array.length; - } + } int n = endIndexExclusive - startIndexInclusive; if (n <= 1) { return; @@ -2684,7 +2684,7 @@ public class ArrayUtils { // see https://beradrian.wordpress.com/2015/04/07/shift-an-array-in-on-in-place/ while (n > 1 && offset > 0) { final int n_offset = n - offset; - + if (offset > n_offset) { swap(array, startIndexInclusive, startIndexInclusive + n - n_offset, n_offset); n = offset; @@ -2705,7 +2705,7 @@ public class ArrayUtils { * * <p>There is no special handling for multi-dimensional arrays. This method * does nothing for {@code null} or empty input arrays.</p> - * + * * @param array * the array to shift, may be {@code null} * @param startIndexInclusive @@ -2728,10 +2728,10 @@ public class ArrayUtils { } if (startIndexInclusive < 0) { startIndexInclusive = 0; - } + } if (endIndexExclusive >= array.length) { endIndexExclusive = array.length; - } + } int n = endIndexExclusive - startIndexInclusive; if (n <= 1) { return; @@ -2744,7 +2744,7 @@ public class ArrayUtils { // see https://beradrian.wordpress.com/2015/04/07/shift-an-array-in-on-in-place/ while (n > 1 && offset > 0) { final int n_offset = n - offset; - + if (offset > n_offset) { swap(array, startIndexInclusive, startIndexInclusive + n - n_offset, n_offset); n = offset; @@ -2788,10 +2788,10 @@ public class ArrayUtils { } if (startIndexInclusive < 0) { startIndexInclusive = 0; - } + } if (endIndexExclusive >= array.length) { endIndexExclusive = array.length; - } + } int n = endIndexExclusive - startIndexInclusive; if (n <= 1) { return; @@ -2804,7 +2804,7 @@ public class ArrayUtils { // see https://beradrian.wordpress.com/2015/04/07/shift-an-array-in-on-in-place/ while (n > 1 && offset > 0) { final int n_offset = n - offset; - + if (offset > n_offset) { swap(array, startIndexInclusive, startIndexInclusive + n - n_offset, n_offset); n = offset; @@ -2848,10 +2848,10 @@ public class ArrayUtils { } if (startIndexInclusive < 0) { startIndexInclusive = 0; - } + } if (endIndexExclusive >= array.length) { endIndexExclusive = array.length; - } + } int n = endIndexExclusive - startIndexInclusive; if (n <= 1) { return; @@ -2864,7 +2864,7 @@ public class ArrayUtils { // see https://beradrian.wordpress.com/2015/04/07/shift-an-array-in-on-in-place/ while (n > 1 && offset > 0) { final int n_offset = n - offset; - + if (offset > n_offset) { swap(array, startIndexInclusive, startIndexInclusive + n - n_offset, n_offset); n = offset; @@ -2908,10 +2908,10 @@ public class ArrayUtils { } if (startIndexInclusive < 0) { startIndexInclusive = 0; - } + } if (endIndexExclusive >= array.length) { endIndexExclusive = array.length; - } + } int n = endIndexExclusive - startIndexInclusive; if (n <= 1) { return; @@ -2924,7 +2924,7 @@ public class ArrayUtils { // see https://beradrian.wordpress.com/2015/04/07/shift-an-array-in-on-in-place/ while (n > 1 && offset > 0) { final int n_offset = n - offset; - + if (offset > n_offset) { swap(array, startIndexInclusive, startIndexInclusive + n - n_offset, n_offset); n = offset; @@ -2968,10 +2968,10 @@ public class ArrayUtils { } if (startIndexInclusive < 0) { startIndexInclusive = 0; - } + } if (endIndexExclusive >= array.length) { endIndexExclusive = array.length; - } + } int n = endIndexExclusive - startIndexInclusive; if (n <= 1) { return; @@ -2984,7 +2984,7 @@ public class ArrayUtils { // see https://beradrian.wordpress.com/2015/04/07/shift-an-array-in-on-in-place/ while (n > 1 && offset > 0) { final int n_offset = n - offset; - + if (offset > n_offset) { swap(array, startIndexInclusive, startIndexInclusive + n - n_offset, n_offset); n = offset; @@ -3028,10 +3028,10 @@ public class ArrayUtils { } if (startIndexInclusive < 0) { startIndexInclusive = 0; - } + } if (endIndexExclusive >= array.length) { endIndexExclusive = array.length; - } + } int n = endIndexExclusive - startIndexInclusive; if (n <= 1) { return; @@ -3044,7 +3044,7 @@ public class ArrayUtils { // see https://beradrian.wordpress.com/2015/04/07/shift-an-array-in-on-in-place/ while (n > 1 && offset > 0) { final int n_offset = n - offset; - + if (offset > n_offset) { swap(array, startIndexInclusive, startIndexInclusive + n - n_offset, n_offset); n = offset; @@ -3088,10 +3088,10 @@ public class ArrayUtils { } if (startIndexInclusive < 0) { startIndexInclusive = 0; - } + } if (endIndexExclusive >= array.length) { endIndexExclusive = array.length; - } + } int n = endIndexExclusive - startIndexInclusive; if (n <= 1) { return; @@ -3104,7 +3104,7 @@ public class ArrayUtils { // see https://beradrian.wordpress.com/2015/04/07/shift-an-array-in-on-in-place/ while (n > 1 && offset > 0) { final int n_offset = n - offset; - + if (offset > n_offset) { swap(array, startIndexInclusive, startIndexInclusive + n - n_offset, n_offset); n = offset; @@ -3148,10 +3148,10 @@ public class ArrayUtils { } if (startIndexInclusive < 0) { startIndexInclusive = 0; - } + } if (endIndexExclusive >= array.length) { endIndexExclusive = array.length; - } + } int n = endIndexExclusive - startIndexInclusive; if (n <= 1) { return; @@ -3164,7 +3164,7 @@ public class ArrayUtils { // see https://beradrian.wordpress.com/2015/04/07/shift-an-array-in-on-in-place/ while (n > 1 && offset > 0) { final int n_offset = n - offset; - + if (offset > n_offset) { swap(array, startIndexInclusive, startIndexInclusive + n - n_offset, n_offset); n = offset; @@ -7428,7 +7428,7 @@ public class ArrayUtils { /** * Removes multiple array elements specified by indices. - * + * * @param array source * @param indices to remove * @return new array of same type minus elements specified by the set bits in {@code indices} @@ -7440,7 +7440,7 @@ public class ArrayUtils { // No need to check maxIndex here, because method only currently called from removeElements() // which guarantee to generate on;y valid bit entries. // final int maxIndex = indices.length(); -// if (maxIndex > srcLength) { +// if (maxIndex > srcLength) { // throw new IndexOutOfBoundsException("Index: " + (maxIndex-1) + ", Length: " + srcLength); // } final int removals = indices.cardinality(); // true bits are items to remove @@ -7459,13 +7459,13 @@ public class ArrayUtils { } count = srcLength - srcIndex; if (count > 0) { - System.arraycopy(array, srcIndex, result, destIndex, count); + System.arraycopy(array, srcIndex, result, destIndex, count); } return result; } /** - * <p>This method checks whether the provided array is sorted according to the class's + * <p>This method checks whether the provided array is sorted according to the class's * {@code compareTo} method. * * @param array the array to check @@ -7481,7 +7481,7 @@ public class ArrayUtils { } }); } - + /** * <p>This method checks whether the provided array is sorted according to the provided {@code Comparator}. @@ -7496,7 +7496,7 @@ public class ArrayUtils { if (comparator == null) { throw new IllegalArgumentException("Comparator should not be null."); } - + if (array == null || array.length < 2) { return true; } @@ -8050,7 +8050,7 @@ public class ArrayUtils { final String[] result = new String[array.length]; for (int i = 0; i < array.length; i++) { - final Object object = array[i]; + final Object object = array[i]; result[i] = (object == null ? valueForNullElements : object.toString()); } @@ -8072,7 +8072,7 @@ public class ArrayUtils { * @param array the array to insert the values into, may be {@code null} * @param values the new values to insert, may be {@code null} * @return The new array. - * @throws IndexOutOfBoundsException if {@code array} is provided + * @throws IndexOutOfBoundsException if {@code array} is provided * and either {@code index < 0} or {@code index > array.length} * @since 3.6 */ @@ -8114,7 +8114,7 @@ public class ArrayUtils { * @param array the array to insert the values into, may be {@code null} * @param values the new values to insert, may be {@code null} * @return The new array. - * @throws IndexOutOfBoundsException if {@code array} is provided + * @throws IndexOutOfBoundsException if {@code array} is provided * and either {@code index < 0} or {@code index > array.length} * @since 3.6 */ @@ -8156,7 +8156,7 @@ public class ArrayUtils { * @param array the array to insert the values into, may be {@code null} * @param values the new values to insert, may be {@code null} * @return The new array. - * @throws IndexOutOfBoundsException if {@code array} is provided + * @throws IndexOutOfBoundsException if {@code array} is provided * and either {@code index < 0} or {@code index > array.length} * @since 3.6 */ @@ -8198,7 +8198,7 @@ public class ArrayUtils { * @param array the array to insert the values into, may be {@code null} * @param values the new values to insert, may be {@code null} * @return The new array. - * @throws IndexOutOfBoundsException if {@code array} is provided + * @throws IndexOutOfBoundsException if {@code array} is provided * and either {@code index < 0} or {@code index > array.length} * @since 3.6 */ @@ -8240,7 +8240,7 @@ public class ArrayUtils { * @param array the array to insert the values into, may be {@code null} * @param values the new values to insert, may be {@code null} * @return The new array. - * @throws IndexOutOfBoundsException if {@code array} is provided + * @throws IndexOutOfBoundsException if {@code array} is provided * and either {@code index < 0} or {@code index > array.length} * @since 3.6 */ @@ -8282,7 +8282,7 @@ public class ArrayUtils { * @param array the array to insert the values into, may be {@code null} * @param values the new values to insert, may be {@code null} * @return The new array. - * @throws IndexOutOfBoundsException if {@code array} is provided + * @throws IndexOutOfBoundsException if {@code array} is provided * and either {@code index < 0} or {@code index > array.length} * @since 3.6 */ @@ -8324,7 +8324,7 @@ public class ArrayUtils { * @param array the array to insert the values into, may be {@code null} * @param values the new values to insert, may be {@code null} * @return The new array. - * @throws IndexOutOfBoundsException if {@code array} is provided + * @throws IndexOutOfBoundsException if {@code array} is provided * and either {@code index < 0} or {@code index > array.length} * @since 3.6 */ @@ -8366,7 +8366,7 @@ public class ArrayUtils { * @param array the array to insert the values into, may be {@code null} * @param values the new values to insert, may be {@code null} * @return The new array. - * @throws IndexOutOfBoundsException if {@code array} is provided + * @throws IndexOutOfBoundsException if {@code array} is provided * and either {@code index < 0} or {@code index > array.length} * @since 3.6 */ @@ -8417,7 +8417,7 @@ public class ArrayUtils { public static <T> T[] insert(final int index, final T[] array, final T... values) { /* * Note on use of @SafeVarargs: - * + * * By returning null when 'array' is null, we avoid returning the vararg * array to the caller. We also avoid relying on the type of the vararg * array, by inspecting the component type of 'array'. diff --git a/src/main/java/org/apache/commons/lang3/BitField.java b/src/main/java/org/apache/commons/lang3/BitField.java index 65b465e91..bc2147e0b 100644 --- a/src/main/java/org/apache/commons/lang3/BitField.java +++ b/src/main/java/org/apache/commons/lang3/BitField.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -17,28 +17,28 @@ package org.apache.commons.lang3; /** - * <p>Supports operations on bit-mapped fields. Instances of this class can be - * used to store a flag or data within an {@code int}, {@code short} or + * <p>Supports operations on bit-mapped fields. Instances of this class can be + * used to store a flag or data within an {@code int}, {@code short} or * {@code byte}.</p> - * + * * <p>Each {@code BitField} is constructed with a mask value, which indicates - * the bits that will be used to store and retrieve the data for that field. - * For instance, the mask {@code 0xFF} indicates the least-significant byte + * the bits that will be used to store and retrieve the data for that field. + * For instance, the mask {@code 0xFF} indicates the least-significant byte * should be used to store the data.</p> - * + * * <p>As an example, consider a car painting machine that accepts * paint instructions as integers. Bit fields can be used to encode this:</p> * *<pre> - * // blue, green and red are 1 byte values (0-255) stored in the three least + * // blue, green and red are 1 byte values (0-255) stored in the three least * // significant bytes * BitField blue = new BitField(0xFF); * BitField green = new BitField(0xFF00); * BitField red = new BitField(0xFF0000); - * + * * // anyColor is a flag triggered if any color is used * BitField anyColor = new BitField(0xFFFFFF); - * + * * // isMetallic is a single bit flag * BitField isMetallic = new BitField(0x1000000); *</pre> @@ -54,24 +54,24 @@ package org.apache.commons.lang3; *</pre> * * <p>Flags and data can be retrieved from the integer:</p> - * + * *<pre> * // Prints true if red, green or blue is non-zero * System.out.println(anyColor.isSet(paintInstruction)); // prints true - * + * * // Prints value of red, green and blue * System.out.println(red.getValue(paintInstruction)); // prints 35 * System.out.println(green.getValue(paintInstruction)); // prints 100 * System.out.println(blue.getValue(paintInstruction)); // prints 255 - * - * // Prints true if isMetallic was set + * + * // Prints true if isMetallic was set * System.out.println(isMetallic.isSet(paintInstruction)); // prints false *</pre> * * @since 2.0 */ public class BitField { - + private final int _mask; private final int _shift_count; diff --git a/src/main/java/org/apache/commons/lang3/BooleanUtils.java b/src/main/java/org/apache/commons/lang3/BooleanUtils.java index 9a212896d..fdeff74a0 100644 --- a/src/main/java/org/apache/commons/lang3/BooleanUtils.java +++ b/src/main/java/org/apache/commons/lang3/BooleanUtils.java @@ -699,7 +699,7 @@ public class BooleanUtils { * BooleanUtils.toBooleanObject("y") = true * BooleanUtils.toBooleanObject("n") = false * BooleanUtils.toBooleanObject("t") = true - * BooleanUtils.toBooleanObject("f") = false + * BooleanUtils.toBooleanObject("f") = false * </pre> * * @param str the String to check diff --git a/src/main/java/org/apache/commons/lang3/CharRange.java b/src/main/java/org/apache/commons/lang3/CharRange.java index bf82805bc..b395306bd 100644 --- a/src/main/java/org/apache/commons/lang3/CharRange.java +++ b/src/main/java/org/apache/commons/lang3/CharRange.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,30 +22,30 @@ import java.util.NoSuchElementException; /** * <p>A contiguous range of characters, optionally negated.</p> - * + * * <p>Instances are immutable.</p> * * <p>#ThreadSafe#</p> * @since 1.0 */ -// TODO: This is no longer public and will be removed later as CharSet is moved +// TODO: This is no longer public and will be removed later as CharSet is moved // to depend on Range. final class CharRange implements Iterable<Character>, Serializable { /** - * Required for serialization support. Lang version 2.0. - * + * Required for serialization support. Lang version 2.0. + * * @see java.io.Serializable */ private static final long serialVersionUID = 8270183163158333422L; - + /** The first character, inclusive, in the range. */ private final char start; /** The last character, inclusive, in the range. */ private final char end; /** True if the range is everything except the characters specified. */ private final boolean negated; - + /** Cached toString. */ private transient String iToString; @@ -55,7 +55,7 @@ final class CharRange implements Iterable<Character>, Serializable { * * <p>A negated range includes everything except that defined by the * start and end characters.</p> - * + * * <p>If start and end are in the wrong order, they are reversed. * Thus {@code a-e} is the same as {@code e-a}.</p> * @@ -70,7 +70,7 @@ final class CharRange implements Iterable<Character>, Serializable { start = end; end = temp; } - + this.start = start; this.end = end; this.negated = negated; @@ -130,7 +130,7 @@ final class CharRange implements Iterable<Character>, Serializable { //----------------------------------------------------------------------- /** * <p>Gets the start character for this character range.</p> - * + * * @return the start char (inclusive) */ public char getStart() { @@ -139,7 +139,7 @@ final class CharRange implements Iterable<Character>, Serializable { /** * <p>Gets the end character for this character range.</p> - * + * * @return the end char (inclusive) */ public char getEnd() { @@ -148,7 +148,7 @@ final class CharRange implements Iterable<Character>, Serializable { /** * <p>Is this {@code CharRange} negated.</p> - * + * * <p>A negated range includes everything except that defined by the * start and end characters.</p> * @@ -197,7 +197,7 @@ final class CharRange implements Iterable<Character>, Serializable { /** * <p>Compares two CharRange objects, returning true if they represent * exactly the same range of characters defined in the same way.</p> - * + * * @param obj the object to compare to * @return true if equal */ @@ -215,17 +215,17 @@ final class CharRange implements Iterable<Character>, Serializable { /** * <p>Gets a hashCode compatible with the equals method.</p> - * + * * @return a suitable hashCode */ @Override public int hashCode() { return 83 + start + 7 * end + (negated ? 1 : 0); } - + /** * <p>Gets a string representation of the character range.</p> - * + * * @return string representation of this range */ @Override diff --git a/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java b/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java index e35f5aa88..9bac1c517 100644 --- a/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java +++ b/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java @@ -50,7 +50,7 @@ public class CharSequenceUtils { * @param cs the specified subsequence, null returns null * @param start the start index, inclusive, valid * @return a new subsequence, may be null - * @throws IndexOutOfBoundsException if {@code start} is negative or if + * @throws IndexOutOfBoundsException if {@code start} is negative or if * {@code start} is greater than {@code length()} */ public static CharSequence subSequence(final CharSequence cs, final int start) { diff --git a/src/main/java/org/apache/commons/lang3/CharSet.java b/src/main/java/org/apache/commons/lang3/CharSet.java index 150f85025..70f9509a2 100644 --- a/src/main/java/org/apache/commons/lang3/CharSet.java +++ b/src/main/java/org/apache/commons/lang3/CharSet.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,37 +34,37 @@ import java.util.Set; public class CharSet implements Serializable { /** - * Required for serialization support. Lang version 2.0. - * + * Required for serialization support. Lang version 2.0. + * * @see java.io.Serializable */ private static final long serialVersionUID = 5947847346149275958L; - /** - * A CharSet defining no characters. + /** + * A CharSet defining no characters. * @since 2.0 */ public static final CharSet EMPTY = new CharSet((String) null); - /** + /** * A CharSet defining ASCII alphabetic characters "a-zA-Z". * @since 2.0 */ public static final CharSet ASCII_ALPHA = new CharSet("a-zA-Z"); - /** + /** * A CharSet defining ASCII alphabetic characters "a-z". * @since 2.0 */ public static final CharSet ASCII_ALPHA_LOWER = new CharSet("a-z"); - /** + /** * A CharSet defining ASCII alphabetic characters "A-Z". * @since 2.0 */ public static final CharSet ASCII_ALPHA_UPPER = new CharSet("A-Z"); - /** + /** * A CharSet defining ASCII alphabetic characters "0-9". * @since 2.0 */ @@ -76,7 +76,7 @@ public class CharSet implements Serializable { * @since 2.0 */ protected static final Map<String, CharSet> COMMON = Collections.synchronizedMap(new HashMap<String, CharSet>()); - + static { COMMON.put(null, EMPTY); COMMON.put(StringUtils.EMPTY, EMPTY); @@ -114,7 +114,7 @@ public class CharSet implements Serializable { * <li>Negated single character, such as "^a" * <li>Ordinary single character, such as "a" * </ol> - * + * * <p>Matching works left to right. Once a match is found the * search starts again from the next character.</p> * @@ -128,7 +128,7 @@ public class CharSet implements Serializable { * as the "a-e" and "e-a" are the same.</p> * * <p>The set of characters represented is the union of the specified ranges.</p> - * + * * <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> @@ -141,11 +141,11 @@ public class CharSet implements Serializable { * CharSet.getInstance("^a-c").contains('d') = true * CharSet.getInstance("^^a-c").contains('a') = true // (only '^' is negated) * CharSet.getInstance("^^a-c").contains('^') = false - * CharSet.getInstance("^a-cd-f").contains('d') = true + * CharSet.getInstance("^a-cd-f").contains('d') = true * CharSet.getInstance("a-c^").contains('^') = true * CharSet.getInstance("^", "a-c").contains('^') = true * </pre> - * + * * <p>All CharSet objects returned by this method will be immutable.</p> * * @param setStrs Strings to merge into the set, may be null @@ -162,7 +162,7 @@ public class CharSet implements Serializable { return common; } } - return new CharSet(setStrs); + return new CharSet(setStrs); } //----------------------------------------------------------------------- @@ -222,7 +222,7 @@ public class CharSet implements Serializable { * @return an array of immutable CharRange objects * @since 2.0 */ -// NOTE: This is no longer public as CharRange is no longer a public class. +// NOTE: This is no longer public as CharRange is no longer a public class. // It may be replaced when CharSet moves to Range. /*public*/ CharRange[] getCharRanges() { return set.toArray(new CharRange[set.size()]); diff --git a/src/main/java/org/apache/commons/lang3/CharSetUtils.java b/src/main/java/org/apache/commons/lang3/CharSetUtils.java index 015eeb80f..4ad4e6779 100644 --- a/src/main/java/org/apache/commons/lang3/CharSetUtils.java +++ b/src/main/java/org/apache/commons/lang3/CharSetUtils.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,7 +22,7 @@ package org.apache.commons.lang3; * <p>This class handles {@code null} input gracefully. * An exception will not be thrown for a {@code null} input. * Each method documents its behaviour in more detail.</p> - * + * * <p>#ThreadSafe#</p> * @see CharSet * @since 1.0 @@ -240,8 +240,8 @@ public class CharSetUtils { return buffer.toString(); } - /** - * Determines whether or not all the Strings in an array are + /** + * Determines whether or not all the Strings in an array are * empty or not. * * @param strings String[] whose elements are being checked for emptiness diff --git a/src/main/java/org/apache/commons/lang3/CharUtils.java b/src/main/java/org/apache/commons/lang3/CharUtils.java index bb45e5f45..f697c086b 100644 --- a/src/main/java/org/apache/commons/lang3/CharUtils.java +++ b/src/main/java/org/apache/commons/lang3/CharUtils.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,19 +22,19 @@ package org.apache.commons.lang3; * <p>This class tries to handle {@code null} input gracefully. * An exception will not be thrown for a {@code null} input. * Each method documents its behaviour in more detail.</p> - * + * * <p>#ThreadSafe#</p> * @since 2.1 */ public class CharUtils { - + private static final String[] CHAR_STRING_ARRAY = new String[128]; - + private static final char[] HEX_DIGITS = new char[] {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; /** * {@code \u000a} linefeed LF ('\n'). - * + * * @see <a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.10.6">JLF: Escape Sequences * for Character and String Literals</a> * @since 2.2 @@ -43,13 +43,13 @@ public class CharUtils { /** * {@code \u000d} carriage return CR ('\r'). - * + * * @see <a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.10.6">JLF: Escape Sequences * for Character and String Literals</a> * @since 2.2 */ public static final char CR = '\r'; - + static { for (char c = 0; c < CHAR_STRING_ARRAY.length; c++) { @@ -71,7 +71,7 @@ public class CharUtils { //----------------------------------------------------------------------- /** * <p>Converts the character to a Character.</p> - * + * * <p>For ASCII 7 bit characters, this uses a cache that will return the * same Character object each time.</p> * @@ -88,14 +88,14 @@ public class CharUtils { public static Character toCharacterObject(final char ch) { return Character.valueOf(ch); } - + /** * <p>Converts the String to a Character using the first character, returning * null for empty Strings.</p> - * + * * <p>For ASCII 7 bit characters, this uses a cache that will return the * same Character object each time.</p> - * + * * <pre> * CharUtils.toCharacterObject(null) = null * CharUtils.toCharacterObject("") = null @@ -112,11 +112,11 @@ public class CharUtils { } return Character.valueOf(str.charAt(0)); } - + //----------------------------------------------------------------------- /** * <p>Converts the Character to a char throwing an exception for {@code null}.</p> - * + * * <pre> * CharUtils.toChar(' ') = ' ' * CharUtils.toChar('A') = 'A' @@ -131,10 +131,10 @@ public class CharUtils { Validate.isTrue(ch != null, "The Character must not be null"); return ch.charValue(); } - + /** * <p>Converts the Character to a char handling {@code null}.</p> - * + * * <pre> * CharUtils.toChar(null, 'X') = 'X' * CharUtils.toChar(' ', 'X') = ' ' @@ -151,12 +151,12 @@ public class CharUtils { } return ch.charValue(); } - + //----------------------------------------------------------------------- /** * <p>Converts the String to a char using the first character, throwing * an exception on empty Strings.</p> - * + * * <pre> * CharUtils.toChar("A") = 'A' * CharUtils.toChar("BA") = 'B' @@ -172,11 +172,11 @@ public class CharUtils { Validate.isTrue(StringUtils.isNotEmpty(str), "The String must not be empty"); return str.charAt(0); } - + /** * <p>Converts the String to a char using the first character, defaulting * the value on empty Strings.</p> - * + * * <pre> * CharUtils.toChar(null, 'X') = 'X' * CharUtils.toChar("", 'X') = 'X' @@ -194,12 +194,12 @@ public class CharUtils { } return str.charAt(0); } - + //----------------------------------------------------------------------- /** * <p>Converts the character to the Integer it represents, throwing an * exception if the character is not numeric.</p> - * + * * <p>This method coverts the char '1' to the int 1 and so on.</p> * * <pre> @@ -217,11 +217,11 @@ public class CharUtils { } return ch - 48; } - + /** * <p>Converts the character to the Integer it represents, throwing an * exception if the character is not numeric.</p> - * + * * <p>This method coverts the char '1' to the int 1 and so on.</p> * * <pre> @@ -239,11 +239,11 @@ public class CharUtils { } return ch - 48; } - + /** * <p>Converts the character to the Integer it represents, throwing an * exception if the character is not numeric.</p> - * + * * <p>This method coverts the char '1' to the int 1 and so on.</p> * * <pre> @@ -260,11 +260,11 @@ public class CharUtils { Validate.isTrue(ch != null, "The character must not be null"); return toIntValue(ch.charValue()); } - + /** * <p>Converts the character to the Integer it represents, throwing an * exception if the character is not numeric.</p> - * + * * <p>This method coverts the char '1' to the int 1 and so on.</p> * * <pre> @@ -283,11 +283,11 @@ public class CharUtils { } return toIntValue(ch.charValue(), defaultValue); } - + //----------------------------------------------------------------------- /** * <p>Converts the character to a String that contains the one character.</p> - * + * * <p>For ASCII 7 bit characters, this uses a cache that will return the * same String object each time.</p> * @@ -305,13 +305,13 @@ public class CharUtils { } return new String(new char[] {ch}); } - + /** * <p>Converts the character to a String that contains the one character.</p> - * + * * <p>For ASCII 7 bit characters, this uses a cache that will return the * same String object each time.</p> - * + * * <p>If {@code null} is passed in, {@code null} will be returned.</p> * * <pre> @@ -329,18 +329,18 @@ public class CharUtils { } return toString(ch.charValue()); } - + //-------------------------------------------------------------------------- /** * <p>Converts the string to the Unicode format '\u0020'.</p> - * + * * <p>This format is the Java source code format.</p> * * <pre> * CharUtils.unicodeEscaped(' ') = "\u0020" * CharUtils.unicodeEscaped('A') = "\u0041" * </pre> - * + * * @param ch the character to convert * @return the escaped Unicode string */ @@ -353,12 +353,12 @@ public class CharUtils { sb.append(HEX_DIGITS[(ch) & 15]); return sb.toString(); } - + /** * <p>Converts the string to the Unicode format '\u0020'.</p> - * + * * <p>This format is the Java source code format.</p> - * + * * <p>If {@code null} is passed in, {@code null} will be returned.</p> * * <pre> @@ -366,7 +366,7 @@ public class CharUtils { * CharUtils.unicodeEscaped(' ') = "\u0020" * CharUtils.unicodeEscaped('A') = "\u0041" * </pre> - * + * * @param ch the character to convert, may be null * @return the escaped Unicode string, null if null input */ @@ -376,7 +376,7 @@ public class CharUtils { } return unicodeEscaped(ch.charValue()); } - + //-------------------------------------------------------------------------- /** * <p>Checks whether the character is ASCII 7 bit.</p> @@ -389,14 +389,14 @@ public class CharUtils { * CharUtils.isAscii('\n') = true * CharUtils.isAscii('©') = false * </pre> - * + * * @param ch the character to check * @return true if less than 128 */ public static boolean isAscii(final char ch) { return ch < 128; } - + /** * <p>Checks whether the character is ASCII 7 bit printable.</p> * @@ -408,14 +408,14 @@ public class CharUtils { * CharUtils.isAsciiPrintable('\n') = false * CharUtils.isAsciiPrintable('©') = false * </pre> - * + * * @param ch the character to check * @return true if between 32 and 126 inclusive */ public static boolean isAsciiPrintable(final char ch) { return ch >= 32 && ch < 127; } - + /** * <p>Checks whether the character is ASCII 7 bit control.</p> * @@ -427,14 +427,14 @@ public class CharUtils { * CharUtils.isAsciiControl('\n') = true * CharUtils.isAsciiControl('©') = false * </pre> - * + * * @param ch the character to check * @return true if less than 32 or equals 127 */ public static boolean isAsciiControl(final char ch) { return ch < 32 || ch == 127; } - + /** * <p>Checks whether the character is ASCII 7 bit alphabetic.</p> * @@ -446,14 +446,14 @@ public class CharUtils { * CharUtils.isAsciiAlpha('\n') = false * CharUtils.isAsciiAlpha('©') = false * </pre> - * + * * @param ch the character to check * @return true if between 65 and 90 or 97 and 122 inclusive */ public static boolean isAsciiAlpha(final char ch) { return isAsciiAlphaUpper(ch) || isAsciiAlphaLower(ch); } - + /** * <p>Checks whether the character is ASCII 7 bit alphabetic upper case.</p> * @@ -465,14 +465,14 @@ public class CharUtils { * CharUtils.isAsciiAlphaUpper('\n') = false * CharUtils.isAsciiAlphaUpper('©') = false * </pre> - * + * * @param ch the character to check * @return true if between 65 and 90 inclusive */ public static boolean isAsciiAlphaUpper(final char ch) { return ch >= 'A' && ch <= 'Z'; } - + /** * <p>Checks whether the character is ASCII 7 bit alphabetic lower case.</p> * @@ -484,14 +484,14 @@ public class CharUtils { * CharUtils.isAsciiAlphaLower('\n') = false * CharUtils.isAsciiAlphaLower('©') = false * </pre> - * + * * @param ch the character to check * @return true if between 97 and 122 inclusive */ public static boolean isAsciiAlphaLower(final char ch) { return ch >= 'a' && ch <= 'z'; } - + /** * <p>Checks whether the character is ASCII 7 bit numeric.</p> * @@ -503,14 +503,14 @@ public class CharUtils { * CharUtils.isAsciiNumeric('\n') = false * CharUtils.isAsciiNumeric('©') = false * </pre> - * + * * @param ch the character to check * @return true if between 48 and 57 inclusive */ public static boolean isAsciiNumeric(final char ch) { return ch >= '0' && ch <= '9'; } - + /** * <p>Checks whether the character is ASCII 7 bit numeric.</p> * @@ -522,7 +522,7 @@ public class CharUtils { * CharUtils.isAsciiAlphanumeric('\n') = false * CharUtils.isAsciiAlphanumeric('©') = false * </pre> - * + * * @param ch the character to check * @return true if between 48 and 57 or 65 and 90 or 97 and 122 inclusive */ diff --git a/src/main/java/org/apache/commons/lang3/ClassUtils.java b/src/main/java/org/apache/commons/lang3/ClassUtils.java index 60395ef94..e0b4d7200 100644 --- a/src/main/java/org/apache/commons/lang3/ClassUtils.java +++ b/src/main/java/org/apache/commons/lang3/ClassUtils.java @@ -1252,51 +1252,51 @@ public class ClassUtils { */ public static Iterable<Class<?>> hierarchy(final Class<?> type, final Interfaces interfacesBehavior) { final Iterable<Class<?>> classes = new Iterable<Class<?>>() { - + @Override public Iterator<Class<?>> iterator() { final MutableObject<Class<?>> next = new MutableObject<Class<?>>(type); return new Iterator<Class<?>>() { - + @Override public boolean hasNext() { return next.getValue() != null; } - + @Override public Class<?> next() { final Class<?> result = next.getValue(); next.setValue(result.getSuperclass()); return result; } - + @Override public void remove() { throw new UnsupportedOperationException(); } - + }; } - + }; if (interfacesBehavior != Interfaces.INCLUDE) { return classes; } return new Iterable<Class<?>>() { - + @Override public Iterator<Class<?>> iterator() { final Set<Class<?>> seenInterfaces = new HashSet<>(); final Iterator<Class<?>> wrapped = classes.iterator(); - + return new Iterator<Class<?>>() { Iterator<Class<?>> interfaces = Collections.<Class<?>> emptySet().iterator(); - + @Override public boolean hasNext() { return interfaces.hasNext() || wrapped.hasNext(); } - + @Override public Class<?> next() { if (interfaces.hasNext()) { @@ -1310,7 +1310,7 @@ public class ClassUtils { interfaces = currentInterfaces.iterator(); return nextSuperclass; } - + private void walkInterfaces(final Set<Class<?>> addTo, final Class<?> c) { for (final Class<?> iface : c.getInterfaces()) { if (!seenInterfaces.contains(iface)) { @@ -1319,12 +1319,12 @@ public class ClassUtils { walkInterfaces(addTo, iface); } } - + @Override public void remove() { throw new UnsupportedOperationException(); } - + }; } }; diff --git a/src/main/java/org/apache/commons/lang3/Conversion.java b/src/main/java/org/apache/commons/lang3/Conversion.java index 6d381c004..d177cc49c 100644 --- a/src/main/java/org/apache/commons/lang3/Conversion.java +++ b/src/main/java/org/apache/commons/lang3/Conversion.java @@ -59,12 +59,12 @@ import java.util.UUID; * Development status: work on going, only a part of the little endian, Lsb0 methods implemented * so far. * </p> - * + * * @since Lang 3.2 */ public class Conversion { - + private static final boolean[] TTTT = new boolean[] { true, true, true, true }; private static final boolean[] FTTT = new boolean[] { false, true, true, true }; private static final boolean[] TFTT = new boolean[] { true, false, true, true }; @@ -89,7 +89,7 @@ public class Conversion { * <p> * '1' is converted to 1 * </p> - * + * * @param hexDigit the hexadecimal digit to convert * @return an int equals to {@code hexDigit} * @throws IllegalArgumentException if {@code hexDigit} is not a hexadecimal digit @@ -109,7 +109,7 @@ public class Conversion { * <p> * '1' is converted to 8 * </p> - * + * * @param hexDigit the hexadecimal digit to convert * @return an int equals to {@code hexDigit} * @throws IllegalArgumentException if {@code hexDigit} is not a hexadecimal digit @@ -167,7 +167,7 @@ public class Conversion { * <p> * '1' is converted as follow: (1, 0, 0, 0) * </p> - * + * * @param hexDigit the hexadecimal digit to convert * @return a boolean array with the binary representation of {@code hexDigit} * @throws IllegalArgumentException if {@code hexDigit} is not a hexadecimal digit @@ -225,7 +225,7 @@ public class Conversion { * <p> * '1' is converted as follow: (0, 0, 0, 1) * </p> - * + * * @param hexDigit the hexadecimal digit to convert * @return a boolean array with the binary representation of {@code hexDigit} * @throws IllegalArgumentException if {@code hexDigit} is not a hexadecimal digit @@ -283,7 +283,7 @@ public class Conversion { * <p> * (1, 0, 0, 0) is converted as follow: '1' * </p> - * + * * @param src the binary to convert * @return a hexadecimal digit representing the selected bits * @throws IllegalArgumentException if {@code src} is empty @@ -301,7 +301,7 @@ public class Conversion { * <p> * (1, 0, 0, 0) is converted as follow: '1' * </p> - * + * * @param src the binary to convert * @param srcPos the position of the lsb to start the conversion * @return a hexadecimal digit representing the selected bits @@ -344,7 +344,7 @@ public class Conversion { * <p> * (1, 0, 0, 0) is converted as follow: '8' * </p> - * + * * @param src the binary to convert * @return a hexadecimal digit representing the selected bits * @throws IllegalArgumentException if {@code src} is empty, {@code src.length < 4} or @@ -364,7 +364,7 @@ public class Conversion { * (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> - * + * * @param src the binary to convert * @param srcPos the position of the lsb to start the conversion * @return a hexadecimal digit representing the selected bits @@ -412,7 +412,7 @@ public class Conversion { * (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> - * + * * @param src the binary to convert * @return a hexadecimal digit representing the selected bits * @throws IllegalArgumentException if {@code src} is empty @@ -431,7 +431,7 @@ public class Conversion { * (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 * @param srcPos the position of the lsb to start the conversion * @return a hexadecimal digit representing the selected bits @@ -485,7 +485,7 @@ public class Conversion { * <p> * 10 returns 'A' and so on... * </p> - * + * * @param nibble the 4 bits to convert * @return a hexadecimal digit representing the 4 lsb of {@code nibble} * @throws IllegalArgumentException if {@code nibble < 0} or {@code nibble > 15} @@ -511,7 +511,7 @@ public class Conversion { * <p> * 10 returns '5' and so on... * </p> - * + * * @param nibble the 4 bits to convert * @return a hexadecimal digit representing the 4 lsb of {@code nibble} * @throws IllegalArgumentException if {@code nibble < 0} or {@code nibble > 15} @@ -560,7 +560,7 @@ public class Conversion { * Converts an array of int into a long using the default (little endian, Lsb0) byte and bit * ordering. * </p> - * + * * @param src the int array to convert * @param srcPos the position in {@code src}, in int unit, from where to start the * conversion @@ -595,7 +595,7 @@ public class Conversion { * Converts an array of short into a long using the default (little endian, Lsb0) byte and * bit ordering. * </p> - * + * * @param src the short array to convert * @param srcPos the position in {@code src}, in short unit, from where to start the * conversion @@ -630,7 +630,7 @@ public class Conversion { * Converts an array of short into an int using the default (little endian, Lsb0) byte and * bit ordering. * </p> - * + * * @param src the short array to convert * @param srcPos the position in {@code src}, in short unit, from where to start the * conversion @@ -665,7 +665,7 @@ public class Conversion { * Converts an array of byte into a long using the default (little endian, Lsb0) byte and * bit ordering. * </p> - * + * * @param src the byte array to convert * @param srcPos the position in {@code src}, in byte unit, from where to start the * conversion @@ -700,7 +700,7 @@ public class Conversion { * Converts an array of byte into an int using the default (little endian, Lsb0) byte and bit * ordering. * </p> - * + * * @param src the byte array to convert * @param srcPos the position in {@code src}, in byte unit, from where to start the * conversion @@ -735,7 +735,7 @@ public class Conversion { * Converts an array of byte into a short using the default (little endian, Lsb0) byte and * bit ordering. * </p> - * + * * @param src the byte array to convert * @param srcPos the position in {@code src}, in byte unit, from where to start the * conversion @@ -770,7 +770,7 @@ public class Conversion { * Converts an array of Char into a long using the default (little endian, Lsb0) byte and * bit ordering. * </p> - * + * * @param src the hex string to convert * @param srcPos the position in {@code src}, in Char unit, from where to start the * conversion @@ -803,7 +803,7 @@ public class Conversion { * Converts an array of Char into an int using the default (little endian, Lsb0) byte and bit * ordering. * </p> - * + * * @param src the hex string to convert * @param srcPos the position in {@code src}, in Char unit, from where to start the * conversion @@ -835,7 +835,7 @@ public class Conversion { * Converts an array of Char into a short using the default (little endian, Lsb0) byte and * bit ordering. * </p> - * + * * @param src the hex string to convert * @param srcPos the position in {@code src}, in Char unit, from where to start the * conversion @@ -868,7 +868,7 @@ public class Conversion { * Converts an array of Char into a byte using the default (little endian, Lsb0) byte and * bit ordering. * </p> - * + * * @param src the hex string to convert * @param srcPos the position in {@code src}, in Char unit, from where to start the * conversion @@ -901,7 +901,7 @@ public class Conversion { * Converts binary (represented as boolean array) into a long using the default (little * endian, Lsb0) byte and bit ordering. * </p> - * + * * @param src the binary to convert * @param srcPos the position in {@code src}, in boolean unit, from where to start the * conversion @@ -936,7 +936,7 @@ public class Conversion { * Converts binary (represented as boolean array) into an int using the default (little * endian, Lsb0) byte and bit ordering. * </p> - * + * * @param src the binary to convert * @param srcPos the position in {@code src}, in boolean unit, from where to start the * conversion @@ -971,7 +971,7 @@ public class Conversion { * Converts binary (represented as boolean array) into a short using the default (little * endian, Lsb0) byte and bit ordering. * </p> - * + * * @param src the binary to convert * @param srcPos the position in {@code src}, in boolean unit, from where to start the * conversion @@ -1006,7 +1006,7 @@ public class Conversion { * Converts binary (represented as boolean array) into a byte using the default (little * endian, Lsb0) byte and bit ordering. * </p> - * + * * @param src the binary to convert * @param srcPos the position in {@code src}, in boolean unit, from where to start the * conversion @@ -1041,7 +1041,7 @@ public class Conversion { * Converts a long into an array of int using the default (little endian, Lsb0) byte and bit * ordering. * </p> - * + * * @param src the long to convert * @param srcPos the position in {@code src}, in bits, from where to start the conversion * @param dst the destination array @@ -1073,7 +1073,7 @@ public class Conversion { * Converts a long into an array of short using the default (little endian, Lsb0) byte and * bit ordering. * </p> - * + * * @param src the long to convert * @param srcPos the position in {@code src}, in bits, from where to start the conversion * @param dst the destination array @@ -1105,7 +1105,7 @@ public class Conversion { * Converts an int into an array of short using the default (little endian, Lsb0) byte and * bit ordering. * </p> - * + * * @param src the int to convert * @param srcPos the position in {@code src}, in bits, from where to start the conversion * @param dst the destination array @@ -1137,7 +1137,7 @@ public class Conversion { * Converts a long into an array of byte using the default (little endian, Lsb0) byte and * bit ordering. * </p> - * + * * @param src the long to convert * @param srcPos the position in {@code src}, in bits, from where to start the conversion * @param dst the destination array @@ -1169,7 +1169,7 @@ public class Conversion { * Converts an int into an array of byte using the default (little endian, Lsb0) byte and bit * ordering. * </p> - * + * * @param src the int to convert * @param srcPos the position in {@code src}, in bits, from where to start the conversion * @param dst the destination array @@ -1201,7 +1201,7 @@ public class Conversion { * Converts a short into an array of byte using the default (little endian, Lsb0) byte and * bit ordering. * </p> - * + * * @param src the short to convert * @param srcPos the position in {@code src}, in bits, from where to start the conversion * @param dst the destination array @@ -1233,7 +1233,7 @@ public class Conversion { * Converts a long into an array of Char using the default (little endian, Lsb0) byte and * bit ordering. * </p> - * + * * @param src the long to convert * @param srcPos the position in {@code src}, in bits, from where to start the conversion * @param dstInit the initial value for the result String @@ -1272,7 +1272,7 @@ public class Conversion { * Converts an int into an array of Char using the default (little endian, Lsb0) byte and bit * ordering. * </p> - * + * * @param src the int to convert * @param srcPos the position in {@code src}, in bits, from where to start the conversion * @param dstInit the initial value for the result String @@ -1311,7 +1311,7 @@ public class Conversion { * Converts a short into an array of Char using the default (little endian, Lsb0) byte and * bit ordering. * </p> - * + * * @param src the short to convert * @param srcPos the position in {@code src}, in bits, from where to start the conversion * @param dstInit the initial value for the result String @@ -1350,7 +1350,7 @@ public class Conversion { * Converts a byte into an array of Char using the default (little endian, Lsb0) byte and * bit ordering. * </p> - * + * * @param src the byte to convert * @param srcPos the position in {@code src}, in bits, from where to start the conversion * @param dstInit the initial value for the result String @@ -1389,7 +1389,7 @@ public class Conversion { * Converts a long into an array of boolean using the default (little endian, Lsb0) byte and * bit ordering. * </p> - * + * * @param src the long to convert * @param srcPos the position in {@code src}, in bits, from where to start the conversion * @param dst the destination array @@ -1421,7 +1421,7 @@ public class Conversion { * Converts an int into an array of boolean using the default (little endian, Lsb0) byte and * bit ordering. * </p> - * + * * @param src the int to convert * @param srcPos the position in {@code src}, in bits, from where to start the conversion * @param dst the destination array @@ -1453,7 +1453,7 @@ public class Conversion { * Converts a short into an array of boolean using the default (little endian, Lsb0) byte * and bit ordering. * </p> - * + * * @param src the short to convert * @param srcPos the position in {@code src}, in bits, from where to start the conversion * @param dst the destination array @@ -1486,7 +1486,7 @@ public class Conversion { * Converts a byte into an array of boolean using the default (little endian, Lsb0) byte and * bit ordering. * </p> - * + * * @param src the byte to convert * @param srcPos the position in {@code src}, in bits, from where to start the conversion * @param dst the destination array @@ -1518,7 +1518,7 @@ public class Conversion { * Converts UUID into an array of byte using the default (little endian, Lsb0) byte and bit * ordering. * </p> - * + * * @param src the UUID to convert * @param dst the destination array * @param dstPos the position in {@code dst} where to copy the result @@ -1548,7 +1548,7 @@ public class Conversion { * Converts bytes from an array into a UUID using the default (little endian, Lsb0) byte and * bit ordering. * </p> - * + * * @param src the byte array to convert * @param srcPos the position in {@code src} where to copy the result from * @return a UUID diff --git a/src/main/java/org/apache/commons/lang3/EnumUtils.java b/src/main/java/org/apache/commons/lang3/EnumUtils.java index d6bcdc0c3..84e93e221 100644 --- a/src/main/java/org/apache/commons/lang3/EnumUtils.java +++ b/src/main/java/org/apache/commons/lang3/EnumUtils.java @@ -289,7 +289,7 @@ public class EnumUtils { */ private static <E extends Enum<E>> Class<E> checkBitVectorable(final Class<E> enumClass) { final E[] constants = asEnum(enumClass).getEnumConstants(); - Validate.isTrue(constants.length <= Long.SIZE, CANNOT_STORE_S_S_VALUES_IN_S_BITS, + Validate.isTrue(constants.length <= Long.SIZE, CANNOT_STORE_S_S_VALUES_IN_S_BITS, Integer.valueOf(constants.length), enumClass.getSimpleName(), Integer.valueOf(Long.SIZE)); return enumClass; diff --git a/src/main/java/org/apache/commons/lang3/JavaVersion.java b/src/main/java/org/apache/commons/lang3/JavaVersion.java index 8c992f2ae..e464043e7 100644 --- a/src/main/java/org/apache/commons/lang3/JavaVersion.java +++ b/src/main/java/org/apache/commons/lang3/JavaVersion.java @@ -26,12 +26,12 @@ import org.apache.commons.lang3.math.NumberUtils; * @since 3.0 */ public enum JavaVersion { - + /** * The Java version reported by Android. This is not an official Java version number. */ JAVA_0_9(1.5f, "0.9"), - + /** * Java 1.1. */ @@ -74,7 +74,7 @@ public enum JavaVersion { /** * Java 1.9. - * + * * @deprecated As of release 3.5, replaced by {@link #JAVA_9} */ @Deprecated @@ -198,7 +198,7 @@ public enum JavaVersion { /** * Gets the Java Version from the system or 99.0 if the {@code java.specification.version} system property is not set. - * + * * @return the value of {@code java.specification.version} system property or 99.0 if it is not set. */ private static float maxVersion() { @@ -211,7 +211,7 @@ public enum JavaVersion { /** * Parses a float value from a String. - * + * * @param value the String to parse. * @return the float value represented by the string or -1 if the given String can not be parsed. */ diff --git a/src/main/java/org/apache/commons/lang3/LocaleUtils.java b/src/main/java/org/apache/commons/lang3/LocaleUtils.java index af0731fc9..51bbf5fcd 100644 --- a/src/main/java/org/apache/commons/lang3/LocaleUtils.java +++ b/src/main/java/org/apache/commons/lang3/LocaleUtils.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -38,11 +38,11 @@ import java.util.concurrent.ConcurrentMap; public class LocaleUtils { /** Concurrent map of language locales by country. */ - private static final ConcurrentMap<String, List<Locale>> cLanguagesByCountry = + private static final ConcurrentMap<String, List<Locale>> cLanguagesByCountry = new ConcurrentHashMap<>(); /** Concurrent map of country locales by language. */ - private static final ConcurrentMap<String, List<Locale>> cCountriesByLanguage = + private static final ConcurrentMap<String, List<Locale>> cCountriesByLanguage = new ConcurrentHashMap<>(); /** @@ -243,7 +243,7 @@ public class LocaleUtils { //----------------------------------------------------------------------- /** * <p>Obtains an unmodifiable list of installed locales.</p> - * + * * <p>This method is a wrapper around {@link Locale#getAvailableLocales()}. * It is more efficient, as the JDK method must create a new array each * time it is called.</p> @@ -257,7 +257,7 @@ public class LocaleUtils { //----------------------------------------------------------------------- /** * <p>Obtains an unmodifiable set of installed locales.</p> - * + * * <p>This method is a wrapper around {@link Locale#getAvailableLocales()}. * It is more efficient, as the JDK method must create a new array each * time it is called.</p> @@ -314,7 +314,7 @@ public class LocaleUtils { //----------------------------------------------------------------------- /** * <p>Obtains the list of countries supported for a given language.</p> - * + * * <p>This method takes a language code and searches to find the * countries available for that language. Variant locales are removed.</p> * @@ -351,7 +351,7 @@ public class LocaleUtils { private static final List<Locale> AVAILABLE_LOCALE_LIST; /** Unmodifiable set of available locales. */ private static final Set<Locale> AVAILABLE_LOCALE_SET; - + static { final List<Locale> list = new ArrayList<>(Arrays.asList(Locale.getAvailableLocales())); // extra safe AVAILABLE_LOCALE_LIST = Collections.unmodifiableList(list); diff --git a/src/main/java/org/apache/commons/lang3/NotImplementedException.java b/src/main/java/org/apache/commons/lang3/NotImplementedException.java index 82e3784e8..d7e2e7565 100644 --- a/src/main/java/org/apache/commons/lang3/NotImplementedException.java +++ b/src/main/java/org/apache/commons/lang3/NotImplementedException.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,11 +20,11 @@ package org.apache.commons.lang3; * <p>Thrown to indicate that a block of code has not been implemented. * This exception supplements <code>UnsupportedOperationException</code> * by providing a more semantically rich description of the problem.</p> - * + * * <p><code>NotImplementedException</code> represents the case where the * author has yet to implement the logic at this point in the program. * This can act as an exception based TODO tag. </p> - * + * * <pre> * public void foo() { * try { @@ -38,7 +38,7 @@ package org.apache.commons.lang3; * * This class was originally added in Lang 2.0, but removed in 3.0. * - * @since 3.2 + * @since 3.2 */ public class NotImplementedException extends UnsupportedOperationException { @@ -48,7 +48,7 @@ public class NotImplementedException extends UnsupportedOperationException { /** * Constructs a NotImplementedException. - * + * * @param message description of the exception * @since 3.2 */ @@ -58,7 +58,7 @@ public class NotImplementedException extends UnsupportedOperationException { /** * Constructs a NotImplementedException. - * + * * @param cause cause of the exception * @since 3.2 */ @@ -68,7 +68,7 @@ public class NotImplementedException extends UnsupportedOperationException { /** * Constructs a NotImplementedException. - * + * * @param message description of the exception * @param cause cause of the exception * @since 3.2 @@ -79,7 +79,7 @@ public class NotImplementedException extends UnsupportedOperationException { /** * Constructs a NotImplementedException. - * + * * @param message description of the exception * @param code code indicating a resource for more information regarding the lack of implementation * @since 3.2 @@ -91,7 +91,7 @@ public class NotImplementedException extends UnsupportedOperationException { /** * Constructs a NotImplementedException. - * + * * @param cause cause of the exception * @param code code indicating a resource for more information regarding the lack of implementation * @since 3.2 @@ -103,7 +103,7 @@ public class NotImplementedException extends UnsupportedOperationException { /** * Constructs a NotImplementedException. - * + * * @param message description of the exception * @param cause cause of the exception * @param code code indicating a resource for more information regarding the lack of implementation @@ -115,8 +115,8 @@ public class NotImplementedException extends UnsupportedOperationException { } /** - * Obtain the not implemented code. This is an unformatted piece of text intended to point to - * further information regarding the lack of implementation. It might, for example, be an issue + * Obtain the not implemented code. This is an unformatted piece of text intended to point to + * further information regarding the lack of implementation. It might, for example, be an issue * tracker ID or a URL. * * @return a code indicating a resource for more information regarding the lack of implementation diff --git a/src/main/java/org/apache/commons/lang3/ObjectUtils.java b/src/main/java/org/apache/commons/lang3/ObjectUtils.java index b5a00dbc4..146556b08 100644 --- a/src/main/java/org/apache/commons/lang3/ObjectUtils.java +++ b/src/main/java/org/apache/commons/lang3/ObjectUtils.java @@ -147,7 +147,7 @@ public class ObjectUtils { * ObjectUtils.anyNotNull(null) = false * ObjectUtils.anyNotNull(null, null) = false * </pre> - * + * * @param values the values to test, may be {@code null} or empty * @return {@code true} if there is at least one non-null value in the array, * {@code false} if all values in the array are {@code null}s. @@ -167,7 +167,7 @@ public class ObjectUtils { * {@code null} or the array is empty (contains no elements) {@code true} * is returned. * </p> - * + * * <pre> * ObjectUtils.allNotNull(*) = true * ObjectUtils.allNotNull(*, *) = true @@ -277,7 +277,7 @@ public class ObjectUtils { /** * <p>Gets the hash code for multiple objects.</p> - * + * * <p>This allows a hash code to be rapidly calculated for a number of objects. * The hash code for a single object is the <em>not</em> same as {@link #hashCode(Object)}. * The hash code for multiple objects is the same as that calculated by an @@ -622,7 +622,7 @@ public class ObjectUtils { //----------------------------------------------------------------------- /** * Find the most frequently occurring item. - * + * * @param <T> type of values processed by this method * @param items to check * @return most populous T, {@code null} if non-unique or no items supplied @@ -1008,7 +1008,7 @@ public class ObjectUtils { * have to recompile themselves if the field's value * changes at some future date. * - * @param <T> the Object type + * @param <T> the Object type * @param v the genericized Object value to return (typically a String). * @return the genericized Object v, unchanged (typically a String). * @since 3.2 diff --git a/src/main/java/org/apache/commons/lang3/RandomStringUtils.java b/src/main/java/org/apache/commons/lang3/RandomStringUtils.java index c5e256b16..25bfe31ad 100644 --- a/src/main/java/org/apache/commons/lang3/RandomStringUtils.java +++ b/src/main/java/org/apache/commons/lang3/RandomStringUtils.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,13 +20,13 @@ import java.util.Random; /** * <p>Operations for random {@code String}s.</p> - * <p>Currently <em>private high surrogate</em> characters are ignored. + * <p>Currently <em>private high surrogate</em> characters are ignored. * These are Unicode characters that fall between the values 56192 (db80) - * and 56319 (dbff) as we don't know how to handle them. - * High and low surrogates are correctly dealt with - that is if a - * high surrogate is randomly chosen, 55296 (d800) to 56191 (db7f) - * then it is followed by a low surrogate. If a low surrogate is chosen, - * 56320 (dc00) to 57343 (dfff) then it is placed after a randomly + * and 56319 (dbff) as we don't know how to handle them. + * High and low surrogates are correctly dealt with - that is if a + * high surrogate is randomly chosen, 55296 (d800) to 56191 (db7f) + * then it is followed by a low surrogate. If a low surrogate is chosen, + * 56320 (dc00) to 57343 (dfff) then it is placed after a randomly * chosen high surrogate. </p> * * <p>#ThreadSafe#</p> @@ -40,7 +40,7 @@ public class RandomStringUtils { /** * <p>Random object used by random method. This has to be not local - * to the random method so as to not return the same value in the + * to the random method so as to not return the same value in the * same millisecond.</p> */ private static final Random RANDOM = new Random(); @@ -165,7 +165,7 @@ public class RandomStringUtils { * <p>Creates a random string whose length is the number of characters specified.</p> * * <p>Characters will be chosen from the set of characters which match the POSIX [:graph:] - * regular expression character class. This class contains all visible ASCII characters + * regular expression character class. This class contains all visible ASCII characters * (i.e. anything except spaces and control characters).</p> * * @param count the length of random string to create @@ -267,7 +267,7 @@ public class RandomStringUtils { public static String random(final int count, final boolean letters, final boolean numbers) { return random(count, 0, 0, letters, numbers); } - + /** * <p>Creates a random string whose length is the number of characters * specified.</p> @@ -326,7 +326,7 @@ public class RandomStringUtils { * end are chosen.</p> * * <p>This method accepts a user-supplied {@link Random} - * instance to use as a source of randomness. By seeding a single + * instance to use as a source of randomness. By seeding a single * {@link Random} instance with a fixed seed and using it for each call, * the same random sequence of strings can be generated repeatedly * and predictably.</p> @@ -364,7 +364,7 @@ public class RandomStringUtils { end = Character.MAX_CODE_POINT; } else { end = 'z' + 1; - start = ' '; + start = ' '; } } } else { @@ -389,7 +389,7 @@ public class RandomStringUtils { int codePoint; if (chars == null) { codePoint = random.nextInt(gap) + start; - + switch (Character.getType(codePoint)) { case Character.UNASSIGNED: case Character.PRIVATE_USE: @@ -397,26 +397,26 @@ public class RandomStringUtils { count++; continue; } - + } else { codePoint = chars[random.nextInt(gap) + start]; } - + final int numberOfChars = Character.charCount(codePoint); if (count == 0 && numberOfChars > 1) { count++; continue; } - + if (letters && Character.isLetter(codePoint) || numbers && Character.isDigit(codePoint) - || !letters && !numbers) { + || !letters && !numbers) { builder.appendCodePoint(codePoint); - + if (numberOfChars == 2) { count--; } - + } else { count++; } @@ -430,7 +430,7 @@ public class RandomStringUtils { * specified.</p> * * <p>Characters will be chosen from the set of characters - * specified by the string, must not be empty. + * specified by the string, must not be empty. * If null, the set of all characters is used.</p> * * @param count the length of random string to create @@ -464,5 +464,5 @@ public class RandomStringUtils { } return random(count, 0, chars.length, false, false, chars, RANDOM); } - + } diff --git a/src/main/java/org/apache/commons/lang3/RandomUtils.java b/src/main/java/org/apache/commons/lang3/RandomUtils.java index 3ea44938a..e9992930e 100644 --- a/src/main/java/org/apache/commons/lang3/RandomUtils.java +++ b/src/main/java/org/apache/commons/lang3/RandomUtils.java @@ -20,7 +20,7 @@ import java.util.Random; /** * <p>Utility library that supplements the standard {@link Random} class.</p> - * + * * @since 3.3 */ public class RandomUtils { @@ -37,7 +37,7 @@ public class RandomUtils { * programming. Instead, the class should be used as * {@code RandomUtils.nextBytes(5);}. * </p> - * + * * <p> * This constructor is public to permit tools that require a JavaBean * instance to operate. @@ -58,12 +58,12 @@ public class RandomUtils { public static boolean nextBoolean() { return RANDOM.nextBoolean(); } - + /** * <p> * Creates an array of random bytes. * </p> - * + * * @param count * the size of the returned array * @return the random byte array @@ -81,7 +81,7 @@ public class RandomUtils { * <p> * Returns a random integer within the specified range. * </p> - * + * * @param startInclusive * the smallest value that can be returned, must be non-negative * @param endExclusive @@ -99,7 +99,7 @@ public class RandomUtils { if (startInclusive == endExclusive) { return startInclusive; } - + return startInclusive + RANDOM.nextInt(endExclusive - startInclusive); } @@ -113,12 +113,12 @@ public class RandomUtils { public static int nextInt() { return nextInt(0, Integer.MAX_VALUE); } - + /** * <p> * Returns a random long within the specified range. * </p> - * + * * @param startInclusive * the smallest value that can be returned, must be non-negative * @param endExclusive @@ -150,12 +150,12 @@ public class RandomUtils { public static long nextLong() { return nextLong(0, Long.MAX_VALUE); } - + /** - * <p> + * <p> * Returns a random double within the specified range. * </p> - * + * * @param startInclusive * the smallest value that can be returned, must be non-negative * @param endInclusive @@ -173,7 +173,7 @@ public class RandomUtils { if (startInclusive == endInclusive) { return startInclusive; } - + return startInclusive + ((endInclusive - startInclusive) * RANDOM.nextDouble()); } @@ -192,7 +192,7 @@ public class RandomUtils { * <p> * Returns a random float within the specified range. * </p> - * + * * @param startInclusive * the smallest value that can be returned, must be non-negative * @param endInclusive @@ -206,11 +206,11 @@ public class RandomUtils { Validate.isTrue(endInclusive >= startInclusive, "Start value must be smaller or equal to end value."); Validate.isTrue(startInclusive >= 0, "Both range values must be non-negative."); - + if (startInclusive == endInclusive) { return startInclusive; } - + return startInclusive + ((endInclusive - startInclusive) * RANDOM.nextFloat()); } diff --git a/src/main/java/org/apache/commons/lang3/Range.java b/src/main/java/org/apache/commons/lang3/Range.java index 29ad7a331..5962f80e1 100644 --- a/src/main/java/org/apache/commons/lang3/Range.java +++ b/src/main/java/org/apache/commons/lang3/Range.java @@ -21,12 +21,12 @@ import java.util.Comparator; /** * <p>An immutable range of objects from a minimum to maximum point inclusive.</p> - * + * * <p>The objects need to either be implementations of {@code Comparable} * or you need to supply a {@code Comparator}. </p> * * <p>#ThreadSafe# if the objects and comparator are thread-safe</p> - * + * * @since 3.0 */ public final class Range<T> implements Serializable { @@ -61,7 +61,7 @@ public final class Range<T> implements Serializable { /** * <p>Obtains a range using the specified element as both the minimum * and maximum in this range.</p> - * + * * <p>The range uses the natural ordering of the elements to determine where * values lie in the range.</p> * @@ -78,7 +78,7 @@ public final class Range<T> implements Serializable { /** * <p>Obtains a range using the specified element as both the minimum * and maximum in this range.</p> - * + * * <p>The range uses the specified {@code Comparator} to determine where * values lie in the range.</p> * @@ -95,7 +95,7 @@ public final class Range<T> implements Serializable { /** * <p>Obtains a range with the specified minimum and maximum values (both inclusive).</p> - * + * * <p>The range uses the natural ordering of the elements to determine where * values lie in the range.</p> * @@ -115,7 +115,7 @@ public final class Range<T> implements Serializable { /** * <p>Obtains a range with the specified minimum and maximum values (both inclusive).</p> - * + * * <p>The range uses the specified {@code Comparator} to determine where * values lie in the range.</p> * @@ -150,7 +150,7 @@ public final class Range<T> implements Serializable { if (comp == null) { this.comparator = ComparableComparator.INSTANCE; } else { - this.comparator = comp; + this.comparator = comp; } if (this.comparator.compare(element1, element2) < 1) { this.minimum = element1; @@ -184,7 +184,7 @@ public final class Range<T> implements Serializable { /** * <p>Gets the comparator being used to determine if objects are within the range.</p> - * + * * <p>Natural ordering uses an internal comparator implementation, thus this * method never returns null. See {@link #isNaturalOrdering()}.</p> * @@ -196,7 +196,7 @@ public final class Range<T> implements Serializable { /** * <p>Whether or not the Range is using the natural ordering of the elements.</p> - * + * * <p>Natural ordering uses an internal comparator implementation, thus this * method is the only way to check if a null comparator was specified.</p> * @@ -276,7 +276,7 @@ public final class Range<T> implements Serializable { /** * <p>Checks where the specified element occurs relative to this range.</p> - * + * * <p>The API is reminiscent of the Comparable interface returning {@code -1} if * the element is before the range, {@code 0} if contained within the range and * {@code 1} if the element is after the range. </p> @@ -334,7 +334,7 @@ public final class Range<T> implements Serializable { /** * <p>Checks whether this range is overlapped by the specified range.</p> - * + * * <p>Two ranges overlap if there is at least one element in common.</p> * * <p>This method may fail if the ranges have two different comparators or element types.</p> @@ -451,13 +451,13 @@ public final class Range<T> implements Serializable { /** * <p>Formats the receiver using the given format.</p> - * + * * <p>This uses {@link java.util.Formattable} to perform the formatting. Three variables may * be used to embed the minimum, maximum and comparator. * Use {@code %1$s} for the minimum element, {@code %2$s} for the maximum element * and {@code %3$s} for the comparator. * The default format used by {@code toString()} is {@code [%1$s..%2$s]}.</p> - * + * * @param format the format string, optionally containing {@code %1$s}, {@code %2$s} and {@code %3$s}, not null * @return the formatted string, not null */ @@ -470,7 +470,7 @@ public final class Range<T> implements Serializable { private enum ComparableComparator implements Comparator { INSTANCE; /** - * Comparable based compare implementation. + * Comparable based compare implementation. * * @param obj1 left hand side of comparison * @param obj2 right hand side of comparison diff --git a/src/main/java/org/apache/commons/lang3/SerializationException.java b/src/main/java/org/apache/commons/lang3/SerializationException.java index 588eff05a..1d1d16ad8 100644 --- a/src/main/java/org/apache/commons/lang3/SerializationException.java +++ b/src/main/java/org/apache/commons/lang3/SerializationException.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,7 +28,7 @@ public class SerializationException extends RuntimeException { /** * Required for serialization support. - * + * * @see java.io.Serializable */ private static final long serialVersionUID = 4029025366392702726L; diff --git a/src/main/java/org/apache/commons/lang3/SerializationUtils.java b/src/main/java/org/apache/commons/lang3/SerializationUtils.java index 670ef1838..5fca908a4 100644 --- a/src/main/java/org/apache/commons/lang3/SerializationUtils.java +++ b/src/main/java/org/apache/commons/lang3/SerializationUtils.java @@ -161,17 +161,17 @@ public class SerializationUtils { * <p> * Deserializes an {@code Object} from the specified stream. * </p> - * + * * <p> * The stream will be closed once the object is written. This avoids the need for a finally clause, and maybe also * exception handling, in the application code. * </p> - * + * * <p> * The stream passed in is not buffered internally within this method. This is the responsibility of your * application if desired. * </p> - * + * * <p> * If the call site incorrectly types the return value, a {@link ClassCastException} is thrown from the call site. * Without Generics in this declaration, the call site must type cast and can cause the same ClassCastException. @@ -202,13 +202,13 @@ public class SerializationUtils { * <p> * Deserializes a single {@code Object} from an array of bytes. * </p> - * + * * <p> * If the call site incorrectly types the return value, a {@link ClassCastException} is thrown from the call site. * Without Generics in this declaration, the call site must type cast and can cause the same ClassCastException. * Note that in both cases, the ClassCastException is in the call site, not in this method. * </p> - * + * * @param <T> the object type to be deserialized * @param objectData * the serialized object, must not be null @@ -232,12 +232,12 @@ public class SerializationUtils { * containers and application servers, no matter in which of the * <code>ClassLoader</code> the particular class that encapsulates * serialization/deserialization lives. </p> - * + * * <p>For more in-depth information about the problem for which this * class here is a workaround, see the JIRA issue LANG-626. </p> */ static class ClassLoaderAwareObjectInputStream extends ObjectInputStream { - private static final Map<String, Class<?>> primitiveTypes = + private static final Map<String, Class<?>> primitiveTypes = new HashMap<>(); static { @@ -253,7 +253,7 @@ public class SerializationUtils { } private final ClassLoader classLoader; - + /** * Constructor. * @param in The <code>InputStream</code>. diff --git a/src/main/java/org/apache/commons/lang3/StringEscapeUtils.java b/src/main/java/org/apache/commons/lang3/StringEscapeUtils.java index df2a8358e..2d0a5db78 100644 --- a/src/main/java/org/apache/commons/lang3/StringEscapeUtils.java +++ b/src/main/java/org/apache/commons/lang3/StringEscapeUtils.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -46,45 +46,45 @@ public class StringEscapeUtils { /* ESCAPE TRANSLATORS */ /** - * Translator object for escaping Java. - * - * While {@link #escapeJava(String)} is the expected method of use, this - * object allows the Java escaping functionality to be used - * as the foundation for a custom translator. + * Translator object for escaping Java. + * + * While {@link #escapeJava(String)} is the expected method of use, this + * object allows the Java escaping functionality to be used + * as the foundation for a custom translator. * * @since 3.0 */ - public static final CharSequenceTranslator ESCAPE_JAVA = + public static final CharSequenceTranslator ESCAPE_JAVA = new LookupTranslator( - new String[][] { + new String[][] { {"\"", "\\\""}, {"\\", "\\\\"}, }).with( new LookupTranslator(EntityArrays.JAVA_CTRL_CHARS_ESCAPE()) ).with( - JavaUnicodeEscaper.outsideOf(32, 0x7f) + JavaUnicodeEscaper.outsideOf(32, 0x7f) ); /** - * Translator object for escaping EcmaScript/JavaScript. - * - * While {@link #escapeEcmaScript(String)} is the expected method of use, this - * object allows the EcmaScript escaping functionality to be used - * as the foundation for a custom translator. + * Translator object for escaping EcmaScript/JavaScript. + * + * While {@link #escapeEcmaScript(String)} is the expected method of use, this + * object allows the EcmaScript escaping functionality to be used + * as the foundation for a custom translator. * * @since 3.0 */ - public static final CharSequenceTranslator ESCAPE_ECMASCRIPT = + public static final CharSequenceTranslator ESCAPE_ECMASCRIPT = new AggregateTranslator( new LookupTranslator( - new String[][] { + new String[][] { {"'", "\\'"}, {"\"", "\\\""}, {"\\", "\\\\"}, {"/", "\\/"} }), new LookupTranslator(EntityArrays.JAVA_CTRL_CHARS_ESCAPE()), - JavaUnicodeEscaper.outsideOf(32, 0x7f) + JavaUnicodeEscaper.outsideOf(32, 0x7f) ); /** @@ -110,24 +110,24 @@ public class StringEscapeUtils { /** * Translator object for escaping XML. - * - * While {@link #escapeXml(String)} is the expected method of use, this - * object allows the XML escaping functionality to be used - * as the foundation for a custom translator. + * + * While {@link #escapeXml(String)} is the expected method of use, this + * object allows the XML escaping functionality to be used + * as the foundation for a custom translator. * * @since 3.0 * @deprecated use {@link #ESCAPE_XML10} or {@link #ESCAPE_XML11} instead. */ @Deprecated - public static final CharSequenceTranslator ESCAPE_XML = + public static final CharSequenceTranslator ESCAPE_XML = new AggregateTranslator( new LookupTranslator(EntityArrays.BASIC_ESCAPE()), new LookupTranslator(EntityArrays.APOS_ESCAPE()) ); - + /** * Translator object for escaping XML 1.0. - * + * * While {@link #escapeXml10(String)} is the expected method of use, this * object allows the XML escaping functionality to be used * as the foundation for a custom translator. @@ -176,10 +176,10 @@ public class StringEscapeUtils { NumericEntityEscaper.between(0x86, 0x9f), new UnicodeUnpairedSurrogateRemover() ); - + /** * Translator object for escaping XML 1.1. - * + * * While {@link #escapeXml11(String)} is the expected method of use, this * object allows the XML escaping functionality to be used * as the foundation for a custom translator. @@ -207,14 +207,14 @@ public class StringEscapeUtils { /** * Translator object for escaping HTML version 3.0. - * - * While {@link #escapeHtml3(String)} is the expected method of use, this - * object allows the HTML escaping functionality to be used - * as the foundation for a custom translator. + * + * While {@link #escapeHtml3(String)} is the expected method of use, this + * object allows the HTML escaping functionality to be used + * as the foundation for a custom translator. * * @since 3.0 */ - public static final CharSequenceTranslator ESCAPE_HTML3 = + public static final CharSequenceTranslator ESCAPE_HTML3 = new AggregateTranslator( new LookupTranslator(EntityArrays.BASIC_ESCAPE()), new LookupTranslator(EntityArrays.ISO8859_1_ESCAPE()) @@ -222,14 +222,14 @@ public class StringEscapeUtils { /** * Translator object for escaping HTML version 4.0. - * - * While {@link #escapeHtml4(String)} is the expected method of use, this - * object allows the HTML escaping functionality to be used - * as the foundation for a custom translator. + * + * While {@link #escapeHtml4(String)} is the expected method of use, this + * object allows the HTML escaping functionality to be used + * as the foundation for a custom translator. * * @since 3.0 */ - public static final CharSequenceTranslator ESCAPE_HTML4 = + public static final CharSequenceTranslator ESCAPE_HTML4 = new AggregateTranslator( new LookupTranslator(EntityArrays.BASIC_ESCAPE()), new LookupTranslator(EntityArrays.ISO8859_1_ESCAPE()), @@ -237,25 +237,25 @@ public class StringEscapeUtils { ); /** - * Translator object for escaping individual Comma Separated Values. - * - * While {@link #escapeCsv(String)} is the expected method of use, this - * object allows the CSV escaping functionality to be used - * as the foundation for a custom translator. + * Translator object for escaping individual Comma Separated Values. + * + * While {@link #escapeCsv(String)} is the expected method of use, this + * object allows the CSV escaping functionality to be used + * as the foundation for a custom translator. * * @since 3.0 */ public static final CharSequenceTranslator ESCAPE_CSV = new CsvEscaper(); // TODO: Create a parent class - 'SinglePassTranslator' ? - // It would handle the index checking + length returning, + // It would handle the index checking + length returning, // and could also have an optimization check method. static class CsvEscaper extends CharSequenceTranslator { private static final char CSV_DELIMITER = ','; private static final char CSV_QUOTE = '"'; private static final String CSV_QUOTE_STR = String.valueOf(CSV_QUOTE); - private static final char[] CSV_SEARCH_CHARS = + private static final char[] CSV_SEARCH_CHARS = new char[] {CSV_DELIMITER, CSV_QUOTE, CharUtils.CR, CharUtils.LF}; @Override @@ -279,22 +279,22 @@ public class StringEscapeUtils { /* UNESCAPE TRANSLATORS */ /** - * Translator object for unescaping escaped Java. - * - * While {@link #unescapeJava(String)} is the expected method of use, this - * object allows the Java unescaping functionality to be used - * as the foundation for a custom translator. + * Translator object for unescaping escaped Java. + * + * While {@link #unescapeJava(String)} is the expected method of use, this + * object allows the Java unescaping functionality to be used + * as the foundation for a custom translator. * * @since 3.0 */ // TODO: throw "illegal character: \92" as an Exception if a \ on the end of the Java (as per the compiler)? - public static final CharSequenceTranslator UNESCAPE_JAVA = + public static final CharSequenceTranslator UNESCAPE_JAVA = new AggregateTranslator( new OctalUnescaper(), // .between('\1', '\377'), new UnicodeUnescaper(), new LookupTranslator(EntityArrays.JAVA_CTRL_CHARS_UNESCAPE()), new LookupTranslator( - new String[][] { + new String[][] { {"\\\\", "\\"}, {"\\\"", "\""}, {"\\'", "'"}, @@ -303,11 +303,11 @@ public class StringEscapeUtils { ); /** - * Translator object for unescaping escaped EcmaScript. - * - * While {@link #unescapeEcmaScript(String)} is the expected method of use, this - * object allows the EcmaScript unescaping functionality to be used - * as the foundation for a custom translator. + * Translator object for unescaping escaped EcmaScript. + * + * While {@link #unescapeEcmaScript(String)} is the expected method of use, this + * object allows the EcmaScript unescaping functionality to be used + * as the foundation for a custom translator. * * @since 3.0 */ @@ -325,15 +325,15 @@ public class StringEscapeUtils { public static final CharSequenceTranslator UNESCAPE_JSON = UNESCAPE_JAVA; /** - * Translator object for unescaping escaped HTML 3.0. - * - * While {@link #unescapeHtml3(String)} is the expected method of use, this - * object allows the HTML unescaping functionality to be used - * as the foundation for a custom translator. + * Translator object for unescaping escaped HTML 3.0. + * + * While {@link #unescapeHtml3(String)} is the expected method of use, this + * object allows the HTML unescaping functionality to be used + * as the foundation for a custom translator. * * @since 3.0 */ - public static final CharSequenceTranslator UNESCAPE_HTML3 = + public static final CharSequenceTranslator UNESCAPE_HTML3 = new AggregateTranslator( new LookupTranslator(EntityArrays.BASIC_UNESCAPE()), new LookupTranslator(EntityArrays.ISO8859_1_UNESCAPE()), @@ -341,15 +341,15 @@ public class StringEscapeUtils { ); /** - * Translator object for unescaping escaped HTML 4.0. - * - * While {@link #unescapeHtml4(String)} is the expected method of use, this - * object allows the HTML unescaping functionality to be used - * as the foundation for a custom translator. + * Translator object for unescaping escaped HTML 4.0. + * + * While {@link #unescapeHtml4(String)} is the expected method of use, this + * object allows the HTML unescaping functionality to be used + * as the foundation for a custom translator. * * @since 3.0 */ - public static final CharSequenceTranslator UNESCAPE_HTML4 = + public static final CharSequenceTranslator UNESCAPE_HTML4 = new AggregateTranslator( new LookupTranslator(EntityArrays.BASIC_UNESCAPE()), new LookupTranslator(EntityArrays.ISO8859_1_UNESCAPE()), @@ -359,14 +359,14 @@ public class StringEscapeUtils { /** * Translator object for unescaping escaped XML. - * - * While {@link #unescapeXml(String)} is the expected method of use, this - * object allows the XML unescaping functionality to be used - * as the foundation for a custom translator. + * + * While {@link #unescapeXml(String)} is the expected method of use, this + * object allows the XML unescaping functionality to be used + * as the foundation for a custom translator. * * @since 3.0 */ - public static final CharSequenceTranslator UNESCAPE_XML = + public static final CharSequenceTranslator UNESCAPE_XML = new AggregateTranslator( new LookupTranslator(EntityArrays.BASIC_UNESCAPE()), new LookupTranslator(EntityArrays.APOS_UNESCAPE()), @@ -375,10 +375,10 @@ public class StringEscapeUtils { /** * Translator object for unescaping escaped Comma Separated Value entries. - * - * While {@link #unescapeCsv(String)} is the expected method of use, this - * object allows the CSV unescaping functionality to be used - * as the foundation for a custom translator. + * + * While {@link #unescapeCsv(String)} is the expected method of use, this + * object allows the CSV unescaping functionality to be used + * as the foundation for a custom translator. * * @since 3.0 */ @@ -389,7 +389,7 @@ public class StringEscapeUtils { private static final char CSV_DELIMITER = ','; private static final char CSV_QUOTE = '"'; private static final String CSV_QUOTE_STR = String.valueOf(CSV_QUOTE); - private static final char[] CSV_SEARCH_CHARS = + private static final char[] CSV_SEARCH_CHARS = new char[] {CSV_DELIMITER, CSV_QUOTE, CharUtils.CR, CharUtils.LF}; @Override @@ -520,7 +520,7 @@ public class StringEscapeUtils { * For example, it will turn a sequence of {@code '\'} and * {@code 'n'} into a newline character, unless the {@code '\'} * is preceded by another {@code '\'}.</p> - * + * * @param input the {@code String} to unescape, may be null * @return a new unescaped {@code String}, {@code null} if null string input */ @@ -569,7 +569,7 @@ public class StringEscapeUtils { * * <p> * For example: - * </p> + * </p> * <p><code>"bread" & "butter"</code></p> * becomes: * <p> @@ -582,13 +582,13 @@ public class StringEscapeUtils { * * @param input the {@code String} to escape, may be null * @return a new escaped {@code String}, {@code null} if null string input - * + * * @see <a href="http://hotwired.lycos.com/webmonkey/reference/special_characters/">ISO Entities</a> * @see <a href="http://www.w3.org/TR/REC-html32#latin1">HTML 3.2 Character Entities for ISO Latin-1</a> * @see <a href="http://www.w3.org/TR/REC-html40/sgml/entities.html">HTML 4.0 Character entity references</a> * @see <a href="http://www.w3.org/TR/html401/charset.html#h-5.3">HTML 4.01 Character References</a> * @see <a href="http://www.w3.org/TR/html401/charset.html#code-position">HTML 4.01 Code positions</a> - * + * * @since 3.0 */ public static final String escapeHtml4(final String input) { @@ -601,7 +601,7 @@ public class StringEscapeUtils { * * @param input the {@code String} to escape, may be null * @return a new escaped {@code String}, {@code null} if null string input - * + * * @since 3.0 */ public static final String escapeHtml3(final String input) { @@ -623,7 +623,7 @@ public class StringEscapeUtils { * * @param input the {@code String} to unescape, may be null * @return a new unescaped {@code String}, {@code null} if null string input - * + * * @since 3.0 */ public static final String unescapeHtml4(final String input) { @@ -637,7 +637,7 @@ public class StringEscapeUtils { * * @param input the {@code String} to unescape, may be null * @return a new unescaped {@code String}, {@code null} if null string input - * + * * @since 3.0 */ public static final String unescapeHtml3(final String input) { @@ -655,9 +655,9 @@ public class StringEscapeUtils { * <p>Supports only the five basic XML entities (gt, lt, quot, amp, apos). * Does not support DTDs or external entities.</p> * - * <p>Note that Unicode characters greater than 0x7f are as of 3.0, no longer - * escaped. If you still wish this functionality, you can achieve it - * via the following: + * <p>Note that Unicode characters greater than 0x7f are as of 3.0, no longer + * escaped. If you still wish this functionality, you can achieve it + * via the following: * {@code StringEscapeUtils.ESCAPE_XML.with( NumericEntityEscaper.between(0x7f, Integer.MAX_VALUE) );}</p> * * @param input the {@code String} to escape, may be null @@ -681,14 +681,14 @@ public class StringEscapeUtils { * characters or unpaired Unicode surrogate codepoints, even after escaping. * {@code escapeXml10} will remove characters that do not fit in the * following ranges:</p> - * + * * <p>{@code #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]}</p> - * + * * <p>Though not strictly necessary, {@code escapeXml10} will escape * characters in the following ranges:</p> - * + * * <p>{@code [#x7F-#x84] | [#x86-#x9F]}</p> - * + * * <p>The returned string can be inserted into a valid XML 1.0 or XML 1.1 * document. If you want to allow more non-text characters in an XML 1.1 * document, use {@link #escapeXml11(String)}.</p> @@ -701,7 +701,7 @@ public class StringEscapeUtils { public static String escapeXml10(final String input) { return ESCAPE_XML10.translate(input); } - + /** * <p>Escapes the characters in a {@code String} using XML entities.</p> * @@ -713,13 +713,13 @@ public class StringEscapeUtils { * the null byte or unpaired Unicode surrogate codepoints, even after escaping. * {@code escapeXml11} will remove characters that do not fit in the following * ranges:</p> - * + * * <p>{@code [#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]}</p> - * + * * <p>{@code escapeXml11} will escape characters in the following ranges:</p> - * + * * <p>{@code [#x1-#x8] | [#xB-#xC] | [#xE-#x1F] | [#x7F-#x84] | [#x86-#x9F]}</p> - * + * * <p>The returned string can be inserted into a valid XML 1.1 document. Do not * use it for XML 1.0 documents.</p> * @@ -741,7 +741,7 @@ public class StringEscapeUtils { * <p>Supports only the five basic XML entities (gt, lt, quot, amp, apos). * Does not support DTDs or external entities.</p> * - * <p>Note that numerical \\u Unicode codes are unescaped to their respective + * <p>Note that numerical \\u Unicode codes are unescaped to their respective * Unicode characters. This may change in future releases. </p> * * @param input the {@code String} to unescape, may be null @@ -783,21 +783,21 @@ public class StringEscapeUtils { /** * <p>Returns a {@code String} value for an unescaped CSV column. </p> * - * <p>If the value is enclosed in double quotes, and contains a comma, newline - * or double quote, then quotes are removed. + * <p>If the value is enclosed in double quotes, and contains a comma, newline + * or double quote, then quotes are removed. * </p> * - * <p>Any double quote escaped characters (a pair of double quotes) are unescaped + * <p>Any double quote escaped characters (a pair of double quotes) are unescaped * to just one double quote. </p> * - * <p>If the value is not enclosed in double quotes, or is and does not contain a + * <p>If the value is not enclosed in double quotes, or is and does not contain a * comma, newline or double quote, then the String value is returned unchanged.</p> * * see <a href="http://en.wikipedia.org/wiki/Comma-separated_values">Wikipedia</a> and * <a href="http://tools.ietf.org/html/rfc4180">RFC 4180</a>. * * @param input the input CSV column String, may be null - * @return the input String, with enclosing double quotes removed and embedded double + * @return the input String, with enclosing double quotes removed and embedded double * quotes unescaped, {@code null} if null string input * @since 2.4 */ diff --git a/src/main/java/org/apache/commons/lang3/StringUtils.java b/src/main/java/org/apache/commons/lang3/StringUtils.java index 7f6432235..442e285b4 100644 --- a/src/main/java/org/apache/commons/lang3/StringUtils.java +++ b/src/main/java/org/apache/commons/lang3/StringUtils.java @@ -228,7 +228,7 @@ public class StringUtils { public static boolean isNotEmpty(final CharSequence cs) { return !isEmpty(cs); } - + /** * <p>Checks if any of the CharSequences are empty ("") or null.</p> * @@ -316,7 +316,7 @@ public class StringUtils { /** * <p>Checks if a CharSequence is empty (""), null or whitespace only.</p> - * + * * <p>Whitespace is defined by {@link Character#isWhitespace(char)}.</p> * * <pre> @@ -347,7 +347,7 @@ public class StringUtils { /** * <p>Checks if a CharSequence is not empty (""), not null and not whitespace only.</p> - * + * * <p>Whitespace is defined by {@link Character#isWhitespace(char)}.</p> * * <pre> @@ -370,7 +370,7 @@ public class StringUtils { /** * <p>Checks if any of the CharSequences are empty ("") or null or whitespace only.</p> - * + * * <p>Whitespace is defined by {@link Character#isWhitespace(char)}.</p> * * <pre> @@ -404,7 +404,7 @@ public class StringUtils { /** * <p>Checks if none of the CharSequences are empty (""), null or whitespace only.</p> - * + * * <p>Whitespace is defined by {@link Character#isWhitespace(char)}.</p> * * <pre> @@ -450,7 +450,7 @@ public class StringUtils { * @since 3.6 */ public static boolean isAllBlank(final CharSequence... css) { - if (ArrayUtils.isEmpty(css)) { + if (ArrayUtils.isEmpty(css)) { return true; } for (final CharSequence cs : css) { @@ -774,7 +774,7 @@ public class StringUtils { str = stripStart(str, stripChars); return stripEnd(str, stripChars); } - + /** * <p>Strips any of a set of characters from the start of a String.</p> * @@ -2019,9 +2019,9 @@ public class StringUtils { /** * <p>Check whether the given CharSequence contains any whitespace characters.</p> - * + * * <p>Whitespace is defined by {@link Character#isWhitespace(char)}.</p> - * + * * @param seq the CharSequence to check (may be {@code null}) * @return {@code true} if the CharSequence is not empty and * contains at least 1 (breaking) whitespace character @@ -2235,7 +2235,7 @@ public class StringUtils { * StringUtils.containsAny("abc", "d", "abc") = true * </pre> * - * + * * @param cs The CharSequence to check, may be null * @param searchCharSequences The array of CharSequences to search for, may be null. * Individual CharSequences may be null as well. @@ -5468,7 +5468,7 @@ public class StringUtils { /** * <p>Replaces a String with another String inside a larger String, - * for the first {@code max} values of the search String, + * for the first {@code max} values of the search String, * case sensitively/insensisitively based on {@code ignoreCase} value.</p> * * <p>A {@code null} reference passed to this method is a no-op.</p> @@ -7200,7 +7200,7 @@ public class StringUtils { /** * <p>Checks if the CharSequence contains only whitespace.</p> - * + * * <p>Whitespace is defined by {@link Character#isWhitespace(char)}.</p> * * <p>{@code null} will return {@code false}. @@ -7390,7 +7390,7 @@ public class StringUtils { /** * <p>Returns either the passed in CharSequence, or if the CharSequence is * whitespace, empty ("") or {@code null}, the value of {@code defaultStr}.</p> - * + * * <p>Whitespace is defined by {@link Character#isWhitespace(char)}.</p> * * <pre> @@ -7539,7 +7539,7 @@ public class StringUtils { * * <p>Specifically:</p> * <ul> - * <li>If the number of characters in {@code str} is less than or equal to + * <li>If the number of characters in {@code str} is less than or equal to * {@code maxWidth}, return {@code str}.</li> * <li>Else abbreviate it to {@code (substring(str, 0, max-3) + "...")}.</li> * <li>If {@code maxWidth} is less than {@code 4}, throw an @@ -7616,7 +7616,7 @@ public class StringUtils { * * <p>Specifically:</p> * <ul> - * <li>If the number of characters in {@code str} is less than or equal to + * <li>If the number of characters in {@code str} is less than or equal to * {@code maxWidth}, return {@code str}.</li> * <li>Else abbreviate it to {@code (substring(str, 0, max-abbrevMarker.length) + abbrevMarker)}.</li> * <li>If {@code maxWidth} is less than {@code abbrevMarker.length + 1}, throw an @@ -8009,7 +8009,7 @@ public class StringUtils { * another, where each change is a single character modification (deletion, * insertion or substitution).</p> * - * <p>The implementation uses a single-dimensional array of length s.length() + 1. See + * <p>The implementation uses a single-dimensional array of length s.length() + 1. See * <a href="http://blog.softwx.net/2014/12/optimizing-levenshtein-algorithm-in-c.html"> * http://blog.softwx.net/2014/12/optimizing-levenshtein-algorithm-in-c.html</a> for details.</p> * @@ -8260,16 +8260,16 @@ public class StringUtils { } return -1; } - + /** * <p>Find the Jaro Winkler Distance which indicates the similarity score between two Strings.</p> * - * <p>The Jaro measure is the weighted sum of percentage of matched characters from each file and transposed characters. + * <p>The Jaro measure is the weighted sum of percentage of matched characters from each file and transposed characters. * Winkler increased this measure for matching initial characters.</p> * * <p>This implementation is based on the Jaro Winkler similarity algorithm * from <a href="http://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance">http://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance</a>.</p> - * + * * <pre> * StringUtils.getJaroWinklerDistance(null, null) = IllegalArgumentException * StringUtils.getJaroWinklerDistance("","") = 0.0 @@ -8972,7 +8972,7 @@ public class StringUtils { /** * Converts a <code>byte[]</code> to a String using the specified character encoding. - * + * * @param bytes * the byte array to read from * @param charset @@ -8991,7 +8991,7 @@ public class StringUtils { * <p> * Wraps a string with a char. * </p> - * + * * <pre> * StringUtils.wrap(null, *) = null * StringUtils.wrap("", *) = "" @@ -9000,7 +9000,7 @@ public class StringUtils { * StringUtils.wrap("ab", '\'') = "'ab'" * StringUtils.wrap("\"ab\"", '\"') = "\"\"ab\"\"" * </pre> - * + * * @param str * the string to be wrapped, may be {@code null} * @param wrapWith @@ -9021,11 +9021,11 @@ public class StringUtils { * <p> * Wraps a String with another String. * </p> - * + * * <p> * A {@code null} input String returns {@code null}. * </p> - * + * * <pre> * StringUtils.wrap(null, *) = null * StringUtils.wrap("", *) = "" @@ -9038,7 +9038,7 @@ public class StringUtils { * StringUtils.wrap("\"abcd\"", "'") = "'\"abcd\"'" * StringUtils.wrap("'abcd'", "\"") = "\"'abcd'\"" * </pre> - * + * * @param str * the String to be wrapper, may be null * @param wrapWith @@ -9059,7 +9059,7 @@ public class StringUtils { * <p> * Wraps a string with a char if that char is missing from the start or end of the given string. * </p> - * + * * <pre> * StringUtils.wrap(null, *) = null * StringUtils.wrap("", *) = "" @@ -9072,7 +9072,7 @@ public class StringUtils { * StringUtils.wrap("/a/b/c", '/') = "/a/b/c/" * StringUtils.wrap("a/b/c/", '/') = "/a/b/c/" * </pre> - * + * * @param str * the string to be wrapped, may be {@code null} * @param wrapWith @@ -9099,7 +9099,7 @@ public class StringUtils { * <p> * Wraps a string with a string if that string is missing from the start or end of the given string. * </p> - * + * * <pre> * StringUtils.wrap(null, *) = null * StringUtils.wrap("", *) = "" @@ -9116,7 +9116,7 @@ public class StringUtils { * StringUtils.wrap("/a/b/c", "/") = "/a/b/c/" * StringUtils.wrap("a/b/c/", "/") = "/a/b/c/" * </pre> - * + * * @param str * the string to be wrapped, may be {@code null} * @param wrapWith @@ -9160,7 +9160,7 @@ public class StringUtils { * the String to be unwrapped, can be null * @param wrapToken * the String used to unwrap - * @return unwrapped String or the original string + * @return unwrapped String or the original string * if it is not quoted properly with the wrapToken * @since 3.6 */ @@ -9185,7 +9185,7 @@ public class StringUtils { * <p> * Unwraps a given string from a character. * </p> - * + * * <pre> * StringUtils.unwrap(null, null) = null * StringUtils.unwrap(null, '\0') = null @@ -9201,7 +9201,7 @@ public class StringUtils { * the String to be unwrapped, can be null * @param wrapChar * the character used to unwrap - * @return unwrapped String or the original string + * @return unwrapped String or the original string * if it is not quoted properly with the wrapChar * @since 3.6 */ @@ -9223,16 +9223,16 @@ public class StringUtils { /** * <p>Converts a {@code CharSequence} into an array of code points.</p> - * + * * <p>Valid pairs of surrogate code units will be converted into a single supplementary * code point. Isolated surrogate code units (i.e. a high surrogate not followed by a low surrogate or * a low surrogate not preceeded by a high surrogate) will be returned as-is.</p> - * + * * <pre> * StringUtils.toCodePoints(null) = null * StringUtils.toCodePoints("") = [] // empty array * </pre> - * + * * @param str the character sequence to convert * @return an array of code points * @since 3.6 diff --git a/src/main/java/org/apache/commons/lang3/SystemUtils.java b/src/main/java/org/apache/commons/lang3/SystemUtils.java index f55361830..50d260ba0 100644 --- a/src/main/java/org/apache/commons/lang3/SystemUtils.java +++ b/src/main/java/org/apache/commons/lang3/SystemUtils.java @@ -955,7 +955,7 @@ public class SystemUtils { * </p> * * @since 3.4 - * + * * @deprecated As of release 3.5, replaced by {@link #IS_JAVA_9} */ @Deprecated @@ -1497,11 +1497,11 @@ public class SystemUtils { /** * Gets the host name from an environment variable. - * + * * <p> * If you want to know what the network stack says is the host name, you should use {@code InetAddress.getLocalHost().getHostName()}. * </p> - * + * * @return the host name. * @since 3.6 */ diff --git a/src/main/java/org/apache/commons/lang3/arch/Processor.java b/src/main/java/org/apache/commons/lang3/arch/Processor.java index 9f6b3db17..cca224d47 100644 --- a/src/main/java/org/apache/commons/lang3/arch/Processor.java +++ b/src/main/java/org/apache/commons/lang3/arch/Processor.java @@ -35,17 +35,17 @@ public class Processor { * </ul> */ public enum Arch { - + /** * A 32-bit processor architecture. */ - BIT_32, - + BIT_32, + /** * A 64-bit processor architecture. */ - BIT_64, - + BIT_64, + /** * An unknown-bit processor architecture. */ @@ -63,22 +63,22 @@ public class Processor { * </ul> */ public enum Type { - + /** * Intel x86 series of instruction set architectures. */ - X86, - + X86, + /** * Intel Itanium 64-bit architecture. */ - IA_64, - + IA_64, + /** * Apple–IBM–Motorola PowerPC architecture. */ - PPC, - + PPC, + /** * Unknown architecture. */ diff --git a/src/main/java/org/apache/commons/lang3/builder/Builder.java b/src/main/java/org/apache/commons/lang3/builder/Builder.java index 496d2248e..3e69afbba 100644 --- a/src/main/java/org/apache/commons/lang3/builder/Builder.java +++ b/src/main/java/org/apache/commons/lang3/builder/Builder.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,52 +18,52 @@ package org.apache.commons.lang3.builder; /** * <p> - * The Builder interface is designed to designate a class as a <em>builder</em> - * object in the Builder design pattern. Builders are capable of creating and - * configuring objects or results that normally take multiple steps to construct - * or are very complex to derive. + * The Builder interface is designed to designate a class as a <em>builder</em> + * object in the Builder design pattern. Builders are capable of creating and + * configuring objects or results that normally take multiple steps to construct + * or are very complex to derive. * </p> - * + * * <p> - * The builder interface defines a single method, {@link #build()}, that - * classes must implement. The result of this method should be the final + * The builder interface defines a single method, {@link #build()}, that + * classes must implement. The result of this method should be the final * configured object or result after all building operations are performed. * </p> - * + * * <p> - * It is a recommended practice that the methods supplied to configure the + * It is a recommended practice that the methods supplied to configure the * object or result being built return a reference to {@code this} so that * method calls can be chained together. * </p> - * + * * <p> * Example Builder: * <pre><code> * class FontBuilder implements Builder<Font> { * private Font font; - * + * * public FontBuilder(String fontName) { * this.font = new Font(fontName, Font.PLAIN, 12); * } - * + * * public FontBuilder bold() { * this.font = this.font.deriveFont(Font.BOLD); * return this; // Reference returned so calls can be chained * } - * + * * public FontBuilder size(float pointSize) { * this.font = this.font.deriveFont(pointSize); * return this; // Reference returned so calls can be chained * } - * + * * // Other Font construction methods - * + * * public Font build() { * return this.font; * } * } * </code></pre> - * + * * Example Builder Usage: * <pre><code> * Font bold14ptSansSerifFont = new FontBuilder(Font.SANS_SERIF).bold() @@ -71,17 +71,17 @@ package org.apache.commons.lang3.builder; * .build(); * </code></pre> * - * + * * @param <T> the type of object that the builder will construct or compute. - * + * * @since 3.0 */ public interface Builder<T> { /** - * Returns a reference to the object being constructed or result being + * Returns a reference to the object being constructed or result being * calculated by the builder. - * + * * @return the object constructed or result calculated by the builder. */ T build(); diff --git a/src/main/java/org/apache/commons/lang3/builder/CompareToBuilder.java b/src/main/java/org/apache/commons/lang3/builder/CompareToBuilder.java index 875b088d7..4a0a1d11b 100644 --- a/src/main/java/org/apache/commons/lang3/builder/CompareToBuilder.java +++ b/src/main/java/org/apache/commons/lang3/builder/CompareToBuilder.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,7 +24,7 @@ import java.util.Comparator; import org.apache.commons.lang3.ArrayUtils; -/** +/** * Assists in implementing {@link java.lang.Comparable#compareTo(Object)} methods. * * <p>It is consistent with <code>equals(Object)</code> and @@ -60,7 +60,7 @@ import org.apache.commons.lang3.ArrayUtils; * } * } * </pre> - * + * * <p>Values are compared in the order they are appended to the builder. If any comparison returns * a non-zero result, then that value will be the result returned by {@code toComparison()} and all * subsequent comparisons are skipped.</p> @@ -80,8 +80,8 @@ import org.apache.commons.lang3.ArrayUtils; * return CompareToBuilder.reflectionCompare(this, o); * } * </pre> - * - * <p>The reflective methods compare object fields in the order returned by + * + * <p>The reflective methods compare object fields in the order returned by * {@link Class#getDeclaredFields()}. The fields of the class are compared first, followed by those * of its parent classes (in order from the bottom to the top of the class hierarchy).</p> * @@ -93,7 +93,7 @@ import org.apache.commons.lang3.ArrayUtils; * @since 1.0 */ public class CompareToBuilder implements Builder<Integer> { - + /** * Current state of the comparison as appended fields are checked. */ @@ -102,8 +102,8 @@ public class CompareToBuilder implements Builder<Integer> { /** * <p>Constructor for CompareToBuilder.</p> * - * <p>Starts off assuming that the objects are equal. Multiple calls are - * then made to the various append methods, followed by a call to + * <p>Starts off assuming that the objects are equal. Multiple calls are + * then made to the various append methods, followed by a call to * {@link #toComparison} to get the result.</p> */ public CompareToBuilder() { @@ -112,11 +112,11 @@ public class CompareToBuilder implements Builder<Integer> { } //----------------------------------------------------------------------- - /** + /** * <p>Compares two <code>Object</code>s via reflection.</p> * * <p>Fields can be private, thus <code>AccessibleObject.setAccessible</code> - * is used to bypass normal access control checks. This will fail under a + * is used to bypass normal access control checks. This will fail under a * security manager unless the appropriate permissions are set.</p> * * <ul> @@ -146,7 +146,7 @@ public class CompareToBuilder implements Builder<Integer> { * <p>Compares two <code>Object</code>s via reflection.</p> * * <p>Fields can be private, thus <code>AccessibleObject.setAccessible</code> - * is used to bypass normal access control checks. This will fail under a + * is used to bypass normal access control checks. This will fail under a * security manager unless the appropriate permissions are set.</p> * * <ul> @@ -178,7 +178,7 @@ public class CompareToBuilder implements Builder<Integer> { * <p>Compares two <code>Object</code>s via reflection.</p> * * <p>Fields can be private, thus <code>AccessibleObject.setAccessible</code> - * is used to bypass normal access control checks. This will fail under a + * is used to bypass normal access control checks. This will fail under a * security manager unless the appropriate permissions are set.</p> * * <ul> @@ -211,7 +211,7 @@ public class CompareToBuilder implements Builder<Integer> { * <p>Compares two <code>Object</code>s via reflection.</p> * * <p>Fields can be private, thus <code>AccessibleObject.setAccessible</code> - * is used to bypass normal access control checks. This will fail under a + * is used to bypass normal access control checks. This will fail under a * security manager unless the appropriate permissions are set.</p> * * <ul> @@ -244,7 +244,7 @@ public class CompareToBuilder implements Builder<Integer> { * <p>Compares two <code>Object</code>s via reflection.</p> * * <p>Fields can be private, thus <code>AccessibleObject.setAccessible</code> - * is used to bypass normal access control checks. This will fail under a + * is used to bypass normal access control checks. This will fail under a * security manager unless the appropriate permissions are set.</p> * * <ul> @@ -273,10 +273,10 @@ public class CompareToBuilder implements Builder<Integer> { * @since 2.2 (2.0 as <code>reflectionCompare(Object, Object, boolean, Class)</code>) */ public static int reflectionCompare( - final Object lhs, - final Object rhs, - final boolean compareTransients, - final Class<?> reflectUpToClass, + final Object lhs, + final Object rhs, + final boolean compareTransients, + final Class<?> reflectUpToClass, final String... excludeFields) { if (lhs == rhs) { @@ -301,7 +301,7 @@ public class CompareToBuilder implements Builder<Integer> { /** * <p>Appends to <code>builder</code> the comparison of <code>lhs</code> * to <code>rhs</code> using the fields defined in <code>clazz</code>.</p> - * + * * @param lhs left-hand object * @param rhs right-hand object * @param clazz <code>Class</code> that defines fields to be compared @@ -316,7 +316,7 @@ public class CompareToBuilder implements Builder<Integer> { final CompareToBuilder builder, final boolean useTransients, final String[] excludeFields) { - + final Field[] fields = clazz.getDeclaredFields(); AccessibleObject.setAccessible(fields, true); for (int i = 0; i < fields.length && builder.comparison == 0; i++) { @@ -352,7 +352,7 @@ public class CompareToBuilder implements Builder<Integer> { comparison = superCompareTo; return this; } - + //----------------------------------------------------------------------- /** * <p>Appends to the <code>builder</code> the comparison of @@ -364,7 +364,7 @@ public class CompareToBuilder implements Builder<Integer> { * a <code>null</code> object is less than a non-<code>null</code> object</li> * <li>Check the object contents</li> * </ol> - * + * * <p><code>lhs</code> must either be an array or implement {@link Comparable}.</p> * * @param lhs left-hand object @@ -498,7 +498,7 @@ public class CompareToBuilder implements Builder<Integer> { /** * Appends to the <code>builder</code> the comparison of * two <code>short</code>s. - * + * * @param lhs left-hand value * @param rhs right-hand value * @return this - used to chain append calls @@ -530,7 +530,7 @@ public class CompareToBuilder implements Builder<Integer> { /** * Appends to the <code>builder</code> the comparison of * two <code>byte</code>s. - * + * * @param lhs left-hand value * @param rhs right-hand value * @return this - used to chain append calls @@ -632,7 +632,7 @@ public class CompareToBuilder implements Builder<Integer> { public CompareToBuilder append(final Object[] lhs, final Object[] rhs) { return append(lhs, rhs, null); } - + /** * <p>Appends to the <code>builder</code> the deep comparison of * two <code>Object</code> arrays.</p> @@ -1007,7 +1007,7 @@ public class CompareToBuilder implements Builder<Integer> { * the <code>builder</code> has judged the "left-hand" side * as less than, greater than, or equal to the "right-hand" * side. - * + * * @return final comparison result * @see #build() */ @@ -1020,7 +1020,7 @@ public class CompareToBuilder implements Builder<Integer> { * the <code>builder</code> has judged the "left-hand" side * as less than, greater than, or equal to the "right-hand" * side. - * + * * @return final comparison result as an Integer * @see #toComparison() * @since 3.0 diff --git a/src/main/java/org/apache/commons/lang3/builder/Diff.java b/src/main/java/org/apache/commons/lang3/builder/Diff.java index d1b0dafd2..aee0d249b 100644 --- a/src/main/java/org/apache/commons/lang3/builder/Diff.java +++ b/src/main/java/org/apache/commons/lang3/builder/Diff.java @@ -27,13 +27,13 @@ import org.apache.commons.lang3.tuple.Pair; * A {@code Diff} contains the differences between two {@link Diffable} class * fields. * </p> - * + * * <p> * Typically, {@code Diff}s are retrieved by using a {@link DiffBuilder} to * produce a {@link DiffResult}, containing the differences between two objects. * </p> - * - * + * + * * @param <T> * The type of object contained within this {@code Diff}. Differences * between primitive objects are stored as their Object wrapper @@ -51,7 +51,7 @@ public abstract class Diff<T> extends Pair<T, T> { * <p> * Constructs a new {@code Diff} for the given field name. * </p> - * + * * @param fieldName * the name of the field */ @@ -66,7 +66,7 @@ public abstract class Diff<T> extends Pair<T, T> { * <p> * Returns the type of the field. * </p> - * + * * @return the field type */ public final Type getType() { @@ -77,7 +77,7 @@ public abstract class Diff<T> extends Pair<T, T> { * <p> * Returns the name of the field. * </p> - * + * * @return the field name */ public final String getFieldName() { @@ -88,12 +88,12 @@ public abstract class Diff<T> extends Pair<T, T> { * <p> * Returns a {@code String} representation of the {@code Diff}, with the * following format:</p> - * + * * <pre> * [fieldname: left-value, right-value] * </pre> - * - * + * + * * @return the string representation */ @Override @@ -105,7 +105,7 @@ public abstract class Diff<T> extends Pair<T, T> { * <p> * Throws {@code UnsupportedOperationException}. * </p> - * + * * @param value * ignored * @return nothing diff --git a/src/main/java/org/apache/commons/lang3/builder/DiffBuilder.java b/src/main/java/org/apache/commons/lang3/builder/DiffBuilder.java index ed2cfe93d..3645ffc54 100644 --- a/src/main/java/org/apache/commons/lang3/builder/DiffBuilder.java +++ b/src/main/java/org/apache/commons/lang3/builder/DiffBuilder.java @@ -27,19 +27,19 @@ import org.apache.commons.lang3.Validate; * <p> * Assists in implementing {@link Diffable#diff(Object)} methods. * </p> - * + * * <p> * To use this class, write code as follows: * </p> - * + * * <pre> * public class Person implements Diffable<Person> { * String name; * int age; * boolean smoker; - * + * * ... - * + * * public DiffResult diff(Person obj) { * // No need for null check, as NullPointerException correct if obj is null * return new DiffBuilder(this, obj, ToStringStyle.SHORT_PREFIX_STYLE) @@ -50,14 +50,14 @@ import org.apache.commons.lang3.Validate; * } * } * </pre> - * + * * <p> * The {@code ToStringStyle} passed to the constructor is embedded in the * returned {@code DiffResult} and influences the style of the * {@code DiffResult.toString()} method. This style choice can be overridden by * calling {@link DiffResult#toString(ToStringStyle)}. * </p> - * + * * @since 3.3 * @see Diffable * @see Diff @@ -76,13 +76,13 @@ public class DiffBuilder implements Builder<DiffResult> { * <p> * Constructs a builder for the specified objects with the specified style. * </p> - * + * * <p> * If {@code lhs == rhs} or {@code lhs.equals(rhs)} then the builder will * not evaluate any calls to {@code append(...)} and will return an empty * {@link DiffResult} when {@link #build()} is executed. * </p> - * + * * @param lhs * {@code this} object * @param rhs @@ -119,13 +119,13 @@ public class DiffBuilder implements Builder<DiffResult> { * <p> * Constructs a builder for the specified objects with the specified style. * </p> - * + * * <p> * If {@code lhs == rhs} or {@code lhs.equals(rhs)} then the builder will * not evaluate any calls to {@code append(...)} and will return an empty * {@link DiffResult} when {@link #build()} is executed. * </p> - * + * * <p> * This delegates to {@link #DiffBuilder(Object, Object, ToStringStyle, boolean)} * with the testTriviallyEqual flag enabled. @@ -151,7 +151,7 @@ public class DiffBuilder implements Builder<DiffResult> { * <p> * Test if two {@code boolean}s are equal. * </p> - * + * * @param fieldName * the field name * @param lhs @@ -191,7 +191,7 @@ public class DiffBuilder implements Builder<DiffResult> { * <p> * Test if two {@code boolean[]}s are equal. * </p> - * + * * @param fieldName * the field name * @param lhs @@ -230,7 +230,7 @@ public class DiffBuilder implements Builder<DiffResult> { * <p> * Test if two {@code byte}s are equal. * </p> - * + * * @param fieldName * the field name * @param lhs @@ -269,7 +269,7 @@ public class DiffBuilder implements Builder<DiffResult> { * <p> * Test if two {@code byte[]}s are equal. * </p> - * + * * @param fieldName * the field name * @param lhs @@ -309,7 +309,7 @@ public class DiffBuilder implements Builder<DiffResult> { * <p> * Test if two {@code char}s are equal. * </p> - * + * * @param fieldName * the field name * @param lhs @@ -349,7 +349,7 @@ public class DiffBuilder implements Builder<DiffResult> { * <p> * Test if two {@code char[]}s are equal. * </p> - * + * * @param fieldName * the field name * @param lhs @@ -389,7 +389,7 @@ public class DiffBuilder implements Builder<DiffResult> { * <p> * Test if two {@code double}s are equal. * </p> - * + * * @param fieldName * the field name * @param lhs @@ -429,7 +429,7 @@ public class DiffBuilder implements Builder<DiffResult> { * <p> * Test if two {@code double[]}s are equal. * </p> - * + * * @param fieldName * the field name * @param lhs @@ -469,7 +469,7 @@ public class DiffBuilder implements Builder<DiffResult> { * <p> * Test if two {@code float}s are equal. * </p> - * + * * @param fieldName * the field name * @param lhs @@ -509,7 +509,7 @@ public class DiffBuilder implements Builder<DiffResult> { * <p> * Test if two {@code float[]}s are equal. * </p> - * + * * @param fieldName * the field name * @param lhs @@ -549,7 +549,7 @@ public class DiffBuilder implements Builder<DiffResult> { * <p> * Test if two {@code int}s are equal. * </p> - * + * * @param fieldName * the field name * @param lhs @@ -589,7 +589,7 @@ public class DiffBuilder implements Builder<DiffResult> { * <p> * Test if two {@code int[]}s are equal. * </p> - * + * * @param fieldName * the field name * @param lhs @@ -629,7 +629,7 @@ public class DiffBuilder implements Builder<DiffResult> { * <p> * Test if two {@code long}s are equal. * </p> - * + * * @param fieldName * the field name * @param lhs @@ -669,7 +669,7 @@ public class DiffBuilder implements Builder<DiffResult> { * <p> * Test if two {@code long[]}s are equal. * </p> - * + * * @param fieldName * the field name * @param lhs @@ -709,7 +709,7 @@ public class DiffBuilder implements Builder<DiffResult> { * <p> * Test if two {@code short}s are equal. * </p> - * + * * @param fieldName * the field name * @param lhs @@ -749,7 +749,7 @@ public class DiffBuilder implements Builder<DiffResult> { * <p> * Test if two {@code short[]}s are equal. * </p> - * + * * @param fieldName * the field name * @param lhs @@ -789,7 +789,7 @@ public class DiffBuilder implements Builder<DiffResult> { * <p> * Test if two {@code Objects}s are equal. * </p> - * + * * @param fieldName * the field name * @param lhs @@ -873,7 +873,7 @@ public class DiffBuilder implements Builder<DiffResult> { * <p> * Test if two {@code Object[]}s are equal. * </p> - * + * * @param fieldName * the field name * @param lhs @@ -914,20 +914,20 @@ public class DiffBuilder implements Builder<DiffResult> { * <p> * Append diffs from another {@code DiffResult}. * </p> - * + * * <p> * This method is useful if you want to compare properties which are * themselves Diffable and would like to know which specific part of * it is different. * </p> - * + * * <pre> * public class Person implements Diffable<Person> { * String name; * Address address; // implements Diffable<Address> - * + * * ... - * + * * public DiffResult diff(Person obj) { * return new DiffBuilder(this, obj, ToStringStyle.SHORT_PREFIX_STYLE) * .append("name", this.name, obj.name) @@ -936,7 +936,7 @@ public class DiffBuilder implements Builder<DiffResult> { * } * } * </pre> - * + * * @param fieldName * the field name * @param diffResult @@ -967,7 +967,7 @@ public class DiffBuilder implements Builder<DiffResult> { * Builds a {@link DiffResult} based on the differences appended to this * builder. * </p> - * + * * @return a {@code DiffResult} containing the differences between the two * objects. */ diff --git a/src/main/java/org/apache/commons/lang3/builder/DiffResult.java b/src/main/java/org/apache/commons/lang3/builder/DiffResult.java index 4bcba6ba3..d8fa976c9 100644 --- a/src/main/java/org/apache/commons/lang3/builder/DiffResult.java +++ b/src/main/java/org/apache/commons/lang3/builder/DiffResult.java @@ -32,7 +32,7 @@ import org.apache.commons.lang3.Validate; * <p> * Use a {@link DiffBuilder} to build a {@code DiffResult} comparing two objects. * </p> - * + * * @since 3.3 */ public class DiffResult implements Iterable<Diff<?>> { @@ -57,7 +57,7 @@ public class DiffResult implements Iterable<Diff<?>> { * Creates a {@link DiffResult} containing the differences between two * objects. * </p> - * + * * @param lhs * the left hand object * @param rhs @@ -93,7 +93,7 @@ public class DiffResult implements Iterable<Diff<?>> { * Returns an unmodifiable list of {@code Diff}s. The list may be empty if * there were no differences between the objects. * </p> - * + * * @return an unmodifiable list of {@code Diff}s */ public List<Diff<?>> getDiffs() { @@ -104,7 +104,7 @@ public class DiffResult implements Iterable<Diff<?>> { * <p> * Returns the number of differences between the two objects. * </p> - * + * * @return the number of differences */ public int getNumberOfDiffs() { @@ -115,7 +115,7 @@ public class DiffResult implements Iterable<Diff<?>> { * <p> * Returns the style used by the {@link #toString()} method. * </p> - * + * * @return the style */ public ToStringStyle getToStringStyle() { @@ -129,28 +129,28 @@ public class DiffResult implements Iterable<Diff<?>> { * and the style of the output is governed by the {@code ToStringStyle} * passed to the constructor. * </p> - * + * * <p> * If there are no differences stored in this list, the method will return * {@link #OBJECTS_SAME_STRING}. Otherwise, using the example given in * {@link Diffable} and {@link ToStringStyle#SHORT_PREFIX_STYLE}, an output * might be: * </p> - * + * * <pre> * Person[name=John Doe,age=32] differs from Person[name=Joe Bloggs,age=26] * </pre> - * + * * <p> * This indicates that the objects differ in name and age, but not in * smoking status. * </p> - * + * * <p> * To use a different {@code ToStringStyle} for an instance of this class, * use {@link #toString(ToStringStyle)}. * </p> - * + * * @return a {@code String} description of the differences. */ @Override @@ -163,10 +163,10 @@ public class DiffResult implements Iterable<Diff<?>> { * Builds a {@code String} description of the differences contained within * this {@code DiffResult}, using the supplied {@code ToStringStyle}. * </p> - * + * * @param style * the {@code ToStringStyle} to use when outputting the objects - * + * * @return a {@code String} description of the differences. */ public String toString(final ToStringStyle style) { @@ -190,7 +190,7 @@ public class DiffResult implements Iterable<Diff<?>> { * <p> * Returns an iterator over the {@code Diff} objects contained in this list. * </p> - * + * * @return the iterator */ @Override diff --git a/src/main/java/org/apache/commons/lang3/builder/Diffable.java b/src/main/java/org/apache/commons/lang3/builder/Diffable.java index 9f85eb132..12bc07dbd 100644 --- a/src/main/java/org/apache/commons/lang3/builder/Diffable.java +++ b/src/main/java/org/apache/commons/lang3/builder/Diffable.java @@ -20,13 +20,13 @@ package org.apache.commons.lang3.builder; * <p>{@code Diffable} classes can be compared with other objects * for differences. The {@link DiffResult} object retrieved can be queried * for a list of differences or printed using the {@link DiffResult#toString()}.</p> - * + * * <p>The calculation of the differences is <i>consistent with equals</i> if * and only if {@code d1.equals(d2)} implies {@code d1.diff(d2) == ""}. * It is strongly recommended that implementations are consistent with equals * to avoid confusion. Note that {@code null} is not an instance of any class * and {@code d1.diff(null)} should throw a {@code NullPointerException}.</p> - * + * * <p> * {@code Diffable} classes lend themselves well to unit testing, in which a * easily readable description of the differences between an anticipated result and @@ -44,7 +44,7 @@ public interface Diffable<T> { /** * <p>Retrieves a list of the differences between * this object and the supplied object.</p> - * + * * @param obj the object to diff against, can be {@code null} * @return a list of differences * @throws NullPointerException if the specified object is {@code null} diff --git a/src/main/java/org/apache/commons/lang3/builder/EqualsBuilder.java b/src/main/java/org/apache/commons/lang3/builder/EqualsBuilder.java index aa7fb060c..a07ea2714 100644 --- a/src/main/java/org/apache/commons/lang3/builder/EqualsBuilder.java +++ b/src/main/java/org/apache/commons/lang3/builder/EqualsBuilder.java @@ -69,7 +69,7 @@ import org.apache.commons.lang3.tuple.Pair; * <code>reflectionEquals</code>, uses <code>AccessibleObject.setAccessible</code> to * change the visibility of the fields. This will fail under a security * manager, unless the appropriate permissions are set up correctly. It is - * also slower than testing explicitly. Non-primitive fields are compared using + * also slower than testing explicitly. Non-primitive fields are compared using * <code>equals()</code>.</p> * * <p> A typical invocation for this method would look like:</p> @@ -78,7 +78,7 @@ import org.apache.commons.lang3.tuple.Pair; * return EqualsBuilder.reflectionEquals(this, obj); * } * </pre> - * + * * <p>The {@link EqualsExclude} annotation can be used to exclude fields from being * used by the <code>reflectionEquals</code> methods.</p> * @@ -271,7 +271,7 @@ public class EqualsBuilder implements Builder<Boolean> { this.excludeFields = excludeFields; return this; } - + /** * <p>This method uses reflection to determine if the two <code>Object</code>s @@ -280,9 +280,9 @@ public class EqualsBuilder implements Builder<Boolean> { * <p>It uses <code>AccessibleObject.setAccessible</code> to gain access to private * fields. This means that it will throw a security exception if run under * a security manager, if the permissions are not set up correctly. It is also - * not as efficient as testing explicitly. Non-primitive fields are compared using + * not as efficient as testing explicitly. Non-primitive fields are compared using * <code>equals()</code>.</p> - * + * * <p>Transient members will be not be tested, as they are likely derived * fields, and not part of the value of the Object.</p> * @@ -292,7 +292,7 @@ public class EqualsBuilder implements Builder<Boolean> { * @param rhs the other object * @param excludeFields Collection of String field names to exclude from testing * @return <code>true</code> if the two Objects have tested equals. - * + * * @see EqualsExclude */ public static boolean reflectionEquals(final Object lhs, final Object rhs, final Collection<String> excludeFields) { @@ -306,7 +306,7 @@ public class EqualsBuilder implements Builder<Boolean> { * <p>It uses <code>AccessibleObject.setAccessible</code> to gain access to private * fields. This means that it will throw a security exception if run under * a security manager, if the permissions are not set up correctly. It is also - * not as efficient as testing explicitly. Non-primitive fields are compared using + * not as efficient as testing explicitly. Non-primitive fields are compared using * <code>equals()</code>.</p> * * <p>Transient members will be not be tested, as they are likely derived @@ -318,7 +318,7 @@ public class EqualsBuilder implements Builder<Boolean> { * @param rhs the other object * @param excludeFields array of field names to exclude from testing * @return <code>true</code> if the two Objects have tested equals. - * + * * @see EqualsExclude */ public static boolean reflectionEquals(final Object lhs, final Object rhs, final String... excludeFields) { @@ -332,7 +332,7 @@ public class EqualsBuilder implements Builder<Boolean> { * <p>It uses <code>AccessibleObject.setAccessible</code> to gain access to private * fields. This means that it will throw a security exception if run under * a security manager, if the permissions are not set up correctly. It is also - * not as efficient as testing explicitly. Non-primitive fields are compared using + * not as efficient as testing explicitly. Non-primitive fields are compared using * <code>equals()</code>.</p> * * <p>If the TestTransients parameter is set to <code>true</code>, transient @@ -345,7 +345,7 @@ public class EqualsBuilder implements Builder<Boolean> { * @param rhs the other object * @param testTransients whether to include transient fields * @return <code>true</code> if the two Objects have tested equals. - * + * * @see EqualsExclude */ public static boolean reflectionEquals(final Object lhs, final Object rhs, final boolean testTransients) { @@ -359,7 +359,7 @@ public class EqualsBuilder implements Builder<Boolean> { * <p>It uses <code>AccessibleObject.setAccessible</code> to gain access to private * fields. This means that it will throw a security exception if run under * a security manager, if the permissions are not set up correctly. It is also - * not as efficient as testing explicitly. Non-primitive fields are compared using + * not as efficient as testing explicitly. Non-primitive fields are compared using * <code>equals()</code>.</p> * * <p>If the testTransients parameter is set to <code>true</code>, transient @@ -377,7 +377,7 @@ public class EqualsBuilder implements Builder<Boolean> { * may be <code>null</code> * @param excludeFields array of field names to exclude from testing * @return <code>true</code> if the two Objects have tested equals. - * + * * @see EqualsExclude * @since 2.0 */ @@ -385,7 +385,7 @@ public class EqualsBuilder implements Builder<Boolean> { final String... excludeFields) { return reflectionEquals(lhs, rhs, testTransients, reflectUpToClass, false, excludeFields); } - + /** * <p>This method uses reflection to determine if the two <code>Object</code>s * are equal.</p> @@ -403,10 +403,10 @@ public class EqualsBuilder implements Builder<Boolean> { * <p>Static fields will not be included. Superclass fields will be appended * up to and including the specified superclass. A null superclass is treated * as java.lang.Object.</p> - * + * * <p>If the testRecursive parameter is set to <code>true</code>, non primitive - * (and non primitive wrapper) field types will be compared by - * <code>EqualsBuilder</code> recursively instead of invoking their + * (and non primitive wrapper) field types will be compared by + * <code>EqualsBuilder</code> recursively instead of invoking their * <code>equals()</code> method. Leading to a deep reflection equals test. * * @param lhs <code>this</code> object @@ -415,10 +415,10 @@ public class EqualsBuilder implements Builder<Boolean> { * @param reflectUpToClass the superclass to reflect up to (inclusive), * may be <code>null</code> * @param testRecursive whether to call reflection equals on non primitive - * fields recursively. + * fields recursively. * @param excludeFields array of field names to exclude from testing * @return <code>true</code> if the two Objects have tested equals. - * + * * @see EqualsExclude * @since 3.6 */ @@ -438,16 +438,16 @@ public class EqualsBuilder implements Builder<Boolean> { .reflectionAppend(lhs, rhs) .isEquals(); } - + /** * <p>Tests if two <code>objects</code> by using reflection.</p> - * + * * <p>It uses <code>AccessibleObject.setAccessible</code> to gain access to private * fields. This means that it will throw a security exception if run under * a security manager, if the permissions are not set up correctly. It is also - * not as efficient as testing explicitly. Non-primitive fields are compared using + * not as efficient as testing explicitly. Non-primitive fields are compared using * <code>equals()</code>.</p> - * + * * <p>If the testTransients field is set to <code>true</code>, transient * members will be tested, otherwise they are ignored, as they are likely * derived fields, and not part of the value of the <code>Object</code>.</p> @@ -455,9 +455,9 @@ public class EqualsBuilder implements Builder<Boolean> { * <p>Static fields will not be included. Superclass fields will be appended * up to and including the specified superclass in field <code>reflectUpToClass</code>. * A null superclass is treated as java.lang.Object.</p> - * + * * <p>Field names listed in field <code>excludeFields</code> will be ignored.</p> - * + * * @param lhs the left hand object * @param rhs the left hand object * @return EqualsBuilder - used to chain calls. @@ -583,10 +583,10 @@ public class EqualsBuilder implements Builder<Boolean> { //------------------------------------------------------------------------- /** - * <p>Test if two <code>Object</code>s are equal using either + * <p>Test if two <code>Object</code>s are equal using either * #{@link #reflectionAppend(Object, Object)}, if object are non - * primitives (or wrapper of primitives) or if field <code>testRecursive</code> - * is set to <code>false</code>. Otherwise, using their + * primitives (or wrapper of primitives) or if field <code>testRecursive</code> + * is set to <code>false</code>. Otherwise, using their * <code>equals</code> method.</p> * * @param lhs the left hand object @@ -794,7 +794,7 @@ public class EqualsBuilder implements Builder<Boolean> { * * <p>This also will be called for the top level of * multi-dimensional, ragged, and multi-typed arrays.</p> - * + * * <p>Note that this method does not compare the type of the arrays; it only * compares the contents.</p> * diff --git a/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java b/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java index d68e36b42..1c2d722f1 100644 --- a/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java +++ b/src/main/java/org/apache/commons/lang3/builder/HashCodeBuilder.java @@ -94,7 +94,7 @@ import org.apache.commons.lang3.Validate; * return HashCodeBuilder.reflectionHashCode(this); * } * </pre> - * + * * <p>The {@link HashCodeExclude} annotation can be used to exclude fields from being * used by the <code>reflectionHashCode</code> methods.</p> * @@ -105,12 +105,12 @@ public class HashCodeBuilder implements Builder<Integer> { * The default initial value to use in reflection hash code building. */ private static final int DEFAULT_INITIAL_VALUE = 17; - + /** * The default multiplier value to use in reflection hash code building. */ private static final int DEFAULT_MULTIPLIER_VALUE = 37; - + /** * <p> * A registry of objects used by reflection methods to detect cyclical object references and avoid infinite loops. @@ -401,7 +401,7 @@ public class HashCodeBuilder implements Builder<Integer> { * @see HashCodeExclude */ public static int reflectionHashCode(final Object object, final boolean testTransients) { - return reflectionHashCode(DEFAULT_INITIAL_VALUE, DEFAULT_MULTIPLIER_VALUE, object, + return reflectionHashCode(DEFAULT_INITIAL_VALUE, DEFAULT_MULTIPLIER_VALUE, object, testTransients, null); } @@ -482,7 +482,7 @@ public class HashCodeBuilder implements Builder<Integer> { * @see HashCodeExclude */ public static int reflectionHashCode(final Object object, final String... excludeFields) { - return reflectionHashCode(DEFAULT_INITIAL_VALUE, DEFAULT_MULTIPLIER_VALUE, object, false, + return reflectionHashCode(DEFAULT_INITIAL_VALUE, DEFAULT_MULTIPLIER_VALUE, object, false, null, excludeFields); } diff --git a/src/main/java/org/apache/commons/lang3/builder/IDKey.java b/src/main/java/org/apache/commons/lang3/builder/IDKey.java index b66cdb835..8eab0ea6c 100644 --- a/src/main/java/org/apache/commons/lang3/builder/IDKey.java +++ b/src/main/java/org/apache/commons/lang3/builder/IDKey.java @@ -20,12 +20,12 @@ package org.apache.commons.lang3.builder; // adapted from org.apache.axis.utils.IDKey /** - * Wrap an identity key (System.identityHashCode()) + * Wrap an identity key (System.identityHashCode()) * so that an object can only be equal() to itself. - * + * * This is necessary to disambiguate the occasional duplicate * identityHashCodes that can occur. - */ + */ final class IDKey { private final Object value; private final int id; @@ -33,12 +33,12 @@ final class IDKey { /** * Constructor for IDKey * @param _value The value - */ + */ public IDKey(final Object _value) { - // This is the Object hash code - id = System.identityHashCode(_value); - // There have been some cases (LANG-459) that return the - // same identity hash code for different objects. So + // This is the Object hash code + id = System.identityHashCode(_value); + // There have been some cases (LANG-459) that return the + // same identity hash code for different objects. So // the value is also added to disambiguate these cases. value = _value; } @@ -46,7 +46,7 @@ final class IDKey { /** * returns hash code - i.e. the system identity hashcode. * @return the hashcode - */ + */ @Override public int hashCode() { return id; @@ -56,7 +56,7 @@ final class IDKey { * checks if instances are equal * @param other The other object to compare to * @return if the instances are for the same object - */ + */ @Override public boolean equals(final Object other) { if (!(other instanceof IDKey)) { diff --git a/src/main/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyle.java b/src/main/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyle.java index 7c0375a33..cf8967598 100644 --- a/src/main/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyle.java +++ b/src/main/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyle.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,9 +21,9 @@ import org.apache.commons.lang3.ClassUtils; /** * <p>Works with {@link ToStringBuilder} to create a "deep" <code>toString</code>. - * But instead a single line like the {@link RecursiveToStringStyle} this creates a multiline String + * But instead a single line like the {@link RecursiveToStringStyle} this creates a multiline String * similar to the {@link ToStringStyle#MULTI_LINE_STYLE}.</p> - * + * * <p>To use this class write code as follows:</p> * * <pre> @@ -31,15 +31,15 @@ import org.apache.commons.lang3.ClassUtils; * String title; * ... * } - * + * * public class Person { * String name; * int age; * boolean smoker; * Job job; - * + * * ... - * + * * public String toString() { * return new ReflectionToStringBuilder(this, new MultilineRecursiveToStringStyle()).toString(); * } @@ -58,7 +58,7 @@ import org.apache.commons.lang3.ClassUtils; * ] * </code> * </p> - * + * * @since 3.4 */ public class MultilineRecursiveToStringStyle extends RecursiveToStringStyle { @@ -84,7 +84,7 @@ public class MultilineRecursiveToStringStyle extends RecursiveToStringStyle { } /** - * Resets the fields responsible for the line breaks and indenting. + * Resets the fields responsible for the line breaks and indenting. * Must be invoked after changing the {@link #spaces} value. */ private void resetIndent() { @@ -99,7 +99,7 @@ public class MultilineRecursiveToStringStyle extends RecursiveToStringStyle { /** * Creates a StringBuilder responsible for the indenting. - * + * * @param spaces how far to indent * @return a StringBuilder with {spaces} leading space characters. */ @@ -142,7 +142,7 @@ public class MultilineRecursiveToStringStyle extends RecursiveToStringStyle { spaces -= INDENT; resetIndent(); } - + @Override protected void appendDetail(final StringBuffer buffer, final String fieldName, final long[] array) { spaces += INDENT; diff --git a/src/main/java/org/apache/commons/lang3/builder/RecursiveToStringStyle.java b/src/main/java/org/apache/commons/lang3/builder/RecursiveToStringStyle.java index b39e9eaaa..aa5dd7149 100644 --- a/src/main/java/org/apache/commons/lang3/builder/RecursiveToStringStyle.java +++ b/src/main/java/org/apache/commons/lang3/builder/RecursiveToStringStyle.java @@ -30,7 +30,7 @@ import org.apache.commons.lang3.ClassUtils; * String title; * ... * } - * + * * public class Person { * String name; * int age; @@ -47,14 +47,14 @@ import org.apache.commons.lang3.ClassUtils; * * <p>This will produce a toString of the format: * <code>Person@7f54[name=Stephen,age=29,smoker=false,job=Job@43cd2[title=Manager]]</code></p> - * + * * @since 3.2 */ public class RecursiveToStringStyle extends ToStringStyle { /** * Required for serialization support. - * + * * @see java.io.Serializable */ private static final long serialVersionUID = 1L; @@ -83,7 +83,7 @@ public class RecursiveToStringStyle extends ToStringStyle { appendIdentityHashCode(buffer, coll); appendDetail(buffer, fieldName, coll.toArray()); } - + /** * Returns whether or not to recursively format the given <code>Class</code>. * By default, this method always returns {@code true}, but may be overwritten by diff --git a/src/main/java/org/apache/commons/lang3/builder/ReflectionDiffBuilder.java b/src/main/java/org/apache/commons/lang3/builder/ReflectionDiffBuilder.java index b1952ddd5..887368ee4 100644 --- a/src/main/java/org/apache/commons/lang3/builder/ReflectionDiffBuilder.java +++ b/src/main/java/org/apache/commons/lang3/builder/ReflectionDiffBuilder.java @@ -33,18 +33,18 @@ import org.apache.commons.lang3.reflect.FieldUtils; * of the objects to diff are discovered using reflection and compared * for differences. * </p> - * + * * <p> * To use this class, write code as follows: * </p> - * + * * <pre> * public class Person implements Diffable<Person> { * String name; * int age; * boolean smoker; * ... - * + * * public DiffResult diff(Person obj) { * // No need for null check, as NullPointerException correct if obj is null * return new ReflectionDiffBuilder(this, obj, ToStringStyle.SHORT_PREFIX_STYLE) @@ -52,7 +52,7 @@ import org.apache.commons.lang3.reflect.FieldUtils; * } * } * </pre> - * + * * <p> * The {@code ToStringStyle} passed to the constructor is embedded in the * returned {@code DiffResult} and influences the style of the @@ -75,7 +75,7 @@ public class ReflectionDiffBuilder implements Builder<DiffResult> { * <p> * Constructs a builder for the specified objects with the specified style. * </p> - * + * * <p> * If {@code lhs == rhs} or {@code lhs.equals(rhs)} then the builder will * not evaluate any calls to {@code append(...)} and will return an empty diff --git a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java index 5e512d39d..3716bc17e 100644 --- a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java +++ b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java @@ -80,7 +80,7 @@ import org.apache.commons.lang3.Validate; * } * </pre> * <p> - * Alternatively the {@link ToStringExclude} annotation can be used to exclude fields from being incorporated in the + * Alternatively the {@link ToStringExclude} annotation can be used to exclude fields from being incorporated in the * result. * </p> * <p> @@ -238,7 +238,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { * @return the String result * @throws IllegalArgumentException * if the Object is <code>null</code> - * + * * @see ToStringExclude * @since 2.1 */ @@ -291,7 +291,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { * @return the String result * @throws IllegalArgumentException * if the Object is <code>null</code> - * + * * @see ToStringExclude * @since 2.1 */ @@ -301,7 +301,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { return new ReflectionToStringBuilder(object, style, null, reflectUpToClass, outputTransients, outputStatics) .toString(); } - + /** * <p> * Builds a <code>toString</code> value through reflection. @@ -349,7 +349,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { * @return the String result * @throws IllegalArgumentException * if the Object is <code>null</code> - * + * * @see ToStringExclude * @since 3.6 */ @@ -421,7 +421,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { public static String toStringExclude(final Object object, final String... excludeFieldNames) { return new ReflectionToStringBuilder(object).setExcludeFieldNames(excludeFieldNames).toString(); } - + private static Object checkNotNull(final Object obj) { Validate.isTrue(obj != null, "The Object passed in should not be null."); return obj; @@ -436,7 +436,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { * Whether or not to append transient fields. */ private boolean appendTransients = false; - + /** * Whether or not to append fields that are null. */ @@ -545,7 +545,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { this.setAppendTransients(outputTransients); this.setAppendStatics(outputStatics); } - + /** * Constructor. * @@ -715,7 +715,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { public boolean isAppendTransients() { return this.appendTransients; } - + /** * <p> * Gets whether or not to append fields whose values are null. @@ -766,7 +766,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { public void setAppendTransients(final boolean appendTransients) { this.appendTransients = appendTransients; } - + /** * <p> * Sets whether or not to append fields whose values are null. diff --git a/src/main/java/org/apache/commons/lang3/builder/StandardToStringStyle.java b/src/main/java/org/apache/commons/lang3/builder/StandardToStringStyle.java index b9ba30c3b..f87d5b51c 100644 --- a/src/main/java/org/apache/commons/lang3/builder/StandardToStringStyle.java +++ b/src/main/java/org/apache/commons/lang3/builder/StandardToStringStyle.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,10 +28,10 @@ package org.apache.commons.lang3.builder; * @since 1.0 */ public class StandardToStringStyle extends ToStringStyle { - + /** * Required for serialization support. - * + * * @see java.io.Serializable */ private static final long serialVersionUID = 1L; @@ -42,9 +42,9 @@ public class StandardToStringStyle extends ToStringStyle { public StandardToStringStyle() { super(); } - + //--------------------------------------------------------------------- - + /** * <p>Gets whether to use the class name.</p> * @@ -66,7 +66,7 @@ public class StandardToStringStyle extends ToStringStyle { } //--------------------------------------------------------------------- - + /** * <p>Gets whether to output short or long class names.</p> * @@ -90,7 +90,7 @@ public class StandardToStringStyle extends ToStringStyle { } //--------------------------------------------------------------------- - + /** * <p>Gets whether to use the identity hash code.</p> * @return the current useIdentityHashCode flag @@ -111,7 +111,7 @@ public class StandardToStringStyle extends ToStringStyle { } //--------------------------------------------------------------------- - + /** * <p>Gets whether to use the field names passed in.</p> * @@ -133,7 +133,7 @@ public class StandardToStringStyle extends ToStringStyle { } //--------------------------------------------------------------------- - + /** * <p>Gets whether to use full detail when the caller doesn't * specify.</p> @@ -157,7 +157,7 @@ public class StandardToStringStyle extends ToStringStyle { } //--------------------------------------------------------------------- - + /** * <p>Gets whether to output array content detail.</p> * @@ -167,7 +167,7 @@ public class StandardToStringStyle extends ToStringStyle { public boolean isArrayContentDetail() { // NOPMD as this is implementing the abstract class return super.isArrayContentDetail(); } - + /** * <p>Sets whether to output array content detail.</p> * @@ -179,7 +179,7 @@ public class StandardToStringStyle extends ToStringStyle { } //--------------------------------------------------------------------- - + /** * <p>Gets the array start text.</p> * @@ -204,7 +204,7 @@ public class StandardToStringStyle extends ToStringStyle { } //--------------------------------------------------------------------- - + /** * <p>Gets the array end text.</p> * @@ -229,7 +229,7 @@ public class StandardToStringStyle extends ToStringStyle { } //--------------------------------------------------------------------- - + /** * <p>Gets the array separator text.</p> * @@ -254,7 +254,7 @@ public class StandardToStringStyle extends ToStringStyle { } //--------------------------------------------------------------------- - + /** * <p>Gets the content start text.</p> * @@ -279,7 +279,7 @@ public class StandardToStringStyle extends ToStringStyle { } //--------------------------------------------------------------------- - + /** * <p>Gets the content end text.</p> * @@ -304,7 +304,7 @@ public class StandardToStringStyle extends ToStringStyle { } //--------------------------------------------------------------------- - + /** * <p>Gets the field name value separator text.</p> * @@ -329,7 +329,7 @@ public class StandardToStringStyle extends ToStringStyle { } //--------------------------------------------------------------------- - + /** * <p>Gets the field separator text.</p> * @@ -354,11 +354,11 @@ public class StandardToStringStyle extends ToStringStyle { } //--------------------------------------------------------------------- - + /** - * <p>Gets whether the field separator should be added at the start + * <p>Gets whether the field separator should be added at the start * of each buffer.</p> - * + * * @return the fieldSeparatorAtStart flag * @since 2.0 */ @@ -368,9 +368,9 @@ public class StandardToStringStyle extends ToStringStyle { } /** - * <p>Sets whether the field separator should be added at the start + * <p>Sets whether the field separator should be added at the start * of each buffer.</p> - * + * * @param fieldSeparatorAtStart the fieldSeparatorAtStart flag * @since 2.0 */ @@ -380,11 +380,11 @@ public class StandardToStringStyle extends ToStringStyle { } //--------------------------------------------------------------------- - + /** - * <p>Gets whether the field separator should be added at the end + * <p>Gets whether the field separator should be added at the end * of each buffer.</p> - * + * * @return fieldSeparatorAtEnd flag * @since 2.0 */ @@ -394,9 +394,9 @@ public class StandardToStringStyle extends ToStringStyle { } /** - * <p>Sets whether the field separator should be added at the end + * <p>Sets whether the field separator should be added at the end * of each buffer.</p> - * + * * @param fieldSeparatorAtEnd the fieldSeparatorAtEnd flag * @since 2.0 */ @@ -406,7 +406,7 @@ public class StandardToStringStyle extends ToStringStyle { } //--------------------------------------------------------------------- - + /** * <p>Gets the text to output when <code>null</code> found.</p> * @@ -431,7 +431,7 @@ public class StandardToStringStyle extends ToStringStyle { } //--------------------------------------------------------------------- - + /** * <p>Gets the text to output when a <code>Collection</code>, * <code>Map</code> or <code>Array</code> size is output.</p> @@ -462,7 +462,7 @@ public class StandardToStringStyle extends ToStringStyle { } //--------------------------------------------------------------------- - + /** * <p>Gets the end text to output when a <code>Collection</code>, * <code>Map</code> or <code>Array</code> size is output.</p> @@ -493,7 +493,7 @@ public class StandardToStringStyle extends ToStringStyle { } //--------------------------------------------------------------------- - + /** * <p>Gets the start text to output when an <code>Object</code> is * output in summary mode.</p> @@ -524,7 +524,7 @@ public class StandardToStringStyle extends ToStringStyle { } //--------------------------------------------------------------------- - + /** * <p>Gets the end text to output when an <code>Object</code> is * output in summary mode.</p> @@ -555,5 +555,5 @@ public class StandardToStringStyle extends ToStringStyle { } //--------------------------------------------------------------------- - + } diff --git a/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java b/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java index 645525e4f..375efb783 100644 --- a/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java +++ b/src/main/java/org/apache/commons/lang3/builder/ToStringStyle.java @@ -168,10 +168,10 @@ public abstract class ToStringStyle implements Serializable { /* * Note that objects of this class are generally shared between threads, so * an instance variable would not be suitable here. - * + * * In normal use the registry should always be left empty, because the caller * should call toString() which will clean up. - * + * * See LANG-792 */ @@ -2602,7 +2602,7 @@ public abstract class ToStringStyle implements Serializable { /** * Appends the given String in parenthesis to the given StringBuffer. - * + * * @param buffer the StringBuffer to append the value to. * @param value the value to append. */ diff --git a/src/main/java/org/apache/commons/lang3/concurrent/BasicThreadFactory.java b/src/main/java/org/apache/commons/lang3/concurrent/BasicThreadFactory.java index b25a51a4f..3882b81c3 100644 --- a/src/main/java/org/apache/commons/lang3/concurrent/BasicThreadFactory.java +++ b/src/main/java/org/apache/commons/lang3/concurrent/BasicThreadFactory.java @@ -251,9 +251,9 @@ public class BasicThreadFactory implements ThreadFactory { * </p> * */ - public static class Builder + public static class Builder implements org.apache.commons.lang3.builder.Builder<BasicThreadFactory> { - + /** The wrapped factory. */ private ThreadFactory wrappedFactory; diff --git a/src/main/java/org/apache/commons/lang3/concurrent/Computable.java b/src/main/java/org/apache/commons/lang3/concurrent/Computable.java index 6cb37aaf9..c949f083e 100644 --- a/src/main/java/org/apache/commons/lang3/concurrent/Computable.java +++ b/src/main/java/org/apache/commons/lang3/concurrent/Computable.java @@ -23,7 +23,7 @@ package org.apache.commons.lang3.concurrent; * * @param <I> the type of the input to the calculation * @param <O> the type of the output of the calculation - * + * * @since 3.6 */ public interface Computable<I, O> { diff --git a/src/main/java/org/apache/commons/lang3/concurrent/ConcurrentUtils.java b/src/main/java/org/apache/commons/lang3/concurrent/ConcurrentUtils.java index d02452407..dcbea8a3d 100644 --- a/src/main/java/org/apache/commons/lang3/concurrent/ConcurrentUtils.java +++ b/src/main/java/org/apache/commons/lang3/concurrent/ConcurrentUtils.java @@ -144,7 +144,7 @@ public class ConcurrentUtils { static Throwable checkedException(final Throwable ex) { Validate.isTrue(ex != null && !(ex instanceof RuntimeException) && !(ex instanceof Error), "Not a checked exception: " + ex); - + return ex; } diff --git a/src/main/java/org/apache/commons/lang3/concurrent/Memoizer.java b/src/main/java/org/apache/commons/lang3/concurrent/Memoizer.java index fb2c15480..cae064641 100644 --- a/src/main/java/org/apache/commons/lang3/concurrent/Memoizer.java +++ b/src/main/java/org/apache/commons/lang3/concurrent/Memoizer.java @@ -48,7 +48,7 @@ import java.util.concurrent.FutureTask; * the type of the input to the calculation * @param <O> * the type of the output of the calculation - * + * * @since 3.6 */ public class Memoizer<I, O> implements Computable<I, O> { diff --git a/src/main/java/org/apache/commons/lang3/exception/CloneFailedException.java b/src/main/java/org/apache/commons/lang3/exception/CloneFailedException.java index 138b2506e..ae534b4e9 100644 --- a/src/main/java/org/apache/commons/lang3/exception/CloneFailedException.java +++ b/src/main/java/org/apache/commons/lang3/exception/CloneFailedException.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,7 +19,7 @@ package org.apache.commons.lang3.exception; /** * Exception thrown when a clone cannot be created. In contrast to * {@link CloneNotSupportedException} this is a {@link RuntimeException}. - * + * * @since 3.0 */ public class CloneFailedException extends RuntimeException { @@ -31,7 +31,7 @@ public class CloneFailedException extends RuntimeException { /** * Constructs a CloneFailedException. - * + * * @param message description of the exception * @since upcoming */ @@ -41,7 +41,7 @@ public class CloneFailedException extends RuntimeException { /** * Constructs a CloneFailedException. - * + * * @param cause cause of the exception * @since upcoming */ @@ -51,7 +51,7 @@ public class CloneFailedException extends RuntimeException { /** * Constructs a CloneFailedException. - * + * * @param message description of the exception * @param cause cause of the exception * @since upcoming diff --git a/src/main/java/org/apache/commons/lang3/exception/ContextedException.java b/src/main/java/org/apache/commons/lang3/exception/ContextedException.java index 326152a23..4ab95f37c 100644 --- a/src/main/java/org/apache/commons/lang3/exception/ContextedException.java +++ b/src/main/java/org/apache/commons/lang3/exception/ContextedException.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -80,7 +80,7 @@ import org.apache.commons.lang3.tuple.Pair; * at org.apache.commons.lang3.exception.ContextedExceptionTest.testAddValue(ContextedExceptionTest.java:88) * ..... (rest of trace) * </pre> - * + * * @see ContextedRuntimeException * @since 3.0 */ @@ -105,7 +105,7 @@ public class ContextedException extends Exception implements ExceptionContext { * Instantiates ContextedException with message, but without cause. * <p> * The context information is stored using a default implementation. - * + * * @param message the exception message, may be null */ public ContextedException(final String message) { @@ -117,7 +117,7 @@ public class ContextedException extends Exception implements ExceptionContext { * Instantiates ContextedException with cause, but without message. * <p> * The context information is stored using a default implementation. - * + * * @param cause the underlying cause of the exception, may be null */ public ContextedException(final Throwable cause) { @@ -129,7 +129,7 @@ public class ContextedException extends Exception implements ExceptionContext { * Instantiates ContextedException with cause and message. * <p> * The context information is stored using a default implementation. - * + * * @param message the exception message, may be null * @param cause the underlying cause of the exception, may be null */ @@ -140,7 +140,7 @@ public class ContextedException extends Exception implements ExceptionContext { /** * Instantiates ContextedException with cause, message, and ExceptionContext. - * + * * @param message the exception message, may be null * @param cause the underlying cause of the exception, may be null * @param context the context used to store the additional information, null uses default implementation @@ -162,13 +162,13 @@ public class ContextedException extends Exception implements ExceptionContext { * <p> * Note: This exception is only serializable if the object added is serializable. * </p> - * + * * @param label a textual label associated with information, {@code null} not recommended * @param value information needed to understand exception, may be {@code null} * @return {@code this}, for method chaining, not {@code null} */ @Override - public ContextedException addContextValue(final String label, final Object value) { + public ContextedException addContextValue(final String label, final Object value) { exceptionContext.addContextValue(label, value); return this; } @@ -181,13 +181,13 @@ public class ContextedException extends Exception implements ExceptionContext { * <p> * Note: This exception is only serializable if the object added as value is serializable. * </p> - * + * * @param label a textual label associated with information, {@code null} not recommended * @param value information needed to understand exception, may be {@code null} * @return {@code this}, for method chaining, not {@code null} */ @Override - public ContextedException setContextValue(final String label, final Object value) { + public ContextedException setContextValue(final String label, final Object value) { exceptionContext.setContextValue(label, value); return this; } @@ -226,7 +226,7 @@ public class ContextedException extends Exception implements ExceptionContext { /** * Provides the message explaining the exception, including the contextual data. - * + * * @see java.lang.Throwable#getMessage() * @return the message, never null */ @@ -237,7 +237,7 @@ public class ContextedException extends Exception implements ExceptionContext { /** * Provides the message explaining the exception without the contextual data. - * + * * @see java.lang.Throwable#getMessage() * @return the message * @since 3.0.1 diff --git a/src/main/java/org/apache/commons/lang3/exception/ContextedRuntimeException.java b/src/main/java/org/apache/commons/lang3/exception/ContextedRuntimeException.java index 012088384..9b904fce1 100644 --- a/src/main/java/org/apache/commons/lang3/exception/ContextedRuntimeException.java +++ b/src/main/java/org/apache/commons/lang3/exception/ContextedRuntimeException.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -80,7 +80,7 @@ import org.apache.commons.lang3.tuple.Pair; * at org.apache.commons.lang3.exception.ContextedRuntimeExceptionTest.testAddValue(ContextedExceptionTest.java:88) * ..... (rest of trace) * </pre> - * + * * @see ContextedException * @since 3.0 */ @@ -105,7 +105,7 @@ public class ContextedRuntimeException extends RuntimeException implements Excep * Instantiates ContextedRuntimeException with message, but without cause. * <p> * The context information is stored using a default implementation. - * + * * @param message the exception message, may be null */ public ContextedRuntimeException(final String message) { @@ -117,7 +117,7 @@ public class ContextedRuntimeException extends RuntimeException implements Excep * Instantiates ContextedRuntimeException with cause, but without message. * <p> * The context information is stored using a default implementation. - * + * * @param cause the underlying cause of the exception, may be null */ public ContextedRuntimeException(final Throwable cause) { @@ -129,7 +129,7 @@ public class ContextedRuntimeException extends RuntimeException implements Excep * Instantiates ContextedRuntimeException with cause and message. * <p> * The context information is stored using a default implementation. - * + * * @param message the exception message, may be null * @param cause the underlying cause of the exception, may be null */ @@ -140,7 +140,7 @@ public class ContextedRuntimeException extends RuntimeException implements Excep /** * Instantiates ContextedRuntimeException with cause, message, and ExceptionContext. - * + * * @param message the exception message, may be null * @param cause the underlying cause of the exception, may be null * @param context the context used to store the additional information, null uses default implementation @@ -162,13 +162,13 @@ public class ContextedRuntimeException extends RuntimeException implements Excep * <p> * Note: This exception is only serializable if the object added is serializable. * </p> - * + * * @param label a textual label associated with information, {@code null} not recommended * @param value information needed to understand exception, may be {@code null} * @return {@code this}, for method chaining, not {@code null} */ @Override - public ContextedRuntimeException addContextValue(final String label, final Object value) { + public ContextedRuntimeException addContextValue(final String label, final Object value) { exceptionContext.addContextValue(label, value); return this; } @@ -181,13 +181,13 @@ public class ContextedRuntimeException extends RuntimeException implements Excep * <p> * Note: This exception is only serializable if the object added as value is serializable. * </p> - * + * * @param label a textual label associated with information, {@code null} not recommended * @param value information needed to understand exception, may be {@code null} * @return {@code this}, for method chaining, not {@code null} */ @Override - public ContextedRuntimeException setContextValue(final String label, final Object value) { + public ContextedRuntimeException setContextValue(final String label, final Object value) { exceptionContext.setContextValue(label, value); return this; } @@ -226,7 +226,7 @@ public class ContextedRuntimeException extends RuntimeException implements Excep /** * Provides the message explaining the exception, including the contextual data. - * + * * @see java.lang.Throwable#getMessage() * @return the message, never null */ @@ -237,7 +237,7 @@ public class ContextedRuntimeException extends RuntimeException implements Excep /** * Provides the message explaining the exception without the contextual data. - * + * * @see java.lang.Throwable#getMessage() * @return the message * @since 3.0.1 diff --git a/src/main/java/org/apache/commons/lang3/exception/DefaultExceptionContext.java b/src/main/java/org/apache/commons/lang3/exception/DefaultExceptionContext.java index 17d98a456..69a4ccf55 100644 --- a/src/main/java/org/apache/commons/lang3/exception/DefaultExceptionContext.java +++ b/src/main/java/org/apache/commons/lang3/exception/DefaultExceptionContext.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,7 +33,7 @@ import org.apache.commons.lang3.tuple.Pair; * This implementation is serializable, however this is dependent on the values that * are added also being serializable. * </p> - * + * * @see ContextedException * @see ContextedRuntimeException * @since 3.0 @@ -119,7 +119,7 @@ public class DefaultExceptionContext implements ExceptionContext, Serializable { /** * Builds the message containing the contextual information. - * + * * @param baseMessage the base exception message <b>without</b> context information appended * @return the exception message <b>with</b> context information appended, never null */ @@ -129,13 +129,13 @@ public class DefaultExceptionContext implements ExceptionContext, Serializable { if (baseMessage != null) { buffer.append(baseMessage); } - + if (contextValues.size() > 0) { if (buffer.length() > 0) { buffer.append('\n'); } buffer.append("Exception Context:\n"); - + int i = 0; for (final Pair<String, Object> pair : contextValues) { buffer.append("\t["); diff --git a/src/main/java/org/apache/commons/lang3/exception/ExceptionContext.java b/src/main/java/org/apache/commons/lang3/exception/ExceptionContext.java index 1e8465929..f055d5b80 100644 --- a/src/main/java/org/apache/commons/lang3/exception/ExceptionContext.java +++ b/src/main/java/org/apache/commons/lang3/exception/ExceptionContext.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,7 +28,7 @@ import org.apache.commons.lang3.tuple.Pair; * Implementations are expected to manage the pairs in a list-style collection * that keeps the pairs in the sequence of their addition. * </p> - * + * * @see ContextedException * @see ContextedRuntimeException * @since 3.0 @@ -41,7 +41,7 @@ public interface ExceptionContext { * The pair will be added to the context, independently of an already * existing pair with the same label. * </p> - * + * * @param label the label of the item to add, {@code null} not recommended * @param value the value of item to add, may be {@code null} * @return {@code this}, for method chaining, not {@code null} @@ -54,7 +54,7 @@ public interface ExceptionContext { * The pair will be added normally, but any existing label-value pair with * the same label is removed from the context. * </p> - * + * * @param label the label of the item to add, {@code null} not recommended * @param value the value of item to add, may be {@code null} * @return {@code this}, for method chaining, not {@code null} @@ -63,7 +63,7 @@ public interface ExceptionContext { /** * Retrieves all the contextual data values associated with the label. - * + * * @param label the label to get the contextual values for, may be {@code null} * @return the contextual values associated with the label, never {@code null} */ @@ -71,7 +71,7 @@ public interface ExceptionContext { /** * Retrieves the first available contextual data value associated with the label. - * + * * @param label the label to get the contextual value for, may be {@code null} * @return the first contextual value associated with the label, may be {@code null} */ @@ -79,14 +79,14 @@ public interface ExceptionContext { /** * Retrieves the full set of labels defined in the contextual data. - * + * * @return the set of labels, not {@code null} */ Set<String> getContextLabels(); /** * Retrieves the full list of label-value pairs defined in the contextual data. - * + * * @return the list of pairs, not {@code null} */ List<Pair<String, Object>> getContextEntries(); @@ -94,7 +94,7 @@ public interface ExceptionContext { /** * Gets the contextualized error message based on a base message. * This will add the context label-value pairs to the message. - * + * * @param baseMessage the base exception message <b>without</b> context information appended * @return the exception message <b>with</b> context information appended, not {@code null} */ diff --git a/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java b/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java index 63510f00f..03185129e 100644 --- a/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java +++ b/src/main/java/org/apache/commons/lang3/exception/ExceptionUtils.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,13 +32,13 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.Validate; /** - * <p>Provides utilities for manipulating and examining + * <p>Provides utilities for manipulating and examining * <code>Throwable</code> objects.</p> * * @since 1.0 */ public class ExceptionUtils { - + /** * <p>Used when printing stack frames to denote the start of a * wrapped exception.</p> @@ -95,7 +95,7 @@ public class ExceptionUtils { /** * <p>Introspects the <code>Throwable</code> to obtain the cause.</p> * - * <p>The method searches for methods with specific names that return a + * <p>The method searches for methods with specific names that return a * <code>Throwable</code> object. This will pick up most wrapping exceptions, * including those from JDK 1.4. * @@ -110,7 +110,7 @@ public class ExceptionUtils { * <li><code>getCausedByException()</code></li> * <li><code>getNested()</code></li> * </ul> - * + * * <p>If none of the above is found, returns <code>null</code>.</p> * * @param throwable the throwable to introspect for a cause, may be null @@ -628,7 +628,7 @@ public class ExceptionUtils { * <p>This works in most cases - it will only fail if the exception * message contains a line that starts with: * <code>" at".</code></p> - * + * * @param t is any throwable * @return List of stack frames */ diff --git a/src/main/java/org/apache/commons/lang3/math/Fraction.java b/src/main/java/org/apache/commons/lang3/math/Fraction.java index d4b8ae079..e59789d66 100644 --- a/src/main/java/org/apache/commons/lang3/math/Fraction.java +++ b/src/main/java/org/apache/commons/lang3/math/Fraction.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,7 +28,7 @@ import org.apache.commons.lang3.Validate; * a <code>Number</code>.</p> * * <p>Note that this class is intended for common use cases, it is <i>int</i> - * based and thus suffers from various overflow issues. For a BigInteger based + * based and thus suffers from various overflow issues. For a BigInteger based * equivalent, please see the Commons Math BigFraction class. </p> * * @since 2.0 @@ -37,7 +37,7 @@ public final class Fraction extends Number implements Comparable<Fraction> { /** * Required for serialization support. Lang version 2.0. - * + * * @see java.io.Serializable */ private static final long serialVersionUID = 65382027393090L; @@ -166,7 +166,7 @@ public final class Fraction extends Number implements Comparable<Fraction> { * @throws ArithmeticException if the denominator is <code>zero</code> * @throws ArithmeticException if the denominator is negative * @throws ArithmeticException if the numerator is negative - * @throws ArithmeticException if the resulting numerator exceeds + * @throws ArithmeticException if the resulting numerator exceeds * <code>Integer.MAX_VALUE</code> */ public static Fraction getFraction(final int whole, final int numerator, final int denominator) { @@ -240,7 +240,7 @@ public final class Fraction extends Number implements Comparable<Fraction> { * * @param value the double value to convert * @return a new fraction instance that is close to the value - * @throws ArithmeticException if <code>|value| > Integer.MAX_VALUE</code> + * @throws ArithmeticException if <code>|value| > Integer.MAX_VALUE</code> * or <code>value = NaN</code> * @throws ArithmeticException if the calculated denominator is <code>zero</code> * @throws ArithmeticException if the the algorithm does not converge @@ -454,7 +454,7 @@ public final class Fraction extends Number implements Comparable<Fraction> { /** * <p>Reduce the fraction to the smallest values for the numerator and * denominator, returning the result.</p> - * + * * <p>For example, if this fraction represents 2/4, then the result * will be 1/2.</p> * @@ -473,7 +473,7 @@ public final class Fraction extends Number implements Comparable<Fraction> { /** * <p>Gets a fraction that is the inverse (1/fraction) of this one.</p> - * + * * <p>The returned fraction is not reduced.</p> * * @return a new fraction instance with the numerator and denominator @@ -531,7 +531,7 @@ public final class Fraction extends Number implements Comparable<Fraction> { * * @param power the power to raise the fraction to * @return <code>this</code> if the power is one, <code>ONE</code> if the power - * is zero (even if the fraction equals ZERO) or a new fraction instance + * is zero (even if the fraction equals ZERO) or a new fraction instance * raised to the appropriate power * @throws ArithmeticException if the resulting numerator or denominator exceeds * <code>Integer.MAX_VALUE</code> @@ -625,9 +625,9 @@ public final class Fraction extends Number implements Comparable<Fraction> { // Arithmetic //------------------------------------------------------------------- - /** + /** * Multiply two integers, checking for overflow. - * + * * @param x a factor * @param y a factor * @return the product <code>x*y</code> @@ -641,10 +641,10 @@ public final class Fraction extends Number implements Comparable<Fraction> { } return (int) m; } - + /** * Multiply two non-negative integers, checking for overflow. - * + * * @param x a non-negative factor * @param y a non-negative factor * @return the product <code>x*y</code> @@ -659,10 +659,10 @@ public final class Fraction extends Number implements Comparable<Fraction> { } return (int) m; } - - /** + + /** * Add two integers, checking for overflow. - * + * * @param x an addend * @param y an addend * @return the sum <code>x+y</code> @@ -676,10 +676,10 @@ public final class Fraction extends Number implements Comparable<Fraction> { } return (int) s; } - - /** + + /** * Subtract two integers, checking for overflow. - * + * * @param x the minuend * @param y the subtrahend * @return the difference <code>x-y</code> @@ -693,7 +693,7 @@ public final class Fraction extends Number implements Comparable<Fraction> { } return (int) s; } - + /** * <p>Adds the value of this fraction to another, returning the result in reduced form. * The algorithm follows Knuth, 4.5.1.</p> @@ -709,7 +709,7 @@ public final class Fraction extends Number implements Comparable<Fraction> { } /** - * <p>Subtracts the value of another fraction from the value of this one, + * <p>Subtracts the value of another fraction from the value of this one, * returning the result in reduced form.</p> * * @param fraction the fraction to subtract, must not be <code>null</code> @@ -722,9 +722,9 @@ public final class Fraction extends Number implements Comparable<Fraction> { return addSub(fraction, false /* subtract */); } - /** + /** * Implement add and subtract using algorithm described in Knuth 4.5.1. - * + * * @param fraction the fraction to subtract, must not be <code>null</code> * @param isAdd true to add, false to subtract * @return a <code>Fraction</code> instance with the resulting values @@ -771,7 +771,7 @@ public final class Fraction extends Number implements Comparable<Fraction> { } /** - * <p>Multiplies the value of this fraction by another, returning the + * <p>Multiplies the value of this fraction by another, returning the * result in reduced form.</p> * * @param fraction the fraction to multiply by, must not be <code>null</code> diff --git a/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java b/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java index 6142832c5..8cd351b50 100644 --- a/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java +++ b/src/main/java/org/apache/commons/lang3/math/IEEE754rUtils.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,10 +26,10 @@ import org.apache.commons.lang3.Validate; * @since 2.4 */ public class IEEE754rUtils { - + /** * <p>Returns the minimum value in an array.</p> - * + * * @param array an array, must not be null or empty * @return the minimum value in the array * @throws IllegalArgumentException if <code>array</code> is <code>null</code> @@ -39,19 +39,19 @@ public class IEEE754rUtils { public static double min(final double... array) { Validate.isTrue(array != null, "The Array must not be null"); Validate.isTrue(array.length != 0, "Array cannot be empty."); - + // Finds and returns min double min = array[0]; for (int i = 1; i < array.length; i++) { min = min(array[i], min); } - + return min; } /** * <p>Returns the minimum value in an array.</p> - * + * * @param array an array, must not be null or empty * @return the minimum value in the array * @throws IllegalArgumentException if <code>array</code> is <code>null</code> @@ -61,21 +61,21 @@ public class IEEE754rUtils { public static float min(final float... array) { Validate.isTrue(array != null, "The Array must not be null"); Validate.isTrue(array.length != 0, "Array cannot be empty."); - + // Finds and returns min float min = array[0]; for (int i = 1; i < array.length; i++) { min = min(array[i], min); } - + return min; } /** * <p>Gets the minimum of three <code>double</code> values.</p> - * + * * <p>NaN is only returned if all numbers are NaN as per IEEE-754r. </p> - * + * * @param a value 1 * @param b value 2 * @param c value 3 @@ -87,9 +87,9 @@ public class IEEE754rUtils { /** * <p>Gets the minimum of two <code>double</code> values.</p> - * + * * <p>NaN is only returned if all numbers are NaN as per IEEE-754r. </p> - * + * * @param a value 1 * @param b value 2 * @return the smallest of the values @@ -107,7 +107,7 @@ public class IEEE754rUtils { /** * <p>Gets the minimum of three <code>float</code> values.</p> - * + * * <p>NaN is only returned if all numbers are NaN as per IEEE-754r. </p> * * @param a value 1 @@ -121,7 +121,7 @@ public class IEEE754rUtils { /** * <p>Gets the minimum of two <code>float</code> values.</p> - * + * * <p>NaN is only returned if all numbers are NaN as per IEEE-754r. </p> * * @param a value 1 @@ -141,7 +141,7 @@ public class IEEE754rUtils { /** * <p>Returns the maximum value in an array.</p> - * + * * @param array an array, must not be null or empty * @return the minimum value in the array * @throws IllegalArgumentException if <code>array</code> is <code>null</code> @@ -151,19 +151,19 @@ public class IEEE754rUtils { public static double max(final double... array) { Validate.isTrue(array != null, "The Array must not be null"); Validate.isTrue(array.length != 0, "Array cannot be empty."); - + // Finds and returns max double max = array[0]; for (int j = 1; j < array.length; j++) { max = max(array[j], max); } - + return max; } /** * <p>Returns the maximum value in an array.</p> - * + * * @param array an array, must not be null or empty * @return the minimum value in the array * @throws IllegalArgumentException if <code>array</code> is <code>null</code> @@ -173,7 +173,7 @@ public class IEEE754rUtils { public static float max(final float... array) { Validate.isTrue(array != null, "The Array must not be null"); Validate.isTrue(array.length != 0, "Array cannot be empty."); - + // Finds and returns max float max = array[0]; for (int j = 1; j < array.length; j++) { @@ -182,10 +182,10 @@ public class IEEE754rUtils { return max; } - + /** * <p>Gets the maximum of three <code>double</code> values.</p> - * + * * <p>NaN is only returned if all numbers are NaN as per IEEE-754r. </p> * * @param a value 1 @@ -199,7 +199,7 @@ public class IEEE754rUtils { /** * <p>Gets the maximum of two <code>double</code> values.</p> - * + * * <p>NaN is only returned if all numbers are NaN as per IEEE-754r. </p> * * @param a value 1 @@ -219,7 +219,7 @@ public class IEEE754rUtils { /** * <p>Gets the maximum of three <code>float</code> values.</p> - * + * * <p>NaN is only returned if all numbers are NaN as per IEEE-754r. </p> * * @param a value 1 @@ -233,7 +233,7 @@ public class IEEE754rUtils { /** * <p>Gets the maximum of two <code>float</code> values.</p> - * + * * <p>NaN is only returned if all numbers are NaN as per IEEE-754r. </p> * * @param a value 1 diff --git a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java index 0d512fee3..1175f5dfb 100644 --- a/src/main/java/org/apache/commons/lang3/math/NumberUtils.java +++ b/src/main/java/org/apache/commons/lang3/math/NumberUtils.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,7 +30,7 @@ import org.apache.commons.lang3.Validate; * @since 2.0 */ public class NumberUtils { - + /** Reusable Long constant for zero. */ public static final Long LONG_ZERO = Long.valueOf(0L); /** Reusable Long constant for one. */ @@ -222,7 +222,7 @@ public class NumberUtils { public static float toFloat(final String str, final float defaultValue) { if (str == null) { return defaultValue; - } + } try { return Float.parseFloat(str); } catch (final NumberFormatException nfe) { @@ -425,7 +425,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> * @@ -433,7 +433,7 @@ public class NumberUtils { * and then try successively larger types from <code>Integer</code> to * <code>BigInteger</code> and from <code>Float</code> to * <code>BigDecimal</code>.</p> - * + * * <p> * Integral values with a leading {@code 0} will be interpreted as octal; the returned number will * be Integer, Long or BigDecimal as appropriate. @@ -621,7 +621,7 @@ public class NumberUtils { * <p>Utility method for {@link #createNumber(java.lang.String)}.</p> * * <p>Returns mantissa of the given number.</p> - * + * * @param str the string representation of the number * @return mantissa of the given number */ @@ -633,7 +633,7 @@ public class NumberUtils { * <p>Utility method for {@link #createNumber(java.lang.String)}.</p> * * <p>Returns mantissa of the given number.</p> - * + * * @param str the string representation of the number * @param stopPos the position of the exponent or decimal point * @return mantissa of the given number @@ -649,7 +649,7 @@ public class NumberUtils { * <p>Utility method for {@link #createNumber(java.lang.String)}.</p> * * <p>Returns <code>true</code> if s is <code>null</code>.</p> - * + * * @param str the String to check * @return if it is all zeros or <code>null</code> */ @@ -670,7 +670,7 @@ public class NumberUtils { * <p>Convert a <code>String</code> to a <code>Float</code>.</p> * * <p>Returns <code>null</code> if the string is <code>null</code>.</p> - * + * * @param str a <code>String</code> to convert, may be null * @return converted <code>Float</code> (or null if the input is null) * @throws NumberFormatException if the value cannot be converted @@ -684,7 +684,7 @@ public class NumberUtils { /** * <p>Convert a <code>String</code> to a <code>Double</code>.</p> - * + * * <p>Returns <code>null</code> if the string is <code>null</code>.</p> * * @param str a <code>String</code> to convert, may be null @@ -704,7 +704,7 @@ public class NumberUtils { * N.B. a leading zero means octal; spaces are not trimmed.</p> * * <p>Returns <code>null</code> if the string is <code>null</code>.</p> - * + * * @param str a <code>String</code> to convert, may be null * @return converted <code>Integer</code> (or null if the input is null) * @throws NumberFormatException if the value cannot be converted @@ -718,10 +718,10 @@ public class NumberUtils { } /** - * <p>Convert a <code>String</code> to a <code>Long</code>; + * <p>Convert a <code>String</code> to a <code>Long</code>; * since 3.1 it handles hex (0Xhhhh) and octal (0ddd) notations. * N.B. a leading zero means octal; spaces are not trimmed.</p> - * + * * <p>Returns <code>null</code> if the string is <code>null</code>.</p> * * @param str a <code>String</code> to convert, may be null @@ -740,7 +740,7 @@ public class NumberUtils { * since 3.2 it handles hex (0x or #) and octal (0) notations.</p> * * <p>Returns <code>null</code> if the string is <code>null</code>.</p> - * + * * @param str a <code>String</code> to convert, may be null * @return converted <code>BigInteger</code> (or null if the input is null) * @throws NumberFormatException if the value cannot be converted @@ -773,7 +773,7 @@ public class NumberUtils { /** * <p>Convert a <code>String</code> to a <code>BigDecimal</code>.</p> - * + * * <p>Returns <code>null</code> if the string is <code>null</code>.</p> * * @param str a <code>String</code> to convert, may be null @@ -790,8 +790,8 @@ public class NumberUtils { } if (str.trim().startsWith("--")) { // this is protection for poorness in java.lang.BigDecimal. - // it accepts this as a legal value, but it does not appear - // to be in specification of class. OS X Java parses it to + // it accepts this as a legal value, but it does not appear + // to be in specification of class. OS X Java parses it to // a wrong value. throw new NumberFormatException(str + " is not a valid number."); } @@ -802,7 +802,7 @@ public class NumberUtils { //-------------------------------------------------------------------- /** * <p>Returns the minimum value in an array.</p> - * + * * @param array an array, must not be null or empty * @return the minimum value in the array * @throws IllegalArgumentException if <code>array</code> is <code>null</code> @@ -812,7 +812,7 @@ public class NumberUtils { public static long min(final long... array) { // Validates input validateArray(array); - + // Finds and returns min long min = array[0]; for (int i = 1; i < array.length; i++) { @@ -820,13 +820,13 @@ public class NumberUtils { min = array[i]; } } - + return min; } /** * <p>Returns the minimum value in an array.</p> - * + * * @param array an array, must not be null or empty * @return the minimum value in the array * @throws IllegalArgumentException if <code>array</code> is <code>null</code> @@ -836,7 +836,7 @@ public class NumberUtils { public static int min(final int... array) { // Validates input validateArray(array); - + // Finds and returns min int min = array[0]; for (int j = 1; j < array.length; j++) { @@ -844,13 +844,13 @@ public class NumberUtils { min = array[j]; } } - + return min; } /** * <p>Returns the minimum value in an array.</p> - * + * * @param array an array, must not be null or empty * @return the minimum value in the array * @throws IllegalArgumentException if <code>array</code> is <code>null</code> @@ -860,7 +860,7 @@ public class NumberUtils { public static short min(final short... array) { // Validates input validateArray(array); - + // Finds and returns min short min = array[0]; for (int i = 1; i < array.length; i++) { @@ -868,13 +868,13 @@ public class NumberUtils { min = array[i]; } } - + return min; } /** * <p>Returns the minimum value in an array.</p> - * + * * @param array an array, must not be null or empty * @return the minimum value in the array * @throws IllegalArgumentException if <code>array</code> is <code>null</code> @@ -884,7 +884,7 @@ public class NumberUtils { public static byte min(final byte... array) { // Validates input validateArray(array); - + // Finds and returns min byte min = array[0]; for (int i = 1; i < array.length; i++) { @@ -892,13 +892,13 @@ public class NumberUtils { min = array[i]; } } - + return min; } /** * <p>Returns the minimum value in an array.</p> - * + * * @param array an array, must not be null or empty * @return the minimum value in the array * @throws IllegalArgumentException if <code>array</code> is <code>null</code> @@ -909,7 +909,7 @@ public class NumberUtils { public static double min(final double... array) { // Validates input validateArray(array); - + // Finds and returns min double min = array[0]; for (int i = 1; i < array.length; i++) { @@ -920,13 +920,13 @@ public class NumberUtils { min = array[i]; } } - + return min; } /** * <p>Returns the minimum value in an array.</p> - * + * * @param array an array, must not be null or empty * @return the minimum value in the array * @throws IllegalArgumentException if <code>array</code> is <code>null</code> @@ -937,7 +937,7 @@ public class NumberUtils { public static float min(final float... array) { // Validates input validateArray(array); - + // Finds and returns min float min = array[0]; for (int i = 1; i < array.length; i++) { @@ -948,7 +948,7 @@ public class NumberUtils { min = array[i]; } } - + return min; } @@ -956,7 +956,7 @@ public class NumberUtils { //-------------------------------------------------------------------- /** * <p>Returns the maximum value in an array.</p> - * + * * @param array an array, must not be null or empty * @return the maximum value in the array * @throws IllegalArgumentException if <code>array</code> is <code>null</code> @@ -980,7 +980,7 @@ public class NumberUtils { /** * <p>Returns the maximum value in an array.</p> - * + * * @param array an array, must not be null or empty * @return the maximum value in the array * @throws IllegalArgumentException if <code>array</code> is <code>null</code> @@ -990,7 +990,7 @@ public class NumberUtils { public static int max(final int... array) { // Validates input validateArray(array); - + // Finds and returns max int max = array[0]; for (int j = 1; j < array.length; j++) { @@ -998,13 +998,13 @@ public class NumberUtils { max = array[j]; } } - + return max; } /** * <p>Returns the maximum value in an array.</p> - * + * * @param array an array, must not be null or empty * @return the maximum value in the array * @throws IllegalArgumentException if <code>array</code> is <code>null</code> @@ -1014,7 +1014,7 @@ public class NumberUtils { public static short max(final short... array) { // Validates input validateArray(array); - + // Finds and returns max short max = array[0]; for (int i = 1; i < array.length; i++) { @@ -1022,13 +1022,13 @@ public class NumberUtils { max = array[i]; } } - + return max; } /** * <p>Returns the maximum value in an array.</p> - * + * * @param array an array, must not be null or empty * @return the maximum value in the array * @throws IllegalArgumentException if <code>array</code> is <code>null</code> @@ -1038,7 +1038,7 @@ public class NumberUtils { public static byte max(final byte... array) { // Validates input validateArray(array); - + // Finds and returns max byte max = array[0]; for (int i = 1; i < array.length; i++) { @@ -1046,13 +1046,13 @@ public class NumberUtils { max = array[i]; } } - + return max; } /** * <p>Returns the maximum value in an array.</p> - * + * * @param array an array, must not be null or empty * @return the maximum value in the array * @throws IllegalArgumentException if <code>array</code> is <code>null</code> @@ -1074,13 +1074,13 @@ public class NumberUtils { max = array[j]; } } - + return max; } /** * <p>Returns the maximum value in an array.</p> - * + * * @param array an array, must not be null or empty * @return the maximum value in the array * @throws IllegalArgumentException if <code>array</code> is <code>null</code> @@ -1114,14 +1114,14 @@ public class NumberUtils { */ private static void validateArray(final Object array) { Validate.isTrue(array != null, "The Array must not be null"); - Validate.isTrue(Array.getLength(array) != 0, "Array cannot be empty."); + Validate.isTrue(Array.getLength(array) != 0, "Array cannot be empty."); } - + // 3 param min //----------------------------------------------------------------------- /** * <p>Gets the minimum of three <code>long</code> values.</p> - * + * * @param a value 1 * @param b value 2 * @param c value 3 @@ -1139,7 +1139,7 @@ public class NumberUtils { /** * <p>Gets the minimum of three <code>int</code> values.</p> - * + * * @param a value 1 * @param b value 2 * @param c value 3 @@ -1157,7 +1157,7 @@ public class NumberUtils { /** * <p>Gets the minimum of three <code>short</code> values.</p> - * + * * @param a value 1 * @param b value 2 * @param c value 3 @@ -1175,7 +1175,7 @@ public class NumberUtils { /** * <p>Gets the minimum of three <code>byte</code> values.</p> - * + * * @param a value 1 * @param b value 2 * @param c value 3 @@ -1193,10 +1193,10 @@ public class NumberUtils { /** * <p>Gets the minimum of three <code>double</code> values.</p> - * + * * <p>If any value is <code>NaN</code>, <code>NaN</code> is * returned. Infinity is handled.</p> - * + * * @param a value 1 * @param b value 2 * @param c value 3 @@ -1209,7 +1209,7 @@ public class NumberUtils { /** * <p>Gets the minimum of three <code>float</code> values.</p> - * + * * <p>If any value is <code>NaN</code>, <code>NaN</code> is * returned. Infinity is handled.</p> * @@ -1227,7 +1227,7 @@ public class NumberUtils { //----------------------------------------------------------------------- /** * <p>Gets the maximum of three <code>long</code> values.</p> - * + * * @param a value 1 * @param b value 2 * @param c value 3 @@ -1245,7 +1245,7 @@ public class NumberUtils { /** * <p>Gets the maximum of three <code>int</code> values.</p> - * + * * @param a value 1 * @param b value 2 * @param c value 3 @@ -1263,7 +1263,7 @@ public class NumberUtils { /** * <p>Gets the maximum of three <code>short</code> values.</p> - * + * * @param a value 1 * @param b value 2 * @param c value 3 @@ -1281,7 +1281,7 @@ public class NumberUtils { /** * <p>Gets the maximum of three <code>byte</code> values.</p> - * + * * @param a value 1 * @param b value 2 * @param c value 3 @@ -1299,7 +1299,7 @@ public class NumberUtils { /** * <p>Gets the maximum of three <code>double</code> values.</p> - * + * * <p>If any value is <code>NaN</code>, <code>NaN</code> is * returned. Infinity is handled.</p> * @@ -1315,7 +1315,7 @@ public class NumberUtils { /** * <p>Gets the maximum of three <code>float</code> values.</p> - * + * * <p>If any value is <code>NaN</code>, <code>NaN</code> is * returned. Infinity is handled.</p> * @@ -1432,7 +1432,7 @@ public class NumberUtils { return false; } } - return true; + return true; } } sz--; // don't want to loop to the last char, check it afterwords @@ -1447,7 +1447,7 @@ public class NumberUtils { } else if (chars[i] == '.') { if (hasDecPoint || hasExp) { - // two decimal points or dec in exponent + // two decimal points or dec in exponent return false; } hasDecPoint = true; @@ -1512,7 +1512,7 @@ public class NumberUtils { // found digit it to make sure weird stuff like '.' and '1E-' doesn't pass return !allowSigns && foundDigit; } - + /** * <p>Checks whether the given String is a parsable number.</p> * diff --git a/src/main/java/org/apache/commons/lang3/mutable/Mutable.java b/src/main/java/org/apache/commons/lang3/mutable/Mutable.java index 301cac22c..85f2bdc67 100644 --- a/src/main/java/org/apache/commons/lang3/mutable/Mutable.java +++ b/src/main/java/org/apache/commons/lang3/mutable/Mutable.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,22 +25,22 @@ package org.apache.commons.lang3.mutable; * A typical use case would be to enable a primitive or string to be passed to a method and allow that method to * effectively change the value of the primitive/string. Another use case is to store a frequently changing primitive in * a collection (for example a total in a map) without needing to create new Integer/Long wrapper objects. - * - * @param <T> the type to set and get + * + * @param <T> the type to set and get * @since 2.1 */ public interface Mutable<T> { /** * Gets the value of this mutable. - * + * * @return the stored value */ T getValue(); /** * Sets the value of this mutable. - * + * * @param value * the value to store * @throws NullPointerException diff --git a/src/main/java/org/apache/commons/lang3/mutable/MutableBoolean.java b/src/main/java/org/apache/commons/lang3/mutable/MutableBoolean.java index 97781bfa7..1aec693f7 100644 --- a/src/main/java/org/apache/commons/lang3/mutable/MutableBoolean.java +++ b/src/main/java/org/apache/commons/lang3/mutable/MutableBoolean.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,8 +24,8 @@ import org.apache.commons.lang3.BooleanUtils; /** * A mutable <code>boolean</code> wrapper. * <p> - * Note that as MutableBoolean does not extend Boolean, it is not treated by String.format as a Boolean parameter. - * + * Note that as MutableBoolean does not extend Boolean, it is not treated by String.format as a Boolean parameter. + * * @see Boolean * @since 2.2 */ @@ -33,7 +33,7 @@ public class MutableBoolean implements Mutable<Boolean>, Serializable, Comparabl /** * Required for serialization support. - * + * * @see java.io.Serializable */ private static final long serialVersionUID = -4830728138360036487L; @@ -50,7 +50,7 @@ public class MutableBoolean implements Mutable<Boolean>, Serializable, Comparabl /** * Constructs a new MutableBoolean with the specified value. - * + * * @param value the initial value to store */ public MutableBoolean(final boolean value) { @@ -60,7 +60,7 @@ public class MutableBoolean implements Mutable<Boolean>, Serializable, Comparabl /** * Constructs a new MutableBoolean with the specified value. - * + * * @param value the initial value to store, not null * @throws NullPointerException if the object is null */ @@ -72,7 +72,7 @@ public class MutableBoolean implements Mutable<Boolean>, Serializable, Comparabl //----------------------------------------------------------------------- /** * Gets the value as a Boolean instance. - * + * * @return the value as a Boolean, never null */ @Override @@ -82,7 +82,7 @@ public class MutableBoolean implements Mutable<Boolean>, Serializable, Comparabl /** * Sets the value. - * + * * @param value the value to set */ public void setValue(final boolean value) { @@ -91,7 +91,7 @@ public class MutableBoolean implements Mutable<Boolean>, Serializable, Comparabl /** * Sets the value to false. - * + * * @since 3.3 */ public void setFalse() { @@ -100,7 +100,7 @@ public class MutableBoolean implements Mutable<Boolean>, Serializable, Comparabl /** * Sets the value to true. - * + * * @since 3.3 */ public void setTrue() { @@ -109,7 +109,7 @@ public class MutableBoolean implements Mutable<Boolean>, Serializable, Comparabl /** * Sets the value from any Boolean instance. - * + * * @param value the value to set, not null * @throws NullPointerException if the object is null */ @@ -121,7 +121,7 @@ public class MutableBoolean implements Mutable<Boolean>, Serializable, Comparabl //----------------------------------------------------------------------- /** * Checks if the current value is <code>true</code>. - * + * * @return <code>true</code> if the current value is <code>true</code> * @since 2.5 */ @@ -131,7 +131,7 @@ public class MutableBoolean implements Mutable<Boolean>, Serializable, Comparabl /** * Checks if the current value is <code>false</code>. - * + * * @return <code>true</code> if the current value is <code>false</code> * @since 2.5 */ @@ -142,7 +142,7 @@ public class MutableBoolean implements Mutable<Boolean>, Serializable, Comparabl //----------------------------------------------------------------------- /** * Returns the value of this MutableBoolean as a boolean. - * + * * @return the boolean value represented by this object. */ public boolean booleanValue() { @@ -165,7 +165,7 @@ public class MutableBoolean implements Mutable<Boolean>, Serializable, Comparabl * Compares this object to the specified object. The result is <code>true</code> if and only if the argument is * not <code>null</code> and is an <code>MutableBoolean</code> object that contains the same * <code>boolean</code> value as this object. - * + * * @param obj the object to compare with, null returns false * @return <code>true</code> if the objects are the same; <code>false</code> otherwise. */ @@ -179,7 +179,7 @@ public class MutableBoolean implements Mutable<Boolean>, Serializable, Comparabl /** * Returns a suitable hash code for this mutable. - * + * * @return the hash code returned by <code>Boolean.TRUE</code> or <code>Boolean.FALSE</code> */ @Override @@ -190,7 +190,7 @@ public class MutableBoolean implements Mutable<Boolean>, Serializable, Comparabl //----------------------------------------------------------------------- /** * Compares this mutable to another in ascending order. - * + * * @param other the other mutable to compare to, not null * @return negative if this is less, zero if equal, positive if greater * where false is less than true @@ -203,7 +203,7 @@ public class MutableBoolean implements Mutable<Boolean>, Serializable, Comparabl //----------------------------------------------------------------------- /** * Returns the String value of this mutable. - * + * * @return the mutable value as a string */ @Override diff --git a/src/main/java/org/apache/commons/lang3/mutable/MutableByte.java b/src/main/java/org/apache/commons/lang3/mutable/MutableByte.java index 5ceb9bbd3..0d07749ee 100644 --- a/src/main/java/org/apache/commons/lang3/mutable/MutableByte.java +++ b/src/main/java/org/apache/commons/lang3/mutable/MutableByte.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,8 +21,8 @@ import org.apache.commons.lang3.math.NumberUtils; /** * A mutable <code>byte</code> wrapper. * <p> - * Note that as MutableByte does not extend Byte, it is not treated by String.format as a Byte parameter. - * + * Note that as MutableByte does not extend Byte, it is not treated by String.format as a Byte parameter. + * * @see Byte * @since 2.1 */ @@ -30,7 +30,7 @@ public class MutableByte extends Number implements Comparable<MutableByte>, Muta /** * Required for serialization support. - * + * * @see java.io.Serializable */ private static final long serialVersionUID = -1585823265L; @@ -47,7 +47,7 @@ public class MutableByte extends Number implements Comparable<MutableByte>, Muta /** * Constructs a new MutableByte with the specified value. - * + * * @param value the initial value to store */ public MutableByte(final byte value) { @@ -57,7 +57,7 @@ public class MutableByte extends Number implements Comparable<MutableByte>, Muta /** * Constructs a new MutableByte with the specified value. - * + * * @param value the initial value to store, not null * @throws NullPointerException if the object is null */ @@ -68,7 +68,7 @@ public class MutableByte extends Number implements Comparable<MutableByte>, Muta /** * Constructs a new MutableByte parsing the given string. - * + * * @param value the string to parse, not null * @throws NumberFormatException if the string cannot be parsed into a byte * @since 2.5 @@ -81,7 +81,7 @@ public class MutableByte extends Number implements Comparable<MutableByte>, Muta //----------------------------------------------------------------------- /** * Gets the value as a Byte instance. - * + * * @return the value as a Byte, never null */ @Override @@ -91,7 +91,7 @@ public class MutableByte extends Number implements Comparable<MutableByte>, Muta /** * Sets the value. - * + * * @param value the value to set */ public void setValue(final byte value) { @@ -100,7 +100,7 @@ public class MutableByte extends Number implements Comparable<MutableByte>, Muta /** * Sets the value from any Number instance. - * + * * @param value the value to set, not null * @throws NullPointerException if the object is null */ @@ -181,7 +181,7 @@ public class MutableByte extends Number implements Comparable<MutableByte>, Muta //----------------------------------------------------------------------- /** * Adds a value to the value of this instance. - * + * * @param operand the value to add, not null * @since Commons Lang 2.2 */ @@ -191,7 +191,7 @@ public class MutableByte extends Number implements Comparable<MutableByte>, Muta /** * Adds a value to the value of this instance. - * + * * @param operand the value to add, not null * @throws NullPointerException if the object is null * @since Commons Lang 2.2 @@ -202,7 +202,7 @@ public class MutableByte extends Number implements Comparable<MutableByte>, Muta /** * Subtracts a value from the value of this instance. - * + * * @param operand the value to subtract, not null * @since Commons Lang 2.2 */ @@ -212,7 +212,7 @@ public class MutableByte extends Number implements Comparable<MutableByte>, Muta /** * Subtracts a value from the value of this instance. - * + * * @param operand the value to subtract, not null * @throws NullPointerException if the object is null * @since Commons Lang 2.2 @@ -344,7 +344,7 @@ public class MutableByte extends Number implements Comparable<MutableByte>, Muta * Compares this object to the specified object. The result is <code>true</code> if and only if the argument is * not <code>null</code> and is a <code>MutableByte</code> object that contains the same <code>byte</code> value * as this object. - * + * * @param obj the object to compare with, null returns false * @return <code>true</code> if the objects are the same; <code>false</code> otherwise. */ @@ -358,7 +358,7 @@ public class MutableByte extends Number implements Comparable<MutableByte>, Muta /** * Returns a suitable hash code for this mutable. - * + * * @return a suitable hash code */ @Override @@ -369,7 +369,7 @@ public class MutableByte extends Number implements Comparable<MutableByte>, Muta //----------------------------------------------------------------------- /** * Compares this mutable to another in ascending order. - * + * * @param other the other mutable to compare to, not null * @return negative if this is less, zero if equal, positive if greater */ @@ -381,7 +381,7 @@ public class MutableByte extends Number implements Comparable<MutableByte>, Muta //----------------------------------------------------------------------- /** * Returns the String value of this mutable. - * + * * @return the mutable value as a string */ @Override diff --git a/src/main/java/org/apache/commons/lang3/mutable/MutableDouble.java b/src/main/java/org/apache/commons/lang3/mutable/MutableDouble.java index cd89027da..dd0ac0edf 100644 --- a/src/main/java/org/apache/commons/lang3/mutable/MutableDouble.java +++ b/src/main/java/org/apache/commons/lang3/mutable/MutableDouble.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,8 +19,8 @@ package org.apache.commons.lang3.mutable; /** * A mutable <code>double</code> wrapper. * <p> - * Note that as MutableDouble does not extend Double, it is not treated by String.format as a Double parameter. - * + * Note that as MutableDouble does not extend Double, it is not treated by String.format as a Double parameter. + * * @see Double * @since 2.1 */ @@ -28,7 +28,7 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>, /** * Required for serialization support. - * + * * @see java.io.Serializable */ private static final long serialVersionUID = 1587163916L; @@ -45,7 +45,7 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>, /** * Constructs a new MutableDouble with the specified value. - * + * * @param value the initial value to store */ public MutableDouble(final double value) { @@ -55,7 +55,7 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>, /** * Constructs a new MutableDouble with the specified value. - * + * * @param value the initial value to store, not null * @throws NullPointerException if the object is null */ @@ -66,7 +66,7 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>, /** * Constructs a new MutableDouble parsing the given string. - * + * * @param value the string to parse, not null * @throws NumberFormatException if the string cannot be parsed into a double * @since 2.5 @@ -79,7 +79,7 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>, //----------------------------------------------------------------------- /** * Gets the value as a Double instance. - * + * * @return the value as a Double, never null */ @Override @@ -89,7 +89,7 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>, /** * Sets the value. - * + * * @param value the value to set */ public void setValue(final double value) { @@ -98,7 +98,7 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>, /** * Sets the value from any Number instance. - * + * * @param value the value to set, not null * @throws NullPointerException if the object is null */ @@ -110,7 +110,7 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>, //----------------------------------------------------------------------- /** * Checks whether the double value is the special NaN value. - * + * * @return true if NaN */ public boolean isNaN() { @@ -119,7 +119,7 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>, /** * Checks whether the double value is infinite. - * + * * @return true if infinite */ public boolean isInfinite() { @@ -198,7 +198,7 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>, //----------------------------------------------------------------------- /** * Adds a value to the value of this instance. - * + * * @param operand the value to add * @since Commons Lang 2.2 */ @@ -208,7 +208,7 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>, /** * Adds a value to the value of this instance. - * + * * @param operand the value to add, not null * @throws NullPointerException if the object is null * @since Commons Lang 2.2 @@ -219,7 +219,7 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>, /** * Subtracts a value from the value of this instance. - * + * * @param operand the value to subtract, not null * @since Commons Lang 2.2 */ @@ -229,7 +229,7 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>, /** * Subtracts a value from the value of this instance. - * + * * @param operand the value to subtract, not null * @throws NullPointerException if the object is null * @since Commons Lang 2.2 @@ -356,11 +356,11 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>, * <p> * Note that in most cases, for two instances of class <code>Double</code>,<code>d1</code> and <code>d2</code>, * the value of <code>d1.equals(d2)</code> is <code>true</code> if and only if <blockquote> - * + * * <pre> * d1.doubleValue() == d2.doubleValue() * </pre> - * + * * </blockquote> * <p> * also has the value <code>true</code>. However, there are two exceptions: @@ -372,7 +372,7 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>, * or vice versa, the <code>equal</code> test has the value <code>false</code>, even though * <code>+0.0==-0.0</code> has the value <code>true</code>. This allows hashtables to operate properly. * </ul> - * + * * @param obj the object to compare with, null returns false * @return <code>true</code> if the objects are the same; <code>false</code> otherwise. */ @@ -384,7 +384,7 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>, /** * Returns a suitable hash code for this mutable. - * + * * @return a suitable hash code */ @Override @@ -396,7 +396,7 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>, //----------------------------------------------------------------------- /** * Compares this mutable to another in ascending order. - * + * * @param other the other mutable to compare to, not null * @return negative if this is less, zero if equal, positive if greater */ @@ -408,7 +408,7 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>, //----------------------------------------------------------------------- /** * Returns the String value of this mutable. - * + * * @return the mutable value as a string */ @Override diff --git a/src/main/java/org/apache/commons/lang3/mutable/MutableFloat.java b/src/main/java/org/apache/commons/lang3/mutable/MutableFloat.java index 6ed0980a8..eec7cf126 100644 --- a/src/main/java/org/apache/commons/lang3/mutable/MutableFloat.java +++ b/src/main/java/org/apache/commons/lang3/mutable/MutableFloat.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -19,8 +19,8 @@ package org.apache.commons.lang3.mutable; /** * A mutable <code>float</code> wrapper. * <p> - * Note that as MutableFloat does not extend Float, it is not treated by String.format as a Float parameter. - * + * Note that as MutableFloat does not extend Float, it is not treated by String.format as a Float parameter. + * * @see Float * @since 2.1 */ @@ -28,7 +28,7 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu /** * Required for serialization support. - * + * * @see java.io.Serializable */ private static final long serialVersionUID = 5787169186L; @@ -45,7 +45,7 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu /** * Constructs a new MutableFloat with the specified value. - * + * * @param value the initial value to store */ public MutableFloat(final float value) { @@ -55,7 +55,7 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu /** * Constructs a new MutableFloat with the specified value. - * + * * @param value the initial value to store, not null * @throws NullPointerException if the object is null */ @@ -66,7 +66,7 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu /** * Constructs a new MutableFloat parsing the given string. - * + * * @param value the string to parse, not null * @throws NumberFormatException if the string cannot be parsed into a float * @since 2.5 @@ -79,7 +79,7 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu //----------------------------------------------------------------------- /** * Gets the value as a Float instance. - * + * * @return the value as a Float, never null */ @Override @@ -89,7 +89,7 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu /** * Sets the value. - * + * * @param value the value to set */ public void setValue(final float value) { @@ -98,7 +98,7 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu /** * Sets the value from any Number instance. - * + * * @param value the value to set, not null * @throws NullPointerException if the object is null */ @@ -110,7 +110,7 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu //----------------------------------------------------------------------- /** * Checks whether the float value is the special NaN value. - * + * * @return true if NaN */ public boolean isNaN() { @@ -119,7 +119,7 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu /** * Checks whether the float value is infinite. - * + * * @return true if infinite */ public boolean isInfinite() { @@ -198,7 +198,7 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu //----------------------------------------------------------------------- /** * Adds a value to the value of this instance. - * + * * @param operand the value to add, not null * @since Commons Lang 2.2 */ @@ -208,7 +208,7 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu /** * Adds a value to the value of this instance. - * + * * @param operand the value to add, not null * @throws NullPointerException if the object is null * @since Commons Lang 2.2 @@ -219,7 +219,7 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu /** * Subtracts a value from the value of this instance. - * + * * @param operand the value to subtract * @since Commons Lang 2.2 */ @@ -229,7 +229,7 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu /** * Subtracts a value from the value of this instance. - * + * * @param operand the value to subtract, not null * @throws NullPointerException if the object is null * @since Commons Lang 2.2 @@ -356,11 +356,11 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu * <p> * Note that in most cases, for two instances of class <code>Float</code>,<code>f1</code> and <code>f2</code>, * the value of <code>f1.equals(f2)</code> is <code>true</code> if and only if <blockquote> - * + * * <pre> * f1.floatValue() == f2.floatValue() * </pre> - * + * * </blockquote> * <p> * also has the value <code>true</code>. However, there are two exceptions: @@ -373,7 +373,7 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu * <code>0.0f==-0.0f</code> has the value <code>true</code>. * </ul> * This definition allows hashtables to operate properly. - * + * * @param obj the object to compare with, null returns false * @return <code>true</code> if the objects are the same; <code>false</code> otherwise. * @see java.lang.Float#floatToIntBits(float) @@ -386,7 +386,7 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu /** * Returns a suitable hash code for this mutable. - * + * * @return a suitable hash code */ @Override @@ -397,7 +397,7 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu //----------------------------------------------------------------------- /** * Compares this mutable to another in ascending order. - * + * * @param other the other mutable to compare to, not null * @return negative if this is less, zero if equal, positive if greater */ @@ -409,7 +409,7 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu //----------------------------------------------------------------------- /** * Returns the String value of this mutable. - * + * * @return the mutable value as a string */ @Override diff --git a/src/main/java/org/apache/commons/lang3/mutable/MutableInt.java b/src/main/java/org/apache/commons/lang3/mutable/MutableInt.java index 7311f00a2..6e022bd79 100644 --- a/src/main/java/org/apache/commons/lang3/mutable/MutableInt.java +++ b/src/main/java/org/apache/commons/lang3/mutable/MutableInt.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,8 +21,8 @@ import org.apache.commons.lang3.math.NumberUtils; /** * A mutable <code>int</code> wrapper. * <p> - * Note that as MutableInt does not extend Integer, it is not treated by String.format as an Integer parameter. - * + * Note that as MutableInt does not extend Integer, it is not treated by String.format as an Integer parameter. + * * @see Integer * @since 2.1 */ @@ -30,7 +30,7 @@ public class MutableInt extends Number implements Comparable<MutableInt>, Mutabl /** * Required for serialization support. - * + * * @see java.io.Serializable */ private static final long serialVersionUID = 512176391864L; @@ -47,7 +47,7 @@ public class MutableInt extends Number implements Comparable<MutableInt>, Mutabl /** * Constructs a new MutableInt with the specified value. - * + * * @param value the initial value to store */ public MutableInt(final int value) { @@ -57,7 +57,7 @@ public class MutableInt extends Number implements Comparable<MutableInt>, Mutabl /** * Constructs a new MutableInt with the specified value. - * + * * @param value the initial value to store, not null * @throws NullPointerException if the object is null */ @@ -68,7 +68,7 @@ public class MutableInt extends Number implements Comparable<MutableInt>, Mutabl /** * Constructs a new MutableInt parsing the given string. - * + * * @param value the string to parse, not null * @throws NumberFormatException if the string cannot be parsed into an int * @since 2.5 @@ -81,7 +81,7 @@ public class MutableInt extends Number implements Comparable<MutableInt>, Mutabl //----------------------------------------------------------------------- /** * Gets the value as a Integer instance. - * + * * @return the value as a Integer, never null */ @Override @@ -91,7 +91,7 @@ public class MutableInt extends Number implements Comparable<MutableInt>, Mutabl /** * Sets the value. - * + * * @param value the value to set */ public void setValue(final int value) { @@ -100,7 +100,7 @@ public class MutableInt extends Number implements Comparable<MutableInt>, Mutabl /** * Sets the value from any Number instance. - * + * * @param value the value to set, not null * @throws NullPointerException if the object is null */ @@ -181,7 +181,7 @@ public class MutableInt extends Number implements Comparable<MutableInt>, Mutabl //----------------------------------------------------------------------- /** * Adds a value to the value of this instance. - * + * * @param operand the value to add, not null * @since Commons Lang 2.2 */ @@ -191,7 +191,7 @@ public class MutableInt extends Number implements Comparable<MutableInt>, Mutabl /** * Adds a value to the value of this instance. - * + * * @param operand the value to add, not null * @throws NullPointerException if the object is null * @since Commons Lang 2.2 @@ -202,7 +202,7 @@ public class MutableInt extends Number implements Comparable<MutableInt>, Mutabl /** * Subtracts a value from the value of this instance. - * + * * @param operand the value to subtract, not null * @since Commons Lang 2.2 */ @@ -212,7 +212,7 @@ public class MutableInt extends Number implements Comparable<MutableInt>, Mutabl /** * Subtracts a value from the value of this instance. - * + * * @param operand the value to subtract, not null * @throws NullPointerException if the object is null * @since Commons Lang 2.2 @@ -334,7 +334,7 @@ public class MutableInt extends Number implements Comparable<MutableInt>, Mutabl * Compares this object to the specified object. The result is <code>true</code> if and only if the argument is * not <code>null</code> and is a <code>MutableInt</code> object that contains the same <code>int</code> value * as this object. - * + * * @param obj the object to compare with, null returns false * @return <code>true</code> if the objects are the same; <code>false</code> otherwise. */ @@ -348,7 +348,7 @@ public class MutableInt extends Number implements Comparable<MutableInt>, Mutabl /** * Returns a suitable hash code for this mutable. - * + * * @return a suitable hash code */ @Override @@ -359,7 +359,7 @@ public class MutableInt extends Number implements Comparable<MutableInt>, Mutabl //----------------------------------------------------------------------- /** * Compares this mutable to another in ascending order. - * + * * @param other the other mutable to compare to, not null * @return negative if this is less, zero if equal, positive if greater */ @@ -371,7 +371,7 @@ public class MutableInt extends Number implements Comparable<MutableInt>, Mutabl //----------------------------------------------------------------------- /** * Returns the String value of this mutable. - * + * * @return the mutable value as a string */ @Override diff --git a/src/main/java/org/apache/commons/lang3/mutable/MutableLong.java b/src/main/java/org/apache/commons/lang3/mutable/MutableLong.java index 5b6254a91..dbd32d5d7 100644 --- a/src/main/java/org/apache/commons/lang3/mutable/MutableLong.java +++ b/src/main/java/org/apache/commons/lang3/mutable/MutableLong.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,8 +21,8 @@ import org.apache.commons.lang3.math.NumberUtils; /** * A mutable <code>long</code> wrapper. * <p> - * Note that as MutableLong does not extend Long, it is not treated by String.format as a Long parameter. - * + * Note that as MutableLong does not extend Long, it is not treated by String.format as a Long parameter. + * * @see Long * @since 2.1 */ @@ -30,7 +30,7 @@ public class MutableLong extends Number implements Comparable<MutableLong>, Muta /** * Required for serialization support. - * + * * @see java.io.Serializable */ private static final long serialVersionUID = 62986528375L; @@ -47,7 +47,7 @@ public class MutableLong extends Number implements Comparable<MutableLong>, Muta /** * Constructs a new MutableLong with the specified value. - * + * * @param value the initial value to store */ public MutableLong(final long value) { @@ -57,7 +57,7 @@ public class MutableLong extends Number implements Comparable<MutableLong>, Muta /** * Constructs a new MutableLong with the specified value. - * + * * @param value the initial value to store, not null * @throws NullPointerException if the object is null */ @@ -68,7 +68,7 @@ public class MutableLong extends Number implements Comparable<MutableLong>, Muta /** * Constructs a new MutableLong parsing the given string. - * + * * @param value the string to parse, not null * @throws NumberFormatException if the string cannot be parsed into a long * @since 2.5 @@ -81,7 +81,7 @@ public class MutableLong extends Number implements Comparable<MutableLong>, Muta //----------------------------------------------------------------------- /** * Gets the value as a Long instance. - * + * * @return the value as a Long, never null */ @Override @@ -91,7 +91,7 @@ public class MutableLong extends Number implements Comparable<MutableLong>, Muta /** * Sets the value. - * + * * @param value the value to set */ public void setValue(final long value) { @@ -100,7 +100,7 @@ public class MutableLong extends Number implements Comparable<MutableLong>, Muta /** * Sets the value from any Number instance. - * + * * @param value the value to set, not null * @throws NullPointerException if the object is null */ @@ -181,7 +181,7 @@ public class MutableLong extends Number implements Comparable<MutableLong>, Muta //----------------------------------------------------------------------- /** * Adds a value to the value of this instance. - * + * * @param operand the value to add, not null * @since Commons Lang 2.2 */ @@ -191,7 +191,7 @@ public class MutableLong extends Number implements Comparable<MutableLong>, Muta /** * Adds a value to the value of this instance. - * + * * @param operand the value to add, not null * @throws NullPointerException if the object is null * @since Commons Lang 2.2 @@ -202,7 +202,7 @@ public class MutableLong extends Number implements Comparable<MutableLong>, Muta /** * Subtracts a value from the value of this instance. - * + * * @param operand the value to subtract, not null * @since Commons Lang 2.2 */ @@ -212,7 +212,7 @@ public class MutableLong extends Number implements Comparable<MutableLong>, Muta /** * Subtracts a value from the value of this instance. - * + * * @param operand the value to subtract, not null * @throws NullPointerException if the object is null * @since Commons Lang 2.2 @@ -334,7 +334,7 @@ public class MutableLong extends Number implements Comparable<MutableLong>, Muta * Compares this object to the specified object. The result is <code>true</code> if and only if the argument * is not <code>null</code> and is a <code>MutableLong</code> object that contains the same <code>long</code> * value as this object. - * + * * @param obj the object to compare with, null returns false * @return <code>true</code> if the objects are the same; <code>false</code> otherwise. */ @@ -348,7 +348,7 @@ public class MutableLong extends Number implements Comparable<MutableLong>, Muta /** * Returns a suitable hash code for this mutable. - * + * * @return a suitable hash code */ @Override @@ -359,7 +359,7 @@ public class MutableLong extends Number implements Comparable<MutableLong>, Muta //----------------------------------------------------------------------- /** * Compares this mutable to another in ascending order. - * + * * @param other the other mutable to compare to, not null * @return negative if this is less, zero if equal, positive if greater */ @@ -371,7 +371,7 @@ public class MutableLong extends Number implements Comparable<MutableLong>, Muta //----------------------------------------------------------------------- /** * Returns the String value of this mutable. - * + * * @return the mutable value as a string */ @Override diff --git a/src/main/java/org/apache/commons/lang3/mutable/MutableObject.java b/src/main/java/org/apache/commons/lang3/mutable/MutableObject.java index 180cf3a70..3c78bc1d9 100644 --- a/src/main/java/org/apache/commons/lang3/mutable/MutableObject.java +++ b/src/main/java/org/apache/commons/lang3/mutable/MutableObject.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,15 +21,15 @@ import java.io.Serializable; /** * A mutable <code>Object</code> wrapper. - * - * @param <T> the type to set and get + * + * @param <T> the type to set and get * @since 2.1 */ public class MutableObject<T> implements Mutable<T>, Serializable { /** * Required for serialization support. - * + * * @see java.io.Serializable */ private static final long serialVersionUID = 86241875189L; @@ -46,7 +46,7 @@ public class MutableObject<T> implements Mutable<T>, Serializable { /** * Constructs a new MutableObject with the specified value. - * + * * @param value the initial value to store */ public MutableObject(final T value) { @@ -57,7 +57,7 @@ public class MutableObject<T> implements Mutable<T>, Serializable { //----------------------------------------------------------------------- /** * Gets the value. - * + * * @return the value, may be null */ @Override @@ -67,7 +67,7 @@ public class MutableObject<T> implements Mutable<T>, Serializable { /** * Sets the value. - * + * * @param value the value to set */ @Override @@ -82,7 +82,7 @@ public class MutableObject<T> implements Mutable<T>, Serializable { * is not <code>null</code> and is a <code>MutableObject</code> object that contains the same <code>T</code> * value as this object. * </p> - * + * * @param obj the object to compare with, <code>null</code> returns <code>false</code> * @return <code>true</code> if the objects are the same; * <code>true</code> if the objects have equivalent <code>value</code> fields; @@ -105,7 +105,7 @@ public class MutableObject<T> implements Mutable<T>, Serializable { /** * Returns the value's hash code or <code>0</code> if the value is <code>null</code>. - * + * * @return the value's hash code or <code>0</code> if the value is <code>null</code>. */ @Override @@ -116,7 +116,7 @@ public class MutableObject<T> implements Mutable<T>, Serializable { //----------------------------------------------------------------------- /** * Returns the String value of this mutable. - * + * * @return the mutable value as a string */ @Override diff --git a/src/main/java/org/apache/commons/lang3/mutable/MutableShort.java b/src/main/java/org/apache/commons/lang3/mutable/MutableShort.java index 01d604f06..1cbd84768 100644 --- a/src/main/java/org/apache/commons/lang3/mutable/MutableShort.java +++ b/src/main/java/org/apache/commons/lang3/mutable/MutableShort.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,8 +21,8 @@ import org.apache.commons.lang3.math.NumberUtils; /** * A mutable <code>short</code> wrapper. * <p> - * Note that as MutableShort does not extend Short, it is not treated by String.format as a Short parameter. - * + * Note that as MutableShort does not extend Short, it is not treated by String.format as a Short parameter. + * * @see Short * @since 2.1 */ @@ -30,7 +30,7 @@ public class MutableShort extends Number implements Comparable<MutableShort>, Mu /** * Required for serialization support. - * + * * @see java.io.Serializable */ private static final long serialVersionUID = -2135791679L; @@ -47,7 +47,7 @@ public class MutableShort extends Number implements Comparable<MutableShort>, Mu /** * Constructs a new MutableShort with the specified value. - * + * * @param value the initial value to store */ public MutableShort(final short value) { @@ -57,7 +57,7 @@ public class MutableShort extends Number implements Comparable<MutableShort>, Mu /** * Constructs a new MutableShort with the specified value. - * + * * @param value the initial value to store, not null * @throws NullPointerException if the object is null */ @@ -68,7 +68,7 @@ public class MutableShort extends Number implements Comparable<MutableShort>, Mu /** * Constructs a new MutableShort parsing the given string. - * + * * @param value the string to parse, not null * @throws NumberFormatException if the string cannot be parsed into a short * @since 2.5 @@ -81,7 +81,7 @@ public class MutableShort extends Number implements Comparable<MutableShort>, Mu //----------------------------------------------------------------------- /** * Gets the value as a Short instance. - * + * * @return the value as a Short, never null */ @Override @@ -91,7 +91,7 @@ public class MutableShort extends Number implements Comparable<MutableShort>, Mu /** * Sets the value. - * + * * @param value the value to set */ public void setValue(final short value) { @@ -100,7 +100,7 @@ public class MutableShort extends Number implements Comparable<MutableShort>, Mu /** * Sets the value from any Number instance. - * + * * @param value the value to set, not null * @throws NullPointerException if the object is null */ @@ -181,7 +181,7 @@ public class MutableShort extends Number implements Comparable<MutableShort>, Mu //----------------------------------------------------------------------- /** * Adds a value to the value of this instance. - * + * * @param operand the value to add, not null * @since Commons Lang 2.2 */ @@ -191,7 +191,7 @@ public class MutableShort extends Number implements Comparable<MutableShort>, Mu /** * Adds a value to the value of this instance. - * + * * @param operand the value to add, not null * @throws NullPointerException if the object is null * @since Commons Lang 2.2 @@ -202,7 +202,7 @@ public class MutableShort extends Number implements Comparable<MutableShort>, Mu /** * Subtracts a value from the value of this instance. - * + * * @param operand the value to subtract, not null * @since Commons Lang 2.2 */ @@ -212,7 +212,7 @@ public class MutableShort extends Number implements Comparable<MutableShort>, Mu /** * Subtracts a value from the value of this instance. - * + * * @param operand the value to subtract, not null * @throws NullPointerException if the object is null * @since Commons Lang 2.2 @@ -344,7 +344,7 @@ public class MutableShort extends Number implements Comparable<MutableShort>, Mu * Compares this object to the specified object. The result is <code>true</code> if and only if the argument * is not <code>null</code> and is a <code>MutableShort</code> object that contains the same <code>short</code> * value as this object. - * + * * @param obj the object to compare with, null returns false * @return <code>true</code> if the objects are the same; <code>false</code> otherwise. */ @@ -358,7 +358,7 @@ public class MutableShort extends Number implements Comparable<MutableShort>, Mu /** * Returns a suitable hash code for this mutable. - * + * * @return a suitable hash code */ @Override @@ -369,7 +369,7 @@ public class MutableShort extends Number implements Comparable<MutableShort>, Mu //----------------------------------------------------------------------- /** * Compares this mutable to another in ascending order. - * + * * @param other the other mutable to compare to, not null * @return negative if this is less, zero if equal, positive if greater */ @@ -381,7 +381,7 @@ public class MutableShort extends Number implements Comparable<MutableShort>, Mu //----------------------------------------------------------------------- /** * Returns the String value of this mutable. - * + * * @return the mutable value as a string */ @Override diff --git a/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java b/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java index 0808fc73c..b6fb70de5 100644 --- a/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java +++ b/src/main/java/org/apache/commons/lang3/reflect/ConstructorUtils.java @@ -60,7 +60,7 @@ public class ConstructorUtils { /** * <p>Returns a new instance of the specified class inferring the right constructor * from the types of the arguments.</p> - * + * * <p>This locates and calls a constructor. * The constructor signature must match the argument types by assignment compatibility.</p> * @@ -87,7 +87,7 @@ public class ConstructorUtils { /** * <p>Returns a new instance of the specified class choosing the right constructor * from the list of parameter types.</p> - * + * * <p>This locates and calls a constructor. * The constructor signature must match the parameter types by assignment compatibility.</p> * @@ -184,7 +184,7 @@ public class ConstructorUtils { //----------------------------------------------------------------------- /** * <p>Finds a constructor given a class and signature, checking accessibility.</p> - * + * * <p>This finds the constructor and ensures that it is accessible. * The constructor signature must match the parameter types exactly.</p> * @@ -208,7 +208,7 @@ public class ConstructorUtils { /** * <p>Checks if the specified constructor is accessible.</p> - * + * * <p>This simply ensures that the constructor is accessible.</p> * * @param <T> the constructor type @@ -225,7 +225,7 @@ public class ConstructorUtils { /** * <p>Finds an accessible constructor with compatible parameters.</p> - * + * * <p>This checks all the constructor and finds one with compatible parameters * This requires that every parameter is assignable from the given parameter types. * This is a more flexible search than the normal exact matching algorithm.</p> diff --git a/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java b/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java index 8b4ac3042..aa2287a18 100644 --- a/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java +++ b/src/main/java/org/apache/commons/lang3/reflect/FieldUtils.java @@ -32,7 +32,7 @@ import java.util.List; * <p> * The ability is provided to break the scoping restrictions coded by the programmer. This can allow fields to be * changed that shouldn't be. This facility should be used with care. - * + * * @since 2.5 */ public class FieldUtils { @@ -49,7 +49,7 @@ public class FieldUtils { /** * Gets an accessible {@link Field} by name respecting scope. Superclasses/interfaces will be considered. - * + * * @param cls * the {@link Class} to reflect, must not be {@code null} * @param fieldName @@ -67,7 +67,7 @@ public class FieldUtils { /** * Gets an accessible {@link Field} by name, breaking scope if requested. Superclasses/interfaces will be * considered. - * + * * @param cls * the {@link Class} to reflect, must not be {@code null} * @param fieldName @@ -135,7 +135,7 @@ public class FieldUtils { /** * Gets an accessible {@link Field} by name respecting scope. Only the specified class will be considered. - * + * * @param cls * the {@link Class} to reflect, must not be {@code null} * @param fieldName @@ -151,7 +151,7 @@ public class FieldUtils { /** * Gets an accessible {@link Field} by name, breaking scope if requested. Only the specified class will be * considered. - * + * * @param cls * the {@link Class} to reflect, must not be {@code null} * @param fieldName @@ -186,7 +186,7 @@ public class FieldUtils { /** * Gets all fields of the given class and its parents (if any). - * + * * @param cls * the {@link Class} to query * @return an array of Fields (possibly empty). @@ -201,7 +201,7 @@ public class FieldUtils { /** * Gets all fields of the given class and its parents (if any). - * + * * @param cls * the {@link Class} to query * @return an array of Fields (possibly empty). @@ -264,7 +264,7 @@ public class FieldUtils { /** * Reads an accessible {@code static} {@link Field}. - * + * * @param field * to read * @return the field value @@ -279,7 +279,7 @@ public class FieldUtils { /** * Reads a static {@link Field}. - * + * * @param field * to read * @param forceAccess @@ -299,7 +299,7 @@ public class FieldUtils { /** * Reads the named {@code public static} {@link Field}. Superclasses will be considered. - * + * * @param cls * the {@link Class} to reflect, must not be {@code null} * @param fieldName @@ -317,7 +317,7 @@ public class FieldUtils { /** * Reads the named {@code static} {@link Field}. Superclasses will be considered. - * + * * @param cls * the {@link Class} to reflect, must not be {@code null} * @param fieldName @@ -343,7 +343,7 @@ public class FieldUtils { /** * Gets the value of a {@code static} {@link Field} by name. The field must be {@code public}. Only the specified * class will be considered. - * + * * @param cls * the {@link Class} to reflect, must not be {@code null} * @param fieldName @@ -361,7 +361,7 @@ public class FieldUtils { /** * Gets the value of a {@code static} {@link Field} by name. Only the specified class will be considered. - * + * * @param cls * the {@link Class} to reflect, must not be {@code null} * @param fieldName @@ -386,7 +386,7 @@ public class FieldUtils { /** * Reads an accessible {@link Field}. - * + * * @param field * the field to use * @param target @@ -403,7 +403,7 @@ public class FieldUtils { /** * Reads a {@link Field}. - * + * * @param field * the field to use * @param target @@ -429,7 +429,7 @@ public class FieldUtils { /** * Reads the named {@code public} {@link Field}. Superclasses will be considered. - * + * * @param target * the object to reflect, must not be {@code null} * @param fieldName @@ -446,7 +446,7 @@ public class FieldUtils { /** * Reads the named {@link Field}. Superclasses will be considered. - * + * * @param target * the object to reflect, must not be {@code null} * @param fieldName @@ -472,7 +472,7 @@ public class FieldUtils { /** * Reads the named {@code public} {@link Field}. Only the class of the specified object will be considered. - * + * * @param target * the object to reflect, must not be {@code null} * @param fieldName @@ -489,7 +489,7 @@ public class FieldUtils { /** * Gets a {@link Field} value by name. Only the class of the specified object will be considered. - * + * * @param target * the object to reflect, must not be {@code null} * @param fieldName @@ -515,7 +515,7 @@ public class FieldUtils { /** * Writes a {@code public static} {@link Field}. - * + * * @param field * to write * @param value @@ -531,7 +531,7 @@ public class FieldUtils { /** * Writes a static {@link Field}. - * + * * @param field * to write * @param value @@ -554,7 +554,7 @@ public class FieldUtils { /** * Writes a named {@code public static} {@link Field}. Superclasses will be considered. - * + * * @param cls * {@link Class} on which the field is to be found * @param fieldName @@ -573,7 +573,7 @@ public class FieldUtils { /** * Writes a named {@code static} {@link Field}. Superclasses will be considered. - * + * * @param cls * {@link Class} on which the field is to be found * @param fieldName @@ -600,7 +600,7 @@ public class FieldUtils { /** * Writes a named {@code public static} {@link Field}. Only the specified class will be considered. - * + * * @param cls * {@link Class} on which the field is to be found * @param fieldName @@ -619,7 +619,7 @@ public class FieldUtils { /** * Writes a named {@code static} {@link Field}. Only the specified class will be considered. - * + * * @param cls * {@link Class} on which the field is to be found * @param fieldName @@ -645,7 +645,7 @@ public class FieldUtils { /** * Writes an accessible {@link Field}. - * + * * @param field * to write * @param target @@ -662,7 +662,7 @@ public class FieldUtils { /** * Writes a {@link Field}. - * + * * @param field * to write * @param target @@ -691,7 +691,7 @@ public class FieldUtils { /** * Removes the final modifier from a {@link Field}. - * + * * @param field * to remove the final modifier * @throws IllegalArgumentException @@ -704,7 +704,7 @@ public class FieldUtils { /** * Removes the final modifier from a {@link Field}. - * + * * @param field * to remove the final modifier * @param forceAccess @@ -743,7 +743,7 @@ public class FieldUtils { /** * Writes a {@code public} {@link Field}. Superclasses will be considered. - * + * * @param target * the object to reflect, must not be {@code null} * @param fieldName @@ -762,7 +762,7 @@ public class FieldUtils { /** * Writes a {@link Field}. Superclasses will be considered. - * + * * @param target * the object to reflect, must not be {@code null} * @param fieldName @@ -791,7 +791,7 @@ public class FieldUtils { /** * Writes a {@code public} {@link Field}. Only the specified class will be considered. - * + * * @param target * the object to reflect, must not be {@code null} * @param fieldName @@ -810,7 +810,7 @@ public class FieldUtils { /** * Writes a {@code public} {@link Field}. Only the specified class will be considered. - * + * * @param target * the object to reflect, must not be {@code null} * @param fieldName diff --git a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java index 2855410aa..17ed733af 100644 --- a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java +++ b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java @@ -49,10 +49,10 @@ import org.apache.commons.lang3.Validate; * Reflection locates these methods fine and correctly assigns them as {@code public}. * However, an {@link IllegalAccessException} is thrown if the method is invoked.</p> * - * <p>{@link MethodUtils} contains a workaround for this situation. + * <p>{@link MethodUtils} contains a workaround for this situation. * It will attempt to call {@link java.lang.reflect.AccessibleObject#setAccessible(boolean)} on this method. * If this call succeeds, then the method can be invoked as normal. - * This call will only succeed when the application has sufficient security privileges. + * This call will only succeed when the application has sufficient security privileges. * If this call fails then the method may fail.</p> * * @since 2.5 @@ -87,14 +87,14 @@ public class MethodUtils { * @throws NoSuchMethodException if there is no such accessible method * @throws InvocationTargetException wraps an exception thrown by the method invoked * @throws IllegalAccessException if the requested method is not accessible via reflection - * + * * @since 3.4 */ public static Object invokeMethod(final Object object, final String methodName) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { return invokeMethod(object, methodName, ArrayUtils.EMPTY_OBJECT_ARRAY, null); } - + /** * <p>Invokes a named method without parameters.</p> * @@ -123,7 +123,7 @@ public class MethodUtils { * * <p>This method delegates the method search to {@link #getMatchingAccessibleMethod(Class, String, Class[])}.</p> * - * <p>This method supports calls to methods taking primitive parameters + * <p>This method supports calls to methods taking primitive parameters * via passing in wrapping classes. So, for example, a {@code Boolean} object * would match a {@code boolean} primitive.</p> * @@ -147,11 +147,11 @@ public class MethodUtils { final Class<?>[] parameterTypes = ClassUtils.toClass(args); return invokeMethod(object, methodName, args, parameterTypes); } - + /** * <p>Invokes a named method whose parameter type matches the object type.</p> * - * <p>This method supports calls to methods taking primitive parameters + * <p>This method supports calls to methods taking primitive parameters * via passing in wrapping classes. So, for example, a {@code Boolean} object * would match a {@code boolean} primitive.</p> * @@ -182,7 +182,7 @@ public class MethodUtils { /** * <p>Invokes a named method whose parameter type matches the object type.</p> * - * <p>This method supports calls to methods taking primitive parameters + * <p>This method supports calls to methods taking primitive parameters * via passing in wrapping classes. So, for example, a {@code Boolean} object * would match a {@code boolean} primitive.</p> * @@ -235,7 +235,7 @@ public class MethodUtils { * * <p>This method delegates the method search to {@link #getMatchingAccessibleMethod(Class, String, Class[])}.</p> * - * <p>This method supports calls to methods taking primitive parameters + * <p>This method supports calls to methods taking primitive parameters * via passing in wrapping classes. So, for example, a {@code Boolean} object * would match a {@code boolean} primitive.</p> * @@ -249,7 +249,7 @@ public class MethodUtils { * @throws InvocationTargetException wraps an exception thrown by the method invoked * @throws IllegalAccessException if the requested method is not accessible via reflection */ - public static Object invokeMethod(final Object object, final String methodName, + public static Object invokeMethod(final Object object, final String methodName, final Object[] args, final Class<?>[] parameterTypes) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { @@ -378,7 +378,7 @@ public class MethodUtils { * * <p>This method delegates the method search to {@link #getMatchingAccessibleMethod(Class, String, Class[])}.</p> * - * <p>This method supports calls to methods taking primitive parameters + * <p>This method supports calls to methods taking primitive parameters * via passing in wrapping classes. So, for example, a {@code Boolean} class * would match a {@code boolean} primitive.</p> * @@ -410,7 +410,7 @@ public class MethodUtils { * * <p>This method delegates the method search to {@link #getMatchingAccessibleMethod(Class, String, Class[])}.</p> * - * <p>This method supports calls to methods taking primitive parameters + * <p>This method supports calls to methods taking primitive parameters * via passing in wrapping classes. So, for example, a {@code Boolean} class * would match a {@code boolean} primitive.</p> * @@ -650,13 +650,13 @@ public class MethodUtils { /** * <p>Finds an accessible method that matches the given name and has compatible parameters. - * Compatible parameters mean that every method parameter is assignable from + * Compatible parameters mean that every method parameter is assignable from * the given parameters. - * In other words, it finds a method with the given name + * In other words, it finds a method with the given name * that will take the parameters given.</p> * - * <p>This method is used by - * {@link + * <p>This method is used by + * {@link * #invokeMethod(Object object, String methodName, Object[] args, Class[] parameterTypes)}. * </p> * @@ -667,7 +667,7 @@ public class MethodUtils { * * @param cls find method in this class * @param methodName find method with this name - * @param parameterTypes find method with most compatible parameters + * @param parameterTypes find method with most compatible parameters * @return The accessible method */ public static Method getMatchingAccessibleMethod(final Class<?> cls, @@ -714,7 +714,7 @@ public class MethodUtils { return bestMatch; } - + /** * <p>Retrieves a method whether or not it's accessible. If no such method * can be found, return {@code null}.</p> @@ -722,7 +722,7 @@ public class MethodUtils { * @param methodName The method that we wish to call * @param parameterTypes Argument class types * @return The method - * + * * @since 3.5 */ public static Method getMatchingMethod(final Class<?> cls, final String methodName, @@ -755,7 +755,7 @@ public class MethodUtils { } return inexactMatch; } - + /** * <p>Returns the aggregate number of inheritance hops between assignable argument class types. Returns -1 * if the arguments aren't assignable. Fills a specific purpose for getMatchingMethod and is not generalized.</p> diff --git a/src/main/java/org/apache/commons/lang3/reflect/TypeLiteral.java b/src/main/java/org/apache/commons/lang3/reflect/TypeLiteral.java index bead33f42..db801fc5c 100644 --- a/src/main/java/org/apache/commons/lang3/reflect/TypeLiteral.java +++ b/src/main/java/org/apache/commons/lang3/reflect/TypeLiteral.java @@ -106,7 +106,7 @@ public abstract class TypeLiteral<T> implements Typed<T> { return TypeUtils.equals(value, other.value); } - @Override + @Override public int hashCode() { return 37 << 4 | value.hashCode(); } diff --git a/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java b/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java index 8db6ca478..3f568d1d6 100644 --- a/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java +++ b/src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java @@ -56,7 +56,7 @@ public class TypeUtils { */ private WildcardTypeBuilder() { } - + private Type[] upperBounds; private Type[] lowerBounds; @@ -91,7 +91,7 @@ public class TypeUtils { /** * GenericArrayType implementation class. - * @since 3.2 + * @since 3.2 */ private static final class GenericArrayTypeImpl implements GenericArrayType { private final Type componentType; @@ -141,7 +141,7 @@ public class TypeUtils { /** * ParameterizedType implementation class. - * @since 3.2 + * @since 3.2 */ private static final class ParameterizedTypeImpl implements ParameterizedType { private final Class<?> raw; @@ -217,7 +217,7 @@ public class TypeUtils { /** * WildcardType implementation class. - * @since 3.2 + * @since 3.2 */ private static final class WildcardTypeImpl implements WildcardType { private static final Type[] EMPTY_BOUNDS = new Type[0]; @@ -1400,7 +1400,7 @@ public class TypeUtils { /** * Local helper method to unroll variables in a type bounds array. - * + * * @param typeArguments assignments {@link Map} * @param bounds in which to expand variables * @return {@code bounds} with any variables reassigned diff --git a/src/main/java/org/apache/commons/lang3/reflect/Typed.java b/src/main/java/org/apache/commons/lang3/reflect/Typed.java index 4841f5c30..b21b51bfd 100644 --- a/src/main/java/org/apache/commons/lang3/reflect/Typed.java +++ b/src/main/java/org/apache/commons/lang3/reflect/Typed.java @@ -27,7 +27,7 @@ public interface Typed<T> { /** * Get the {@link Type} represented by this entity. - * + * * @return Type */ Type getType(); diff --git a/src/main/java/org/apache/commons/lang3/text/CompositeFormat.java b/src/main/java/org/apache/commons/lang3/text/CompositeFormat.java index bac62ecf3..f36596967 100644 --- a/src/main/java/org/apache/commons/lang3/text/CompositeFormat.java +++ b/src/main/java/org/apache/commons/lang3/text/CompositeFormat.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,7 +34,7 @@ public class CompositeFormat extends Format { /** * Required for serialization support. - * + * * @see java.io.Serializable */ private static final long serialVersionUID = -4329119827877627683L; @@ -47,7 +47,7 @@ public class CompositeFormat extends Format { /** * Create a format that points its parseObject method to one implementation * and its format method to another. - * + * * @param parser implementation * @param formatter implementation */ @@ -58,7 +58,7 @@ public class CompositeFormat extends Format { /** * Uses the formatter Format instance. - * + * * @param obj the object to format * @param toAppendTo the {@link StringBuffer} to append to * @param pos the FieldPosition to use (or ignore). @@ -73,7 +73,7 @@ public class CompositeFormat extends Format { /** * Uses the parser Format instance. - * + * * @param source the String source * @param pos the ParsePosition containing the position to parse from, will * be updated according to parsing success (index) or failure @@ -88,7 +88,7 @@ public class CompositeFormat extends Format { /** * Provides access to the parser Format implementation. - * + * * @return parser Format implementation */ public Format getParser() { @@ -97,7 +97,7 @@ public class CompositeFormat extends Format { /** * Provides access to the parser Format implementation. - * + * * @return formatter Format implementation */ public Format getFormatter() { @@ -106,7 +106,7 @@ public class CompositeFormat extends Format { /** * Utility method to parse and then reformat a String. - * + * * @param input String to reformat * @return A reformatted String * @throws ParseException thrown by parseObject(String) call diff --git a/src/main/java/org/apache/commons/lang3/text/ExtendedMessageFormat.java b/src/main/java/org/apache/commons/lang3/text/ExtendedMessageFormat.java index 75e53a0ff..6c9948b37 100644 --- a/src/main/java/org/apache/commons/lang3/text/ExtendedMessageFormat.java +++ b/src/main/java/org/apache/commons/lang3/text/ExtendedMessageFormat.java @@ -477,7 +477,7 @@ public class ExtendedMessageFormat extends MessageFormat { */ private StringBuilder appendQuotedString(final String pattern, final ParsePosition pos, final StringBuilder appendTo) { - assert pattern.toCharArray()[pos.getIndex()] == QUOTE : + assert pattern.toCharArray()[pos.getIndex()] == QUOTE : "Quoted string must start with quote character"; // handle quote character at the beginning of the string diff --git a/src/main/java/org/apache/commons/lang3/text/FormatFactory.java b/src/main/java/org/apache/commons/lang3/text/FormatFactory.java index b6e35834c..0a206d0ff 100644 --- a/src/main/java/org/apache/commons/lang3/text/FormatFactory.java +++ b/src/main/java/org/apache/commons/lang3/text/FormatFactory.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -21,7 +21,7 @@ import java.util.Locale; /** * Format factory. - * + * * @since 2.4 * @deprecated as of 3.6, use commons-text * <a href="https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/FormatFactory.html"> diff --git a/src/main/java/org/apache/commons/lang3/text/FormattableUtils.java b/src/main/java/org/apache/commons/lang3/text/FormattableUtils.java index 9fdf6ec81..87cd84cef 100644 --- a/src/main/java/org/apache/commons/lang3/text/FormattableUtils.java +++ b/src/main/java/org/apache/commons/lang3/text/FormattableUtils.java @@ -27,11 +27,11 @@ import org.apache.commons.lang3.Validate; /** * <p>Provides utilities for working with the {@code Formattable} interface.</p> - * + * * <p>The {@link Formattable} interface provides basic control over formatting * when using a {@code Formatter}. It is primarily concerned with numeric precision * and padding, and is not designed to allow generalised alternate formats.</p> - * + * * @since Lang 3.0 * @deprecated as of 3.6, use commons-text * <a href="https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/FormattableUtils.html"> @@ -49,7 +49,7 @@ public class FormattableUtils { * <p>{@code FormattableUtils} instances should NOT be constructed in * standard programming. Instead, the methods of the class should be invoked * statically.</p> - * + * * <p>This constructor is public to permit tools that require a JavaBean * instance to operate.</p> */ @@ -61,7 +61,7 @@ public class FormattableUtils { /** * Get the default formatted representation of the specified * {@code Formattable}. - * + * * @param formattable the instance to convert to a string, not null * @return the resulting string, not null */ @@ -73,7 +73,7 @@ public class FormattableUtils { * Handles the common {@code Formattable} operations of truncate-pad-append, * with no ellipsis on precision overflow, and padding width underflow with * spaces. - * + * * @param seq the string to handle, not null * @param formatter the destination formatter, not null * @param flags the flags for formatting, see {@code Formattable} @@ -89,7 +89,7 @@ public class FormattableUtils { /** * Handles the common {@link Formattable} operations of truncate-pad-append, * with no ellipsis on precision overflow. - * + * * @param seq the string to handle, not null * @param formatter the destination formatter, not null * @param flags the flags for formatting, see {@code Formattable} @@ -106,7 +106,7 @@ public class FormattableUtils { /** * Handles the common {@link Formattable} operations of truncate-pad-append, * padding width underflow with spaces. - * + * * @param seq the string to handle, not null * @param formatter the destination formatter, not null * @param flags the flags for formatting, see {@code Formattable} @@ -123,7 +123,7 @@ public class FormattableUtils { /** * Handles the common {@link Formattable} operations of truncate-pad-append. - * + * * @param seq the string to handle, not null * @param formatter the destination formatter, not null * @param flags the flags for formatting, see {@code Formattable} diff --git a/src/main/java/org/apache/commons/lang3/text/StrBuilder.java b/src/main/java/org/apache/commons/lang3/text/StrBuilder.java index cb0bf9d38..4e69cd5d3 100644 --- a/src/main/java/org/apache/commons/lang3/text/StrBuilder.java +++ b/src/main/java/org/apache/commons/lang3/text/StrBuilder.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -67,9 +67,9 @@ import org.apache.commons.lang3.builder.Builder; * The biggest of these changes is that by default, null will not output the text * 'null'. This can be controlled by a property, {@link #setNullText(String)}. * <p> - * Prior to 3.0, this class implemented Cloneable but did not implement the - * clone method so could not be used. From 3.0 onwards it no longer implements - * the interface. + * Prior to 3.0, this class implemented Cloneable but did not implement the + * clone method so could not be used. From 3.0 onwards it no longer implements + * the interface. * * @since 2.2 * @deprecated as of 3.6, use commons-text @@ -86,7 +86,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build /** * Required for serialization support. - * + * * @see java.io.Serializable */ private static final long serialVersionUID = 7628716375283629643L; @@ -355,7 +355,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build //----------------------------------------------------------------------- /** * Copies the builder's character array into a new character array. - * + * * @return a new array that represents the contents of the builder */ public char[] toCharArray() { @@ -369,7 +369,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build /** * Copies part of the builder's character array into a new character array. - * + * * @param startIndex the start index, inclusive, must be valid * @param endIndex the end index, exclusive, must be valid except that * if too large it is treated as end of string @@ -390,7 +390,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build /** * Copies the character array into the specified array. - * + * * @param destination the destination array, null will cause an array to be created * @return the input array, unless that was null or too small */ @@ -512,7 +512,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build if (obj instanceof CharSequence) { return append((CharSequence) obj); } - return append(obj.toString()); + return append(obj.toString()); } /** @@ -540,7 +540,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build if (seq instanceof CharBuffer) { return append((CharBuffer) seq); } - return append(seq.toString()); + return append(seq.toString()); } /** @@ -557,10 +557,10 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build public StrBuilder append(final CharSequence seq, final int startIndex, final int length) { if (seq == null) { return appendNull(); - } + } return append(seq.toString(), startIndex, length); } - + /** * Appends a string to this string builder. * Appending null will call {@link #appendNull()}. @@ -581,7 +581,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build } return this; } - + /** * Appends part of a string to this string builder. @@ -750,7 +750,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build } return this; } - + /** * Appends part of a StringBuilder to this string builder. * Appending null will call {@link #appendNull()}. @@ -1327,7 +1327,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * </pre> * Note that for this simple example, you should use * {@link #appendWithSeparators(Iterable, String)}. - * + * * @param separator the separator to use, null means no separator * @return this, to enable chaining * @since 2.3 @@ -1340,7 +1340,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * Appends one of both separators to the StrBuilder. * If the builder is currently empty it will append the defaultIfEmpty-separator * Otherwise it will append the standard-separator - * + * * Appending a null separator will have no effect. * The separator is appended using {@link #append(String)}. * <p> @@ -1357,7 +1357,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * } * selectClause.append(whereClause) * </pre> - * + * * @param standard the separator if builder is not empty, null means no separator * @param defaultIfEmpty the separator if builder is empty, null means no separator * @return this, to enable chaining @@ -1385,7 +1385,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * </pre> * Note that for this simple example, you should use * {@link #appendWithSeparators(Iterable, String)}. - * + * * @param separator the separator to use * @return this, to enable chaining * @since 2.3 @@ -1432,7 +1432,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * </pre> * Note that for this simple example, you should use * {@link #appendWithSeparators(Iterable, String)}. - * + * * @param separator the separator to use, null means no separator * @param loopIndex the loop index * @return this, to enable chaining @@ -1460,7 +1460,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * </pre> * Note that for this simple example, you should use * {@link #appendWithSeparators(Iterable, String)}. - * + * * @param separator the separator to use * @param loopIndex the loop index * @return this, to enable chaining @@ -1476,7 +1476,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build //----------------------------------------------------------------------- /** * Appends the pad character to the builder the specified number of times. - * + * * @param length the length to append, negative means no append * @param padChar the character to append * @return this, to enable chaining @@ -1497,7 +1497,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * The <code>toString</code> of the object is used. * If the object is larger than the length, the left hand side is lost. * If the object is null, the null text value is used. - * + * * @param obj the object to append, null uses null text * @param width the fixed field width, zero or negative has no effect * @param padChar the pad character to use @@ -1529,7 +1529,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * Appends an object to the builder padding on the left to a fixed width. * The <code>String.valueOf</code> of the <code>int</code> value is used. * If the formatted value is larger than the length, the left hand side is lost. - * + * * @param value the value to append * @param width the fixed field width, zero or negative has no effect * @param padChar the pad character to use @@ -1544,7 +1544,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * The <code>toString</code> of the object is used. * If the object is larger than the length, the right hand side is lost. * If the object is null, null text value is used. - * + * * @param obj the object to append, null uses null text * @param width the fixed field width, zero or negative has no effect * @param padChar the pad character to use @@ -1576,7 +1576,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * Appends an object to the builder padding on the right to a fixed length. * The <code>String.valueOf</code> of the <code>int</code> value is used. * If the object is larger than the length, the right hand side is lost. - * + * * @param value the value to append * @param width the fixed field width, zero or negative has no effect * @param padChar the pad character to use @@ -2134,14 +2134,14 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build //----------------------------------------------------------------------- /** * Reverses the string builder placing each character in the opposite index. - * + * * @return this, to enable chaining */ public StrBuilder reverse() { if (size == 0) { return this; } - + final int half = size / 2; final char[] buf = buffer; for (int leftIdx = 0, rightIdx = size - 1; leftIdx < half; leftIdx++,rightIdx--) { @@ -2186,7 +2186,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * Checks whether this builder starts with the specified string. * <p> * Note that this method handles null input quietly, unlike String. - * + * * @param str the string to search for, null returns false * @return true if the builder starts with the string */ @@ -2213,7 +2213,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * Checks whether this builder ends with the specified string. * <p> * Note that this method handles null input quietly, unlike String. - * + * * @param str the string to search for, null returns false * @return true if the builder ends with the string */ @@ -2258,7 +2258,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build /** * Extracts a portion of this string builder as a string. - * + * * @param start the start index, inclusive, must be valid * @return the new string * @throws IndexOutOfBoundsException if the index is invalid @@ -2273,7 +2273,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * Note: This method treats an endIndex greater than the length of the * builder as equal to the length of the builder, and continues * without error, unlike StringBuffer or String. - * + * * @param startIndex the start index, inclusive, must be valid * @param endIndex the end index, exclusive, must be valid except * that if too large it is treated as end of string @@ -2293,7 +2293,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * the builder. If this many characters are not available, the whole * builder is returned. Thus the returned string may be shorter than the * length requested. - * + * * @param length the number of characters to extract, negative returns empty string * @return the new string */ @@ -2315,7 +2315,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * the builder. If this many characters are not available, the whole * builder is returned. Thus the returned string may be shorter than the * length requested. - * + * * @param length the number of characters to extract, negative returns empty string * @return the new string */ @@ -2340,7 +2340,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * If the length is negative, the empty string is returned. * If insufficient characters are available in the builder, as much as possible is returned. * Thus the returned string may be shorter than the length requested. - * + * * @param index the index to start at, negative means zero * @param length the number of characters to extract, negative returns empty string * @return the new string @@ -2403,7 +2403,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build //----------------------------------------------------------------------- /** * Searches the string builder to find the first reference to the specified char. - * + * * @param ch the character to find * @return the first index of the character, or -1 if not found */ @@ -2413,7 +2413,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build /** * Searches the string builder to find the first reference to the specified char. - * + * * @param ch the character to find * @param startIndex the index to start at, invalid index rounded to edge * @return the first index of the character, or -1 if not found @@ -2436,7 +2436,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * Searches the string builder to find the first reference to the specified string. * <p> * Note that a null input string will return -1, whereas the JDK throws an exception. - * + * * @param str the string to find, null returns -1 * @return the first index of the string, or -1 if not found */ @@ -2449,7 +2449,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * string starting searching from the given index. * <p> * Note that a null input string will return -1, whereas the JDK throws an exception. - * + * * @param str the string to find, null returns -1 * @param startIndex the index to start at, invalid index rounded to edge * @return the first index of the string, or -1 if not found @@ -2527,7 +2527,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build //----------------------------------------------------------------------- /** * Searches the string builder to find the last reference to the specified char. - * + * * @param ch the character to find * @return the last index of the character, or -1 if not found */ @@ -2537,7 +2537,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build /** * Searches the string builder to find the last reference to the specified char. - * + * * @param ch the character to find * @param startIndex the index to start at, invalid index rounded to edge * @return the last index of the character, or -1 if not found @@ -2559,7 +2559,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * Searches the string builder to find the last reference to the specified string. * <p> * Note that a null input string will return -1, whereas the JDK throws an exception. - * + * * @param str the string to find, null returns -1 * @return the last index of the string, or -1 if not found */ @@ -2572,7 +2572,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build * string starting searching from the given index. * <p> * Note that a null input string will return -1, whereas the JDK throws an exception. - * + * * @param str the string to find, null returns -1 * @param startIndex the index to start at, invalid index rounded to edge * @return the last index of the string, or -1 if not found @@ -2597,7 +2597,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build } return i; } - + } else if (strLen == 0) { return startIndex; } @@ -2887,7 +2887,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build //----------------------------------------------------------------------- /** * Validates parameters defining a range of the builder. - * + * * @param startIndex the start index, inclusive, must be valid * @param endIndex the end index, exclusive, must be valid except * that if too large it is treated as end of string @@ -2909,7 +2909,7 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build /** * Validates parameters defining a single index in the builder. - * + * * @param index the index, must be valid * @throws IndexOutOfBoundsException if the index is invalid */ diff --git a/src/main/java/org/apache/commons/lang3/text/StrMatcher.java b/src/main/java/org/apache/commons/lang3/text/StrMatcher.java index 0cfcd6f58..60e0d454d 100644 --- a/src/main/java/org/apache/commons/lang3/text/StrMatcher.java +++ b/src/main/java/org/apache/commons/lang3/text/StrMatcher.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -378,7 +378,7 @@ public abstract class StrMatcher { } return len; } - + @Override public String toString() { return super.toString() + ' ' + Arrays.toString(chars); diff --git a/src/main/java/org/apache/commons/lang3/text/StrSubstitutor.java b/src/main/java/org/apache/commons/lang3/text/StrSubstitutor.java index 68f881128..db5ed0af1 100644 --- a/src/main/java/org/apache/commons/lang3/text/StrSubstitutor.java +++ b/src/main/java/org/apache/commons/lang3/text/StrSubstitutor.java @@ -1209,7 +1209,7 @@ public class StrSubstitutor { /** * Returns the flag controlling whether escapes are preserved during * substitution. - * + * * @return the preserve escape flag * @since 3.5 */ @@ -1225,7 +1225,7 @@ public class StrSubstitutor { * character is removed during substitution (e.g. * <code>$${this-is-escaped}</code> becomes * <code>${this-is-escaped}</code>). The default value is <b>false</b> - * + * * @param preserveEscapes true if escapes are to be preserved * @since 3.5 */ diff --git a/src/main/java/org/apache/commons/lang3/text/StrTokenizer.java b/src/main/java/org/apache/commons/lang3/text/StrTokenizer.java index 8d56b1db0..f9fb6dcb6 100644 --- a/src/main/java/org/apache/commons/lang3/text/StrTokenizer.java +++ b/src/main/java/org/apache/commons/lang3/text/StrTokenizer.java @@ -135,7 +135,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable { /** * Returns a clone of <code>CSV_TOKENIZER_PROTOTYPE</code>. - * + * * @return a clone of <code>CSV_TOKENIZER_PROTOTYPE</code>. */ private static StrTokenizer getCSVClone() { @@ -187,7 +187,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable { /** * Returns a clone of <code>TSV_TOKENIZER_PROTOTYPE</code>. - * + * * @return a clone of <code>TSV_TOKENIZER_PROTOTYPE</code>. */ private static StrTokenizer getTSVClone() { @@ -629,7 +629,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable { * <code>StrTokenizer</code> will always pass a zero offset and a count * equal to the length of the array to this method, however a subclass * may pass other values, or even an entirely different array. - * + * * @param srcChars the character array being tokenized, may be null * @param offset the start position within the character array, must be valid * @param count the number of characters to tokenize, must be valid @@ -642,12 +642,12 @@ public class StrTokenizer implements ListIterator<String>, Cloneable { final StrBuilder buf = new StrBuilder(); final List<String> tokenList = new ArrayList<>(); int pos = offset; - + // loop around the entire buffer while (pos >= 0 && pos < count) { // find next token pos = readNextToken(srcChars, pos, count, buf, tokenList); - + // handle case where end of string is a delimiter if (pos >= count) { addToken(tokenList, StringUtils.EMPTY); @@ -699,20 +699,20 @@ public class StrTokenizer implements ListIterator<String>, Cloneable { } start += removeLen; } - + // handle reaching end if (start >= len) { addToken(tokenList, StringUtils.EMPTY); return -1; } - + // handle empty token final int delimLen = getDelimiterMatcher().isMatch(srcChars, start, start, len); if (delimLen > 0) { addToken(tokenList, StringUtils.EMPTY); return start + delimLen; } - + // handle found token final int quoteLen = getQuoteMatcher().isMatch(srcChars, start, start, len); if (quoteLen > 0) { @@ -735,7 +735,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable { * immediately after the delimiter, or if end of string found, * then the length of string */ - private int readWithQuotes(final char[] srcChars, final int start, final int len, final StrBuilder workArea, + private int readWithQuotes(final char[] srcChars, final int start, final int len, final StrBuilder workArea, final List<String> tokenList, final int quoteStart, final int quoteLen) { // Loop until we've found the end of the quoted // string or the end of the input @@ -743,14 +743,14 @@ public class StrTokenizer implements ListIterator<String>, Cloneable { int pos = start; boolean quoting = quoteLen > 0; int trimStart = 0; - + while (pos < len) { // quoting mode can occur several times throughout a string // we must switch between quoting and non-quoting until we // encounter a non-quoted delimiter, or end of string if (quoting) { // In quoting mode - + // If we've found a quote character, see if it's // followed by a second quote. If so, then we need // to actually put the quote character into the token @@ -763,20 +763,20 @@ public class StrTokenizer implements ListIterator<String>, Cloneable { trimStart = workArea.size(); continue; } - + // end of quoting quoting = false; pos += quoteLen; continue; } - + // copy regular character from inside quotes workArea.append(srcChars[pos++]); trimStart = workArea.size(); - + } else { // Not in quoting mode - + // check for delimiter, and thus end of token final int delimLen = getDelimiterMatcher().isMatch(srcChars, pos, start, len); if (delimLen > 0) { @@ -784,21 +784,21 @@ public class StrTokenizer implements ListIterator<String>, Cloneable { addToken(tokenList, workArea.substring(0, trimStart)); return pos + delimLen; } - + // check for quote, and thus back into quoting mode if (quoteLen > 0 && isQuote(srcChars, pos, len, quoteStart, quoteLen)) { quoting = true; pos += quoteLen; continue; } - + // check for ignored (outside quotes), and ignore final int ignoredLen = getIgnoredMatcher().isMatch(srcChars, pos, start, len); if (ignoredLen > 0) { pos += ignoredLen; continue; } - + // check for trimmed character // don't yet know if its at the end, so copy to workArea // use trimStart to keep track of trim at the end @@ -808,13 +808,13 @@ public class StrTokenizer implements ListIterator<String>, Cloneable { pos += trimmedLen; continue; } - + // copy regular character from outside quotes workArea.append(srcChars[pos++]); trimStart = workArea.size(); } } - + // return condition when end of string found addToken(tokenList, workArea.substring(0, trimStart)); return -1; @@ -1071,7 +1071,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable { * Creates a new instance of this Tokenizer. The new instance is reset so * that it will be at the start of the token list. * If a {@link CloneNotSupportedException} is caught, return <code>null</code>. - * + * * @return a new instance of this Tokenizer which has been reset. */ @Override @@ -1086,7 +1086,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable { /** * Creates a new instance of this Tokenizer. The new instance is reset so that * it will be at the start of the token list. - * + * * @return a new instance of this Tokenizer which has been reset. * @throws CloneNotSupportedException if there is a problem cloning */ diff --git a/src/main/java/org/apache/commons/lang3/text/WordUtils.java b/src/main/java/org/apache/commons/lang3/text/WordUtils.java index 66ce4457e..fef20d0bb 100644 --- a/src/main/java/org/apache/commons/lang3/text/WordUtils.java +++ b/src/main/java/org/apache/commons/lang3/text/WordUtils.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,11 +24,11 @@ import org.apache.commons.lang3.StringUtils; /** * <p>Operations on Strings that contain words.</p> - * + * * <p>This class tries to handle <code>null</code> input gracefully. * An exception will not be thrown for a <code>null</code> input. * Each method documents its behaviour in more detail.</p> - * + * * @since 2.0 * @deprecated as of 3.6, use commons-text * <a href="https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/WordUtils.html"> @@ -53,10 +53,10 @@ public class WordUtils { //-------------------------------------------------------------------------- /** * <p>Wraps a single line of text, identifying words by <code>' '</code>.</p> - * + * * <p>New lines will be separated by the system property line separator. * Very long words, such as URLs will <i>not</i> be wrapped.</p> - * + * * <p>Leading spaces on a new line are stripped. * Trailing spaces are not stripped.</p> * @@ -102,10 +102,10 @@ public class WordUtils { public static String wrap(final String str, final int wrapLength) { return wrap(str, wrapLength, null, false); } - + /** * <p>Wraps a single line of text, identifying words by <code>' '</code>.</p> - * + * * <p>Leading spaces on a new line are stripped. * Trailing spaces are not stripped.</p> * @@ -170,7 +170,7 @@ public class WordUtils { * * @param str the String to be word wrapped, may be null * @param wrapLength the column to wrap the words at, less than 1 is treated as 1 - * @param newLineStr the string to insert for a new line, + * @param newLineStr the string to insert for a new line, * <code>null</code> uses the system property line separator * @param wrapLongWords true if long words (such as URLs) should be wrapped * @return a line with newlines inserted, <code>null</code> if null input @@ -348,8 +348,8 @@ public class WordUtils { //----------------------------------------------------------------------- /** * <p>Capitalizes all the whitespace separated words in a String. - * Only the first character of each word is changed. To convert the - * rest of each word to lowercase at the same time, + * Only the first character of each word is changed. To convert the + * rest of each word to lowercase at the same time, * use {@link #capitalizeFully(String)}.</p> * * <p>Whitespace is defined by {@link Character#isWhitespace(char)}. @@ -362,7 +362,7 @@ public class WordUtils { * WordUtils.capitalize("") = "" * WordUtils.capitalize("i am FINE") = "I Am FINE" * </pre> - * + * * @param str the String to capitalize, may be null * @return capitalized String, <code>null</code> if null String input * @see #uncapitalize(String) @@ -374,8 +374,8 @@ public class WordUtils { /** * <p>Capitalizes all the delimiter separated words in a String. - * Only the first character of each word is changed. To convert the - * rest of each word to lowercase at the same time, + * Only the first character of each word is changed. To convert the + * rest of each word to lowercase at the same time, * use {@link #capitalizeFully(String, char[])}.</p> * * <p>The delimiters represent a set of characters understood to separate words. @@ -393,7 +393,7 @@ public class WordUtils { * WordUtils.capitalize("i am fine", null) = "I Am Fine" * WordUtils.capitalize("i aM.fine", {'.'}) = "I aM.Fine" * </pre> - * + * * @param str the String to capitalize, may be null * @param delimiters set of characters to determine capitalization, null means whitespace * @return capitalized String, <code>null</code> if null String input @@ -422,8 +422,8 @@ public class WordUtils { //----------------------------------------------------------------------- /** - * <p>Converts all the whitespace separated words in a String into capitalized words, - * that is each word is made up of a titlecase character and then a series of + * <p>Converts all the whitespace separated words in a String into capitalized words, + * that is each word is made up of a titlecase character and then a series of * lowercase characters. </p> * * <p>Whitespace is defined by {@link Character#isWhitespace(char)}. @@ -436,7 +436,7 @@ public class WordUtils { * WordUtils.capitalizeFully("") = "" * WordUtils.capitalizeFully("i am FINE") = "I Am Fine" * </pre> - * + * * @param str the String to capitalize, may be null * @return capitalized String, <code>null</code> if null String input */ @@ -445,8 +445,8 @@ public class WordUtils { } /** - * <p>Converts all the delimiter separated words in a String into capitalized words, - * that is each word is made up of a titlecase character and then a series of + * <p>Converts all the delimiter separated words in a String into capitalized words, + * that is each word is made up of a titlecase character and then a series of * lowercase characters. </p> * * <p>The delimiters represent a set of characters understood to separate words. @@ -464,7 +464,7 @@ public class WordUtils { * WordUtils.capitalizeFully(*, new char[0]) = * * WordUtils.capitalizeFully("i aM.fine", {'.'}) = "I am.Fine" * </pre> - * + * * @param str the String to capitalize, may be null * @param delimiters set of characters to determine capitalization, null means whitespace * @return capitalized String, <code>null</code> if null String input @@ -492,7 +492,7 @@ public class WordUtils { * WordUtils.uncapitalize("") = "" * WordUtils.uncapitalize("I Am FINE") = "i am fINE" * </pre> - * + * * @param str the String to uncapitalize, may be null * @return uncapitalized String, <code>null</code> if null String input * @see #capitalize(String) @@ -519,7 +519,7 @@ public class WordUtils { * WordUtils.uncapitalize(*, new char[0]) = * * WordUtils.uncapitalize("I AM.FINE", {'.'}) = "i AM.fINE" * </pre> - * + * * @param str the String to uncapitalize, may be null * @param delimiters set of characters to determine uncapitalization, null means whitespace * @return uncapitalized String, <code>null</code> if null String input @@ -548,23 +548,23 @@ public class WordUtils { //----------------------------------------------------------------------- /** * <p>Swaps the case of a String using a word based algorithm.</p> - * + * * <ul> * <li>Upper case character converts to Lower case</li> * <li>Title case character converts to Lower case</li> * <li>Lower case character after Whitespace or at start converts to Title case</li> * <li>Other Lower case character converts to Upper case</li> * </ul> - * + * * <p>Whitespace is defined by {@link Character#isWhitespace(char)}. * A <code>null</code> input String returns <code>null</code>.</p> - * + * * <pre> * StringUtils.swapCase(null) = null * StringUtils.swapCase("") = "" * StringUtils.swapCase("The dog has a BONE") = "tHE DOG HAS A bone" * </pre> - * + * * @param str the String to swap case, may be null * @return the changed String, <code>null</code> if null String input */ @@ -601,7 +601,7 @@ public class WordUtils { //----------------------------------------------------------------------- /** * <p>Extracts the initial characters from each word in the String.</p> - * + * * <p>All first characters after whitespace are returned as a new string. * Their case is not changed.</p> * @@ -626,7 +626,7 @@ public class WordUtils { /** * <p>Extracts the initial characters from each word in the String.</p> - * + * * <p>All first characters after the defined delimiters are returned as a new string. * Their case is not changed.</p> * @@ -643,7 +643,7 @@ public class WordUtils { * WordUtils.initials("Ben J.Lee", [' ','.']) = "BJL" * WordUtils.initials(*, new char[0]) = "" * </pre> - * + * * @param str the String to get initials from, may be null * @param delimiters set of characters to determine words, null means whitespace * @return String of initial characters, <code>null</code> if null String input diff --git a/src/main/java/org/apache/commons/lang3/text/translate/AggregateTranslator.java b/src/main/java/org/apache/commons/lang3/text/translate/AggregateTranslator.java index 6f4519c1c..86b22bbcc 100644 --- a/src/main/java/org/apache/commons/lang3/text/translate/AggregateTranslator.java +++ b/src/main/java/org/apache/commons/lang3/text/translate/AggregateTranslator.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,9 +22,9 @@ import java.io.Writer; import org.apache.commons.lang3.ArrayUtils; /** - * Executes a sequence of translators one after the other. Execution ends whenever + * Executes a sequence of translators one after the other. Execution ends whenever * the first translator consumes codepoints from the input. - * + * * @since 3.0 * @deprecated as of 3.6, use commons-text * <a href="https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/AggregateTranslator.html"> @@ -36,7 +36,7 @@ public class AggregateTranslator extends CharSequenceTranslator { private final CharSequenceTranslator[] translators; /** - * Specify the translators to be used at creation time. + * Specify the translators to be used at creation time. * * @param translators CharSequenceTranslator array to aggregate */ @@ -45,8 +45,8 @@ public class AggregateTranslator extends CharSequenceTranslator { } /** - * The first translator to consume codepoints from the input is the 'winner'. - * Execution stops with the number of consumed codepoints being returned. + * The first translator to consume codepoints from the input is the 'winner'. + * Execution stops with the number of consumed codepoints being returned. * {@inheritDoc} */ @Override diff --git a/src/main/java/org/apache/commons/lang3/text/translate/CharSequenceTranslator.java b/src/main/java/org/apache/commons/lang3/text/translate/CharSequenceTranslator.java index 17fb8ac05..e79ebe60c 100644 --- a/src/main/java/org/apache/commons/lang3/text/translate/CharSequenceTranslator.java +++ b/src/main/java/org/apache/commons/lang3/text/translate/CharSequenceTranslator.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,10 +22,10 @@ import java.io.Writer; import java.util.Locale; /** - * An API for translating text. - * Its core use is to escape and unescape text. Because escaping and unescaping + * An API for translating text. + * Its core use is to escape and unescape text. Because escaping and unescaping * is completely contextual, the API does not present two separate signatures. - * + * * @since 3.0 * @deprecated as of 3.6, use commons-text * <a href="https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/translate/CharSequenceTranslator.html"> @@ -37,10 +37,10 @@ public abstract class CharSequenceTranslator { static final char[] HEX_DIGITS = new char[] {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; /** - * Translate a set of codepoints, represented by an int index into a CharSequence, - * into another set of codepoints. The number of codepoints consumed must be returned, - * and the only IOExceptions thrown must be from interacting with the Writer so that - * the top level API may reliably ignore StringWriter IOExceptions. + * Translate a set of codepoints, represented by an int index into a CharSequence, + * into another set of codepoints. The number of codepoints consumed must be returned, + * and the only IOExceptions thrown must be from interacting with the Writer so that + * the top level API may reliably ignore StringWriter IOExceptions. * * @param input CharSequence that is being translated * @param index int representing the current point of translation @@ -51,7 +51,7 @@ public abstract class CharSequenceTranslator { public abstract int translate(CharSequence input, int index, Writer out) throws IOException; /** - * Helper for non-Writer usage. + * Helper for non-Writer usage. * @param input CharSequence to be translated * @return String output of translation */ @@ -70,8 +70,8 @@ public abstract class CharSequenceTranslator { } /** - * Translate an input onto a Writer. This is intentionally final as its algorithm is - * tightly coupled with the abstract method of this class. + * Translate an input onto a Writer. This is intentionally final as its algorithm is + * tightly coupled with the abstract method of this class. * * @param input CharSequence that is being translated * @param out Writer to translate the text to @@ -112,7 +112,7 @@ public abstract class CharSequenceTranslator { } /** - * Helper method to create a merger of this translator with another set of + * Helper method to create a merger of this translator with another set of * translators. Useful in customizing the standard functionality. * * @param translators CharSequenceTranslator array of translators to merge with this one diff --git a/src/main/java/org/apache/commons/lang3/text/translate/CodePointTranslator.java b/src/main/java/org/apache/commons/lang3/text/translate/CodePointTranslator.java index 92ed50520..003dd77c0 100644 --- a/src/main/java/org/apache/commons/lang3/text/translate/CodePointTranslator.java +++ b/src/main/java/org/apache/commons/lang3/text/translate/CodePointTranslator.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,9 +20,9 @@ import java.io.IOException; import java.io.Writer; /** - * Helper subclass to CharSequenceTranslator to allow for translations that + * Helper subclass to CharSequenceTranslator to allow for translations that * will replace up to one character at a time. - * + * * @since 3.0 * @deprecated as of 3.6, use commons-text * <a href="https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/translate/CodePointTranslator.html"> @@ -32,19 +32,19 @@ import java.io.Writer; public abstract class CodePointTranslator extends CharSequenceTranslator { /** - * Implementation of translate that maps onto the abstract translate(int, Writer) method. + * Implementation of translate that maps onto the abstract translate(int, Writer) method. * {@inheritDoc} */ @Override public final int translate(final CharSequence input, final int index, final Writer out) throws IOException { final int codepoint = Character.codePointAt(input, index); final boolean consumed = translate(codepoint, out); - return consumed ? 1 : 0; + return consumed ? 1 : 0; } /** - * Translate the specified codepoint into another. - * + * Translate the specified codepoint into another. + * * @param codepoint int character input to translate * @param out Writer to optionally push the translated output to * @return boolean as to whether translation occurred or not diff --git a/src/main/java/org/apache/commons/lang3/text/translate/JavaUnicodeEscaper.java b/src/main/java/org/apache/commons/lang3/text/translate/JavaUnicodeEscaper.java index d02a0574d..150cfafe5 100644 --- a/src/main/java/org/apache/commons/lang3/text/translate/JavaUnicodeEscaper.java +++ b/src/main/java/org/apache/commons/lang3/text/translate/JavaUnicodeEscaper.java @@ -18,7 +18,7 @@ package org.apache.commons.lang3.text.translate; /** * Translates codepoints to their Unicode escaped value suitable for Java source. - * + * * @since 3.2 * @deprecated as of 3.6, use commons-text * <a href="https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/translate/UnicodeEscaper.html"> @@ -31,7 +31,7 @@ public class JavaUnicodeEscaper extends UnicodeEscaper { * <p> * Constructs a <code>JavaUnicodeEscaper</code> above the specified value (exclusive). * </p> - * + * * @param codepoint * above which to escape * @return the newly created {@code UnicodeEscaper} instance @@ -44,7 +44,7 @@ public class JavaUnicodeEscaper extends UnicodeEscaper { * <p> * Constructs a <code>JavaUnicodeEscaper</code> below the specified value (exclusive). * </p> - * + * * @param codepoint * below which to escape * @return the newly created {@code UnicodeEscaper} instance @@ -57,7 +57,7 @@ public class JavaUnicodeEscaper extends UnicodeEscaper { * <p> * Constructs a <code>JavaUnicodeEscaper</code> between the specified values (inclusive). * </p> - * + * * @param codepointLow * above which to escape * @param codepointHigh @@ -72,7 +72,7 @@ public class JavaUnicodeEscaper extends UnicodeEscaper { * <p> * Constructs a <code>JavaUnicodeEscaper</code> outside of the specified values (exclusive). * </p> - * + * * @param codepointLow * below which to escape * @param codepointHigh @@ -89,7 +89,7 @@ public class JavaUnicodeEscaper extends UnicodeEscaper { * other constructors/builders. The <code>below</code> and <code>above</code> boundaries are inclusive when * <code>between</code> is <code>true</code> and exclusive when it is <code>false</code>. * </p> - * + * * @param below * int value representing the lowest codepoint boundary * @param above @@ -103,7 +103,7 @@ public class JavaUnicodeEscaper extends UnicodeEscaper { /** * Converts the given codepoint to a hex string of the form {@code "\\uXXXX\\uXXXX"} - * + * * @param codepoint * a Unicode code point * @return the hex string for the given codepoint diff --git a/src/main/java/org/apache/commons/lang3/text/translate/LookupTranslator.java b/src/main/java/org/apache/commons/lang3/text/translate/LookupTranslator.java index e00983e88..5e80154d2 100644 --- a/src/main/java/org/apache/commons/lang3/text/translate/LookupTranslator.java +++ b/src/main/java/org/apache/commons/lang3/text/translate/LookupTranslator.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java b/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java index bfb5f85a2..d01a42041 100644 --- a/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java +++ b/src/main/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaper.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,11 +22,11 @@ import java.util.Arrays; import java.util.EnumSet; /** - * Translate XML numeric entities of the form &#[xX]?\d+;? to + * Translate XML numeric entities of the form &#[xX]?\d+;? to * the specific codepoint. * * Note that the semi-colon is optional. - * + * * @since 3.0 * @deprecated as of 3.6, use commons-text * <a href="https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/translate/NumericEntityUnescaper.html"> @@ -43,8 +43,8 @@ public class NumericEntityUnescaper extends CharSequenceTranslator { /** * Create a UnicodeUnescaper. * - * The constructor takes a list of options, only one type of which is currently - * available (whether to allow, error or ignore the semi-colon on the end of a + * The constructor takes a list of options, only one type of which is currently + * available (whether to allow, error or ignore the semi-colon on the end of a * numeric entity to being missing). * * For example, to support numeric entities without a ';': @@ -52,7 +52,7 @@ public class NumericEntityUnescaper extends CharSequenceTranslator { * and to throw an IllegalArgumentException when they're missing: * new NumericEntityUnescaper(NumericEntityUnescaper.OPTION.errorIfNoSemiColon) * - * Note that the default behaviour is to ignore them. + * Note that the default behaviour is to ignore them. * * @param options to apply to this unescaper */ @@ -70,7 +70,7 @@ public class NumericEntityUnescaper extends CharSequenceTranslator { * @param option to check state of * @return whether the option is set */ - public boolean isSet(final OPTION option) { + public boolean isSet(final OPTION option) { return options == null ? false : options.contains(option); } diff --git a/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java b/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java index 5a27d5086..e8ac35782 100644 --- a/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java +++ b/src/main/java/org/apache/commons/lang3/text/translate/OctalUnescaper.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,9 +24,9 @@ import java.io.Writer; * * For example, "\45" should go back to being the specific value (a %). * - * Note that this currently only supports the viable range of octal for Java; namely + * Note that this currently only supports the viable range of octal for Java; namely * 1 to 377. This is because parsing Java is the main use case. - * + * * @since 3.0 * @deprecated as of 3.6, use commons-text * <a href="https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/translate/OctalUnescaper.html"> diff --git a/src/main/java/org/apache/commons/lang3/text/translate/UnicodeEscaper.java b/src/main/java/org/apache/commons/lang3/text/translate/UnicodeEscaper.java index b7ee38f0a..5771d1558 100644 --- a/src/main/java/org/apache/commons/lang3/text/translate/UnicodeEscaper.java +++ b/src/main/java/org/apache/commons/lang3/text/translate/UnicodeEscaper.java @@ -129,7 +129,7 @@ public class UnicodeEscaper extends CodePointTranslator { /** * Converts the given codepoint to a hex string of the form {@code "\\uXXXX"} - * + * * @param codepoint * a Unicode code point * @return the hex string for the given codepoint diff --git a/src/main/java/org/apache/commons/lang3/text/translate/UnicodeUnescaper.java b/src/main/java/org/apache/commons/lang3/text/translate/UnicodeUnescaper.java index 0f2fd2595..52d8df4be 100644 --- a/src/main/java/org/apache/commons/lang3/text/translate/UnicodeUnescaper.java +++ b/src/main/java/org/apache/commons/lang3/text/translate/UnicodeUnescaper.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -20,10 +20,10 @@ import java.io.IOException; import java.io.Writer; /** - * Translates escaped Unicode values of the form \\u+\d\d\d\d back to - * Unicode. It supports multiple 'u' characters and will work with or + * Translates escaped Unicode values of the form \\u+\d\d\d\d back to + * Unicode. It supports multiple 'u' characters and will work with or * without the +. - * + * * @since 3.0 * @deprecated as of 3.6, use commons-text * <a href="https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/translate/UnicodeUnescaper.html"> diff --git a/src/main/java/org/apache/commons/lang3/text/translate/UnicodeUnpairedSurrogateRemover.java b/src/main/java/org/apache/commons/lang3/text/translate/UnicodeUnpairedSurrogateRemover.java index 39249c3dc..0115422aa 100644 --- a/src/main/java/org/apache/commons/lang3/text/translate/UnicodeUnpairedSurrogateRemover.java +++ b/src/main/java/org/apache/commons/lang3/text/translate/UnicodeUnpairedSurrogateRemover.java @@ -21,7 +21,7 @@ import java.io.Writer; /** * Helper subclass to CharSequenceTranslator to remove unpaired surrogates. - * + * * @deprecated as of 3.6, use commons-text * <a href="https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/translate/UnicodeUnpairedSurrogateRemover.html"> * UnicodeUnpairedSurrogateRemover</a> instead @@ -29,7 +29,7 @@ import java.io.Writer; @Deprecated public class UnicodeUnpairedSurrogateRemover extends CodePointTranslator { /** - * Implementation of translate that throws out unpaired surrogates. + * Implementation of translate that throws out unpaired surrogates. * {@inheritDoc} */ @Override diff --git a/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java b/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java index 3f78753eb..09d2c521c 100644 --- a/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java +++ b/src/main/java/org/apache/commons/lang3/time/DateFormatUtils.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -27,7 +27,7 @@ import java.util.TimeZone; * <p>Formatting is performed using the thread-safe * {@link org.apache.commons.lang3.time.FastDateFormat} class.</p> * - * <p>Note that the JDK has a bug wherein calling Calendar.get(int) will + * <p>Note that the JDK has a bug wherein calling Calendar.get(int) will * override any previously called Calendar.clear() calls. See LANG-755.</p> * * @since 2.0 @@ -206,7 +206,7 @@ public class DateFormatUtils { /** * <p>Formats a date/time into a specific pattern using the UTC time zone.</p> - * + * * @param millis the date to format expressed in milliseconds * @param pattern the pattern to use to format the date, not null * @return the formatted date @@ -217,7 +217,7 @@ public class DateFormatUtils { /** * <p>Formats a date/time into a specific pattern using the UTC time zone.</p> - * + * * @param date the date to format, not null * @param pattern the pattern to use to format the date, not null * @return the formatted date @@ -225,10 +225,10 @@ public class DateFormatUtils { public static String formatUTC(final Date date, final String pattern) { return format(date, pattern, UTC_TIME_ZONE, null); } - + /** * <p>Formats a date/time into a specific pattern using the UTC time zone.</p> - * + * * @param millis the date to format expressed in milliseconds * @param pattern the pattern to use to format the date, not null * @param locale the locale to use, may be <code>null</code> @@ -240,7 +240,7 @@ public class DateFormatUtils { /** * <p>Formats a date/time into a specific pattern using the UTC time zone.</p> - * + * * @param date the date to format, not null * @param pattern the pattern to use to format the date, not null * @param locale the locale to use, may be <code>null</code> @@ -249,10 +249,10 @@ public class DateFormatUtils { public static String formatUTC(final Date date, final String pattern, final Locale locale) { return format(date, pattern, UTC_TIME_ZONE, locale); } - + /** * <p>Formats a date/time into a specific pattern.</p> - * + * * @param millis the date to format expressed in milliseconds * @param pattern the pattern to use to format the date, not null * @return the formatted date @@ -263,7 +263,7 @@ public class DateFormatUtils { /** * <p>Formats a date/time into a specific pattern.</p> - * + * * @param date the date to format, not null * @param pattern the pattern to use to format the date, not null * @return the formatted date @@ -274,7 +274,7 @@ public class DateFormatUtils { /** * <p>Formats a calendar into a specific pattern.</p> - * + * * @param calendar the calendar to format, not null * @param pattern the pattern to use to format the calendar, not null * @return the formatted calendar @@ -284,10 +284,10 @@ public class DateFormatUtils { public static String format(final Calendar calendar, final String pattern) { return format(calendar, pattern, null, null); } - + /** * <p>Formats a date/time into a specific pattern in a time zone.</p> - * + * * @param millis the time expressed in milliseconds * @param pattern the pattern to use to format the date, not null * @param timeZone the time zone to use, may be <code>null</code> @@ -299,7 +299,7 @@ public class DateFormatUtils { /** * <p>Formats a date/time into a specific pattern in a time zone.</p> - * + * * @param date the date to format, not null * @param pattern the pattern to use to format the date, not null * @param timeZone the time zone to use, may be <code>null</code> @@ -311,7 +311,7 @@ public class DateFormatUtils { /** * <p>Formats a calendar into a specific pattern in a time zone.</p> - * + * * @param calendar the calendar to format, not null * @param pattern the pattern to use to format the calendar, not null * @param timeZone the time zone to use, may be <code>null</code> @@ -325,7 +325,7 @@ public class DateFormatUtils { /** * <p>Formats a date/time into a specific pattern in a locale.</p> - * + * * @param millis the date to format expressed in milliseconds * @param pattern the pattern to use to format the date, not null * @param locale the locale to use, may be <code>null</code> @@ -337,7 +337,7 @@ public class DateFormatUtils { /** * <p>Formats a date/time into a specific pattern in a locale.</p> - * + * * @param date the date to format, not null * @param pattern the pattern to use to format the date, not null * @param locale the locale to use, may be <code>null</code> @@ -349,7 +349,7 @@ public class DateFormatUtils { /** * <p>Formats a calendar into a specific pattern in a locale.</p> - * + * * @param calendar the calendar to format, not null * @param pattern the pattern to use to format the calendar, not null * @param locale the locale to use, may be <code>null</code> @@ -363,7 +363,7 @@ public class DateFormatUtils { /** * <p>Formats a date/time into a specific pattern in a time zone and locale.</p> - * + * * @param millis the date to format expressed in milliseconds * @param pattern the pattern to use to format the date, not null * @param timeZone the time zone to use, may be <code>null</code> @@ -376,7 +376,7 @@ public class DateFormatUtils { /** * <p>Formats a date/time into a specific pattern in a time zone and locale.</p> - * + * * @param date the date to format, not null * @param pattern the pattern to use to format the date, not null, not null * @param timeZone the time zone to use, may be <code>null</code> @@ -390,7 +390,7 @@ public class DateFormatUtils { /** * <p>Formats a calendar into a specific pattern in a time zone and locale.</p> - * + * * @param calendar the calendar to format, not null * @param pattern the pattern to use to format the calendar, not null * @param timeZone the time zone to use, may be <code>null</code> diff --git a/src/main/java/org/apache/commons/lang3/time/DateParser.java b/src/main/java/org/apache/commons/lang3/time/DateParser.java index 370260386..2836e9ee3 100644 --- a/src/main/java/org/apache/commons/lang3/time/DateParser.java +++ b/src/main/java/org/apache/commons/lang3/time/DateParser.java @@ -30,30 +30,30 @@ import java.util.TimeZone; * <p> * Warning: Since binary compatible methods may be added to this interface in any * release, developers are not expected to implement this interface. - * + * * @since 3.2 */ public interface DateParser { /** - * Equivalent to DateFormat.parse(String). - * - * See {@link java.text.DateFormat#parse(String)} for more information. - * @param source A <code>String</code> whose beginning should be parsed. + * Equivalent to DateFormat.parse(String). + * + * See {@link java.text.DateFormat#parse(String)} for more information. + * @param source A <code>String</code> whose beginning should be parsed. * @return A <code>Date</code> parsed from the string * @throws ParseException if the beginning of the specified string cannot be parsed. */ Date parse(String source) throws ParseException; /** - * Equivalent to DateFormat.parse(String, ParsePosition). - * - * See {@link java.text.DateFormat#parse(String, ParsePosition)} for more information. - * + * Equivalent to DateFormat.parse(String, ParsePosition). + * + * See {@link java.text.DateFormat#parse(String, ParsePosition)} for more information. + * * @param source A <code>String</code>, part of which should be parsed. - * @param pos A <code>ParsePosition</code> object with index and error index information - * as described above. - * @return A <code>Date</code> parsed from the string. In case of error, returns null. + * @param pos A <code>ParsePosition</code> object with index and error index information + * as described above. + * @return A <code>Date</code> parsed from the string. In case of error, returns null. * @throws NullPointerException if text or pos is null. */ Date parse(String source, ParsePosition pos); @@ -70,7 +70,7 @@ public interface DateParser { * @return true, if source has been parsed (pos parsePosition is updated); otherwise false (and pos errorIndex is updated) * @throws IllegalArgumentException when Calendar has been set to be not lenient, and a parsed field is * out of range. - * + * * @since 3.5 */ boolean parse(String source, ParsePosition pos, Calendar calendar); @@ -79,7 +79,7 @@ public interface DateParser { //----------------------------------------------------------------------- /** * <p>Gets the pattern used by this parser.</p> - * + * * @return the pattern, {@link java.text.SimpleDateFormat} compatible */ String getPattern(); @@ -88,40 +88,40 @@ public interface DateParser { * <p> * Gets the time zone used by this parser. * </p> - * + * * <p> * The default {@link TimeZone} used to create a {@link Date} when the {@link TimeZone} is not specified by * the format pattern. * </p> - * + * * @return the time zone */ TimeZone getTimeZone(); /** * <p>Gets the locale used by this parser.</p> - * + * * @return the locale */ Locale getLocale(); /** * Parses text from a string to produce a Date. - * + * * @param source A <code>String</code> whose beginning should be parsed. * @return a <code>java.util.Date</code> object * @throws ParseException if the beginning of the specified string cannot be parsed. - * @see java.text.DateFormat#parseObject(String) + * @see java.text.DateFormat#parseObject(String) */ Object parseObject(String source) throws ParseException; /** * Parses a date/time string according to the given parse position. - * + * * @param source A <code>String</code> whose beginning should be parsed. * @param pos the parse position * @return a <code>java.util.Date</code> object - * @see java.text.DateFormat#parseObject(String, ParsePosition) + * @see java.text.DateFormat#parseObject(String, ParsePosition) */ Object parseObject(String source, ParsePosition pos); } diff --git a/src/main/java/org/apache/commons/lang3/time/DatePrinter.java b/src/main/java/org/apache/commons/lang3/time/DatePrinter.java index 342405af5..eebcbeef0 100644 --- a/src/main/java/org/apache/commons/lang3/time/DatePrinter.java +++ b/src/main/java/org/apache/commons/lang3/time/DatePrinter.java @@ -23,13 +23,13 @@ import java.util.Locale; import java.util.TimeZone; /** - * DatePrinter is the "missing" interface for the format methods of + * DatePrinter is the "missing" interface for the format methods of * {@link java.text.DateFormat}. You can obtain an object implementing this * interface by using one of the FastDateFormat factory methods. * <p> * Warning: Since binary compatible methods may be added to this interface in any * release, developers are not expected to implement this interface. - * + * * @since 3.2 */ public interface DatePrinter { diff --git a/src/main/java/org/apache/commons/lang3/time/DateUtils.java b/src/main/java/org/apache/commons/lang3/time/DateUtils.java index 7f3bc9747..7e5e4f694 100644 --- a/src/main/java/org/apache/commons/lang3/time/DateUtils.java +++ b/src/main/java/org/apache/commons/lang3/time/DateUtils.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,7 +31,7 @@ import org.apache.commons.lang3.Validate; /** * <p>A suite of utilities surrounding the use of the * {@link java.util.Calendar} and {@link java.util.Date} object.</p> - * + * * <p>DateUtils contains a lot of common methods considering manipulations * of Dates or Calendars. Some methods require some extra explanation. * The truncate, ceiling and round methods could be considered the Math.floor(), @@ -43,8 +43,8 @@ import org.apache.commons.lang3.Validate; * kind of date-field you want your result, for instance milliseconds or days. * </p> * <p> - * Several methods are provided for adding to {@code Date} objects, of the form - * {@code addXXX(Date date, int amount)}. It is important to note these methods + * Several methods are provided for adding to {@code Date} objects, of the form + * {@code addXXX(Date date, int amount)}. It is important to note these methods * use a {@code Calendar} internally (with default timezone and locale) and may * be affected by changes to daylight saving time (DST). * </p> @@ -85,7 +85,7 @@ public class DateUtils { {Calendar.SECOND}, {Calendar.MINUTE}, {Calendar.HOUR_OF_DAY, Calendar.HOUR}, - {Calendar.DATE, Calendar.DAY_OF_MONTH, Calendar.AM_PM + {Calendar.DATE, Calendar.DAY_OF_MONTH, Calendar.AM_PM /* Calendar.DAY_OF_YEAR, Calendar.DAY_OF_WEEK, Calendar.DAY_OF_WEEK_IN_MONTH */ }, {Calendar.MONTH, DateUtils.SEMI_MONTH}, @@ -125,14 +125,14 @@ public class DateUtils { * Truncation. */ TRUNCATE, - + /** - * Rounding. + * Rounding. */ ROUND, - + /** - * Ceiling. + * Ceiling. */ CEILING } @@ -156,7 +156,7 @@ public class DateUtils { * <p>28 Mar 2002 13:45 and 28 Mar 2002 06:01 would return true. * 28 Mar 2002 13:45 and 12 Mar 2002 13:45 would return false. * </p> - * + * * @param date1 the first date, not altered, not null * @param date2 the second date, not altered, not null * @return true if they represent the same day @@ -180,7 +180,7 @@ public class DateUtils { * <p>28 Mar 2002 13:45 and 28 Mar 2002 06:01 would return true. * 28 Mar 2002 13:45 and 12 Mar 2002 13:45 would return false. * </p> - * + * * @param cal1 the first calendar, not altered, not null * @param cal2 the second calendar, not altered, not null * @return true if they represent the same day @@ -201,7 +201,7 @@ public class DateUtils { * <p>Checks if two date objects represent the same instant in time.</p> * * <p>This method compares the long millisecond time of the two objects.</p> - * + * * @param date1 the first date, not altered, not null * @param date2 the second date, not altered, not null * @return true if they represent the same millisecond instant @@ -219,7 +219,7 @@ public class DateUtils { * <p>Checks if two calendar objects represent the same instant in time.</p> * * <p>This method compares the long millisecond time of the two objects.</p> - * + * * @param cal1 the first calendar, not altered, not null * @param cal2 the second calendar, not altered, not null * @return true if they represent the same millisecond instant @@ -239,7 +239,7 @@ public class DateUtils { * * <p>This method compares the values of the fields of the two objects. * In addition, both calendars must be the same of the same type.</p> - * + * * @param cal1 the first calendar, not altered, not null * @param cal2 the second calendar, not altered, not null * @return true if they represent the same millisecond instant @@ -263,12 +263,12 @@ public class DateUtils { //----------------------------------------------------------------------- /** * <p>Parses a string representing a date by trying a variety of different parsers.</p> - * + * * <p>The parse will try each parse pattern in turn. * A parse is only deemed successful if it parses the whole of the input string. * If no parse patterns match, a ParseException is thrown.</p> * The parser will be lenient toward the parsed date. - * + * * @param str the date to parse, not null * @param parsePatterns the date format patterns to use, see SimpleDateFormat, not null * @return the parsed date @@ -278,17 +278,17 @@ public class DateUtils { public static Date parseDate(final String str, final String... parsePatterns) throws ParseException { return parseDate(str, null, parsePatterns); } - + //----------------------------------------------------------------------- /** * <p>Parses a string representing a date by trying a variety of different parsers, * using the default date format symbols for the given locale.</p> - * + * * <p>The parse will try each parse pattern in turn. * A parse is only deemed successful if it parses the whole of the input string. * If no parse patterns match, a ParseException is thrown.</p> * The parser will be lenient toward the parsed date. - * + * * @param str the date to parse, not null * @param locale the locale whose date format symbols should be used. If <code>null</code>, * the system locale is used (as per {@link #parseDate(String, String...)}). @@ -300,17 +300,17 @@ public class DateUtils { */ public static Date parseDate(final String str, final Locale locale, final String... parsePatterns) throws ParseException { return parseDateWithLeniency(str, locale, parsePatterns, true); - } + } //----------------------------------------------------------------------- /** * <p>Parses a string representing a date by trying a variety of different parsers.</p> - * + * * <p>The parse will try each parse pattern in turn. * A parse is only deemed successful if it parses the whole of the input string. * If no parse patterns match, a ParseException is thrown.</p> - * The parser parses strictly - it does not allow for dates such as "February 942, 1996". - * + * The parser parses strictly - it does not allow for dates such as "February 942, 1996". + * * @param str the date to parse, not null * @param parsePatterns the date format patterns to use, see SimpleDateFormat, not null * @return the parsed date @@ -325,12 +325,12 @@ public class DateUtils { /** * <p>Parses a string representing a date by trying a variety of different parsers, * using the default date format symbols for the given locale..</p> - * + * * <p>The parse will try each parse pattern in turn. * A parse is only deemed successful if it parses the whole of the input string. * If no parse patterns match, a ParseException is thrown.</p> - * The parser parses strictly - it does not allow for dates such as "February 942, 1996". - * + * The parser parses strictly - it does not allow for dates such as "February 942, 1996". + * * @param str the date to parse, not null * @param locale the locale whose date format symbols should be used. If <code>null</code>, * the system locale is used (as per {@link #parseDateStrictly(String, String...)}). @@ -342,15 +342,15 @@ public class DateUtils { */ public static Date parseDateStrictly(final String str, final Locale locale, final String... parsePatterns) throws ParseException { return parseDateWithLeniency(str, locale, parsePatterns, false); - } + } /** * <p>Parses a string representing a date by trying a variety of different parsers.</p> - * + * * <p>The parse will try each parse pattern in turn. * A parse is only deemed successful if it parses the whole of the input string. * If no parse patterns match, a ParseException is thrown.</p> - * + * * @param str the date to parse, not null * @param locale the locale to use when interpretting the pattern, can be null in which * case the default system locale is used @@ -519,7 +519,7 @@ public class DateUtils { c.add(calendarField, amount); return c.getTime(); } - + //----------------------------------------------------------------------- /** * Sets the years field to a date returning a new object. @@ -567,7 +567,7 @@ public class DateUtils { //----------------------------------------------------------------------- /** - * Sets the hours field to a date returning a new object. Hours range + * Sets the hours field to a date returning a new object. Hours range * from 0-23. * The original {@code Date} is unchanged. * @@ -595,7 +595,7 @@ public class DateUtils { public static Date setMinutes(final Date date, final int amount) { return set(date, Calendar.MINUTE, amount); } - + //----------------------------------------------------------------------- /** * Sets the seconds field to a date returning a new object. @@ -624,11 +624,11 @@ public class DateUtils { */ public static Date setMilliseconds(final Date date, final int amount) { return set(date, Calendar.MILLISECOND, amount); - } - + } + //----------------------------------------------------------------------- /** - * Sets the specified field to a date returning a new object. + * Sets the specified field to a date returning a new object. * This does not use a lenient calendar. * The original {@code Date} is unchanged. * @@ -647,12 +647,12 @@ public class DateUtils { c.setTime(date); c.set(calendarField, amount); return c.getTime(); - } + } //----------------------------------------------------------------------- /** - * Converts a {@code Date} into a {@code Calendar}. - * + * Converts a {@code Date} into a {@code Calendar}. + * * @param date the date to convert to a Calendar * @return the created Calendar * @throws NullPointerException if null is passed in @@ -663,7 +663,7 @@ public class DateUtils { c.setTime(date); return c; } - + //----------------------------------------------------------------------- /** * Converts a {@code Date} of a given {@code TimeZone} into a {@code Calendar} @@ -677,7 +677,7 @@ public class DateUtils { c.setTime(date); return c; } - + //----------------------------------------------------------------------- /** * <p>Rounds a date, leaving the field specified as the most @@ -687,10 +687,10 @@ public class DateUtils { * 13:45:01.231, if this was passed with HOUR, it would return * 28 Mar 2002 14:00:00.000. If this was passed with MONTH, it * would return 1 April 2002 0:00:00.000.</p> - * + * * <p>For a date in a timezone that handles the change to daylight * saving time, rounding to Calendar.HOUR_OF_DAY will behave as follows. - * Suppose daylight saving time begins at 02:00 on March 30. Rounding a + * Suppose daylight saving time begins at 02:00 on March 30. Rounding a * date that crosses this time would produce the following values: * </p> * <ul> @@ -699,7 +699,7 @@ public class DateUtils { * <li>March 30, 2003 02:10 rounds to March 30, 2003 03:00</li> * <li>March 30, 2003 02:40 rounds to March 30, 2003 04:00</li> * </ul> - * + * * @param date the date to work with, not null * @param field the field from {@code Calendar} or {@code SEMI_MONTH} * @return the different rounded date, not null @@ -721,10 +721,10 @@ public class DateUtils { * 13:45:01.231, if this was passed with HOUR, it would return * 28 Mar 2002 14:00:00.000. If this was passed with MONTH, it * would return 1 April 2002 0:00:00.000.</p> - * + * * <p>For a date in a timezone that handles the change to daylight * saving time, rounding to Calendar.HOUR_OF_DAY will behave as follows. - * Suppose daylight saving time begins at 02:00 on March 30. Rounding a + * Suppose daylight saving time begins at 02:00 on March 30. Rounding a * date that crosses this time would produce the following values: * </p> * <ul> @@ -733,7 +733,7 @@ public class DateUtils { * <li>March 30, 2003 02:10 rounds to March 30, 2003 03:00</li> * <li>March 30, 2003 02:40 rounds to March 30, 2003 04:00</li> * </ul> - * + * * @param date the date to work with, not null * @param field the field from {@code Calendar} or <code>SEMI_MONTH</code> * @return the different rounded date, not null @@ -757,10 +757,10 @@ public class DateUtils { * 13:45:01.231, if this was passed with HOUR, it would return * 28 Mar 2002 14:00:00.000. If this was passed with MONTH, it * would return 1 April 2002 0:00:00.000.</p> - * + * * <p>For a date in a timezone that handles the change to daylight * saving time, rounding to Calendar.HOUR_OF_DAY will behave as follows. - * Suppose daylight saving time begins at 02:00 on March 30. Rounding a + * Suppose daylight saving time begins at 02:00 on March 30. Rounding a * date that crosses this time would produce the following values: * </p> * <ul> @@ -769,7 +769,7 @@ public class DateUtils { * <li>March 30, 2003 02:10 rounds to March 30, 2003 03:00</li> * <li>March 30, 2003 02:40 rounds to March 30, 2003 04:00</li> * </ul> - * + * * @param date the date to work with, either {@code Date} or {@code Calendar}, not null * @param field the field from {@code Calendar} or <code>SEMI_MONTH</code> * @return the different rounded date, not null @@ -799,7 +799,7 @@ public class DateUtils { * 13:45:01.231, if you passed with HOUR, it would return 28 Mar * 2002 13:00:00.000. If this was passed with MONTH, it would * return 1 Mar 2002 0:00:00.000.</p> - * + * * @param date the date to work with, not null * @param field the field from {@code Calendar} or <code>SEMI_MONTH</code> * @return the different truncated date, not null @@ -822,7 +822,7 @@ public class DateUtils { * 13:45:01.231, if you passed with HOUR, it would return 28 Mar * 2002 13:00:00.000. If this was passed with MONTH, it would * return 1 Mar 2002 0:00:00.000.</p> - * + * * @param date the date to work with, not null * @param field the field from {@code Calendar} or <code>SEMI_MONTH</code> * @return the different truncated date, not null @@ -846,7 +846,7 @@ public class DateUtils { * 13:45:01.231, if you passed with HOUR, it would return 28 Mar * 2002 13:00:00.000. If this was passed with MONTH, it would * return 1 Mar 2002 0:00:00.000.</p> - * + * * @param date the date to work with, either {@code Date} or {@code Calendar}, not null * @param field the field from {@code Calendar} or <code>SEMI_MONTH</code> * @return the different truncated date, not null @@ -866,7 +866,7 @@ public class DateUtils { throw new ClassCastException("Could not truncate " + date); } } - + //----------------------------------------------------------------------- /** * <p>Gets a date ceiling, leaving the field specified as the most @@ -876,7 +876,7 @@ public class DateUtils { * 13:45:01.231, if you passed with HOUR, it would return 28 Mar * 2002 14:00:00.000. If this was passed with MONTH, it would * return 1 Apr 2002 0:00:00.000.</p> - * + * * @param date the date to work with, not null * @param field the field from {@code Calendar} or <code>SEMI_MONTH</code> * @return the different ceil date, not null @@ -900,7 +900,7 @@ public class DateUtils { * 13:45:01.231, if you passed with HOUR, it would return 28 Mar * 2002 14:00:00.000. If this was passed with MONTH, it would * return 1 Apr 2002 0:00:00.000.</p> - * + * * @param date the date to work with, not null * @param field the field from {@code Calendar} or <code>SEMI_MONTH</code> * @return the different ceil date, not null @@ -925,7 +925,7 @@ public class DateUtils { * 13:45:01.231, if you passed with HOUR, it would return 28 Mar * 2002 14:00:00.000. If this was passed with MONTH, it would * return 1 Apr 2002 0:00:00.000.</p> - * + * * @param date the date to work with, either {@code Date} or {@code Calendar}, not null * @param field the field from {@code Calendar} or <code>SEMI_MONTH</code> * @return the different ceil date, not null @@ -950,7 +950,7 @@ public class DateUtils { //----------------------------------------------------------------------- /** * <p>Internal calculation method.</p> - * + * * @param val the calendar, not null * @param field the field constant * @param modType type to truncate, round or ceiling @@ -960,7 +960,7 @@ public class DateUtils { if (val.get(Calendar.YEAR) > 280000000) { throw new ArithmeticException("Calendar value too large for accurate calculations"); } - + if (field == Calendar.MILLISECOND) { return; } @@ -1111,7 +1111,7 @@ public class DateUtils { * * @param focus the date to work with, not null * @param rangeStyle the style constant to use. Must be one of - * {@link DateUtils#RANGE_MONTH_SUNDAY}, + * {@link DateUtils#RANGE_MONTH_SUNDAY}, * {@link DateUtils#RANGE_MONTH_MONDAY}, * {@link DateUtils#RANGE_WEEK_SUNDAY}, * {@link DateUtils#RANGE_WEEK_MONDAY}, @@ -1142,7 +1142,7 @@ public class DateUtils { * * @param focus the date to work with, not null * @param rangeStyle the style constant to use. Must be one of - * {@link DateUtils#RANGE_MONTH_SUNDAY}, + * {@link DateUtils#RANGE_MONTH_SUNDAY}, * {@link DateUtils#RANGE_MONTH_MONDAY}, * {@link DateUtils#RANGE_WEEK_SUNDAY}, * {@link DateUtils#RANGE_WEEK_MONDAY}, @@ -1254,23 +1254,23 @@ public class DateUtils { throw new ClassCastException("Could not iterate based on " + focus); } } - + /** - * <p>Returns the number of milliseconds within the + * <p>Returns the number of milliseconds within the * fragment. All datefields greater than the fragment will be ignored.</p> - * + * * <p>Asking the milliseconds of any date will only return the number of milliseconds - * of the current second (resulting in a number between 0 and 999). This - * method will retrieve the number of milliseconds for any fragment. - * For example, if you want to calculate the number of milliseconds past today, + * of the current second (resulting in a number between 0 and 999). This + * method will retrieve the number of milliseconds for any fragment. + * For example, if you want to calculate the number of milliseconds past today, * your fragment is Calendar.DATE or Calendar.DAY_OF_YEAR. The result will * be all milliseconds of the past hour(s), minutes(s) and second(s).</p> - * - * <p>Valid fragments are: Calendar.YEAR, Calendar.MONTH, both - * Calendar.DAY_OF_YEAR and Calendar.DATE, Calendar.HOUR_OF_DAY, + * + * <p>Valid fragments are: Calendar.YEAR, Calendar.MONTH, both + * Calendar.DAY_OF_YEAR and Calendar.DATE, Calendar.HOUR_OF_DAY, * Calendar.MINUTE, Calendar.SECOND and Calendar.MILLISECOND - * A fragment less than or equal to a SECOND field will return 0.</p> - * + * A fragment less than or equal to a SECOND field will return 0.</p> + * * <ul> * <li>January 1, 2008 7:15:10.538 with Calendar.SECOND as fragment will return 538</li> * <li>January 6, 2008 7:15:10.538 with Calendar.SECOND as fragment will return 538</li> @@ -1278,34 +1278,34 @@ public class DateUtils { * <li>January 16, 2008 7:15:10.538 with Calendar.MILLISECOND as fragment will return 0 * (a millisecond cannot be split in milliseconds)</li> * </ul> - * + * * @param date the date to work with, not null - * @param fragment the {@code Calendar} field part of date to calculate + * @param fragment the {@code Calendar} field part of date to calculate * @return number of milliseconds within the fragment of date * @throws IllegalArgumentException if the date is <code>null</code> or * fragment is not supported * @since 2.4 */ public static long getFragmentInMilliseconds(final Date date, final int fragment) { - return getFragment(date, fragment, TimeUnit.MILLISECONDS); + return getFragment(date, fragment, TimeUnit.MILLISECONDS); } - + /** - * <p>Returns the number of seconds within the - * fragment. All datefields greater than the fragment will be ignored.</p> - * + * <p>Returns the number of seconds within the + * fragment. All datefields greater than the fragment will be ignored.</p> + * * <p>Asking the seconds of any date will only return the number of seconds - * of the current minute (resulting in a number between 0 and 59). This - * method will retrieve the number of seconds for any fragment. - * For example, if you want to calculate the number of seconds past today, + * of the current minute (resulting in a number between 0 and 59). This + * method will retrieve the number of seconds for any fragment. + * For example, if you want to calculate the number of seconds past today, * your fragment is Calendar.DATE or Calendar.DAY_OF_YEAR. The result will - * be all seconds of the past hour(s) and minutes(s).</p> - * - * <p>Valid fragments are: Calendar.YEAR, Calendar.MONTH, both - * Calendar.DAY_OF_YEAR and Calendar.DATE, Calendar.HOUR_OF_DAY, + * be all seconds of the past hour(s) and minutes(s).</p> + * + * <p>Valid fragments are: Calendar.YEAR, Calendar.MONTH, both + * Calendar.DAY_OF_YEAR and Calendar.DATE, Calendar.HOUR_OF_DAY, * Calendar.MINUTE, Calendar.SECOND and Calendar.MILLISECOND - * A fragment less than or equal to a SECOND field will return 0.</p> - * + * A fragment less than or equal to a SECOND field will return 0.</p> + * * <ul> * <li>January 1, 2008 7:15:10.538 with Calendar.MINUTE as fragment will return 10 * (equivalent to deprecated date.getSeconds())</li> @@ -1316,9 +1316,9 @@ public class DateUtils { * <li>January 16, 2008 7:15:10.538 with Calendar.MILLISECOND as fragment will return 0 * (a millisecond cannot be split in seconds)</li> * </ul> - * + * * @param date the date to work with, not null - * @param fragment the {@code Calendar} field part of date to calculate + * @param fragment the {@code Calendar} field part of date to calculate * @return number of seconds within the fragment of date * @throws IllegalArgumentException if the date is <code>null</code> or * fragment is not supported @@ -1327,23 +1327,23 @@ public class DateUtils { public static long getFragmentInSeconds(final Date date, final int fragment) { return getFragment(date, fragment, TimeUnit.SECONDS); } - + /** - * <p>Returns the number of minutes within the - * fragment. All datefields greater than the fragment will be ignored.</p> - * + * <p>Returns the number of minutes within the + * fragment. All datefields greater than the fragment will be ignored.</p> + * * <p>Asking the minutes of any date will only return the number of minutes - * of the current hour (resulting in a number between 0 and 59). This - * method will retrieve the number of minutes for any fragment. - * For example, if you want to calculate the number of minutes past this month, - * your fragment is Calendar.MONTH. The result will be all minutes of the - * past day(s) and hour(s).</p> - * - * <p>Valid fragments are: Calendar.YEAR, Calendar.MONTH, both - * Calendar.DAY_OF_YEAR and Calendar.DATE, Calendar.HOUR_OF_DAY, + * of the current hour (resulting in a number between 0 and 59). This + * method will retrieve the number of minutes for any fragment. + * For example, if you want to calculate the number of minutes past this month, + * your fragment is Calendar.MONTH. The result will be all minutes of the + * past day(s) and hour(s).</p> + * + * <p>Valid fragments are: Calendar.YEAR, Calendar.MONTH, both + * Calendar.DAY_OF_YEAR and Calendar.DATE, Calendar.HOUR_OF_DAY, * Calendar.MINUTE, Calendar.SECOND and Calendar.MILLISECOND - * A fragment less than or equal to a MINUTE field will return 0.</p> - * + * A fragment less than or equal to a MINUTE field will return 0.</p> + * * <ul> * <li>January 1, 2008 7:15:10.538 with Calendar.HOUR_OF_DAY as fragment will return 15 * (equivalent to deprecated date.getMinutes())</li> @@ -1354,34 +1354,34 @@ public class DateUtils { * <li>January 16, 2008 7:15:10.538 with Calendar.MILLISECOND as fragment will return 0 * (a millisecond cannot be split in minutes)</li> * </ul> - * + * * @param date the date to work with, not null - * @param fragment the {@code Calendar} field part of date to calculate + * @param fragment the {@code Calendar} field part of date to calculate * @return number of minutes within the fragment of date - * @throws IllegalArgumentException if the date is <code>null</code> or + * @throws IllegalArgumentException if the date is <code>null</code> or * fragment is not supported * @since 2.4 */ public static long getFragmentInMinutes(final Date date, final int fragment) { return getFragment(date, fragment, TimeUnit.MINUTES); } - + /** - * <p>Returns the number of hours within the - * fragment. All datefields greater than the fragment will be ignored.</p> - * + * <p>Returns the number of hours within the + * fragment. All datefields greater than the fragment will be ignored.</p> + * * <p>Asking the hours of any date will only return the number of hours - * of the current day (resulting in a number between 0 and 23). This - * method will retrieve the number of hours for any fragment. - * For example, if you want to calculate the number of hours past this month, - * your fragment is Calendar.MONTH. The result will be all hours of the - * past day(s).</p> - * - * <p>Valid fragments are: Calendar.YEAR, Calendar.MONTH, both - * Calendar.DAY_OF_YEAR and Calendar.DATE, Calendar.HOUR_OF_DAY, + * of the current day (resulting in a number between 0 and 23). This + * method will retrieve the number of hours for any fragment. + * For example, if you want to calculate the number of hours past this month, + * your fragment is Calendar.MONTH. The result will be all hours of the + * past day(s).</p> + * + * <p>Valid fragments are: Calendar.YEAR, Calendar.MONTH, both + * Calendar.DAY_OF_YEAR and Calendar.DATE, Calendar.HOUR_OF_DAY, * Calendar.MINUTE, Calendar.SECOND and Calendar.MILLISECOND - * A fragment less than or equal to a HOUR field will return 0.</p> - * + * A fragment less than or equal to a HOUR field will return 0.</p> + * * <ul> * <li>January 1, 2008 7:15:10.538 with Calendar.DAY_OF_YEAR as fragment will return 7 * (equivalent to deprecated date.getHours())</li> @@ -1392,34 +1392,34 @@ public class DateUtils { * <li>January 16, 2008 7:15:10.538 with Calendar.MILLISECOND as fragment will return 0 * (a millisecond cannot be split in hours)</li> * </ul> - * + * * @param date the date to work with, not null - * @param fragment the {@code Calendar} field part of date to calculate + * @param fragment the {@code Calendar} field part of date to calculate * @return number of hours within the fragment of date - * @throws IllegalArgumentException if the date is <code>null</code> or + * @throws IllegalArgumentException if the date is <code>null</code> or * fragment is not supported * @since 2.4 */ public static long getFragmentInHours(final Date date, final int fragment) { return getFragment(date, fragment, TimeUnit.HOURS); } - + /** - * <p>Returns the number of days within the - * fragment. All datefields greater than the fragment will be ignored.</p> - * + * <p>Returns the number of days within the + * fragment. All datefields greater than the fragment will be ignored.</p> + * * <p>Asking the days of any date will only return the number of days - * of the current month (resulting in a number between 1 and 31). This - * method will retrieve the number of days for any fragment. - * For example, if you want to calculate the number of days past this year, - * your fragment is Calendar.YEAR. The result will be all days of the - * past month(s).</p> - * - * <p>Valid fragments are: Calendar.YEAR, Calendar.MONTH, both - * Calendar.DAY_OF_YEAR and Calendar.DATE, Calendar.HOUR_OF_DAY, + * of the current month (resulting in a number between 1 and 31). This + * method will retrieve the number of days for any fragment. + * For example, if you want to calculate the number of days past this year, + * your fragment is Calendar.YEAR. The result will be all days of the + * past month(s).</p> + * + * <p>Valid fragments are: Calendar.YEAR, Calendar.MONTH, both + * Calendar.DAY_OF_YEAR and Calendar.DATE, Calendar.HOUR_OF_DAY, * Calendar.MINUTE, Calendar.SECOND and Calendar.MILLISECOND - * A fragment less than or equal to a DAY field will return 0.</p> - * + * A fragment less than or equal to a DAY field will return 0.</p> + * * <ul> * <li>January 28, 2008 with Calendar.MONTH as fragment will return 28 * (equivalent to deprecated date.getDay())</li> @@ -1430,11 +1430,11 @@ public class DateUtils { * <li>January 28, 2008 with Calendar.MILLISECOND as fragment will return 0 * (a millisecond cannot be split in days)</li> * </ul> - * + * * @param date the date to work with, not null - * @param fragment the {@code Calendar} field part of date to calculate + * @param fragment the {@code Calendar} field part of date to calculate * @return number of days within the fragment of date - * @throws IllegalArgumentException if the date is <code>null</code> or + * @throws IllegalArgumentException if the date is <code>null</code> or * fragment is not supported * @since 2.4 */ @@ -1443,21 +1443,21 @@ public class DateUtils { } /** - * <p>Returns the number of milliseconds within the - * fragment. All datefields greater than the fragment will be ignored.</p> - * + * <p>Returns the number of milliseconds within the + * fragment. All datefields greater than the fragment will be ignored.</p> + * * <p>Asking the milliseconds of any date will only return the number of milliseconds - * of the current second (resulting in a number between 0 and 999). This - * method will retrieve the number of milliseconds for any fragment. - * For example, if you want to calculate the number of seconds past today, + * of the current second (resulting in a number between 0 and 999). This + * method will retrieve the number of milliseconds for any fragment. + * For example, if you want to calculate the number of seconds past today, * your fragment is Calendar.DATE or Calendar.DAY_OF_YEAR. The result will - * be all seconds of the past hour(s), minutes(s) and second(s).</p> - * - * <p>Valid fragments are: Calendar.YEAR, Calendar.MONTH, both - * Calendar.DAY_OF_YEAR and Calendar.DATE, Calendar.HOUR_OF_DAY, + * be all seconds of the past hour(s), minutes(s) and second(s).</p> + * + * <p>Valid fragments are: Calendar.YEAR, Calendar.MONTH, both + * Calendar.DAY_OF_YEAR and Calendar.DATE, Calendar.HOUR_OF_DAY, * Calendar.MINUTE, Calendar.SECOND and Calendar.MILLISECOND - * A fragment less than or equal to a MILLISECOND field will return 0.</p> - * + * A fragment less than or equal to a MILLISECOND field will return 0.</p> + * * <ul> * <li>January 1, 2008 7:15:10.538 with Calendar.SECOND as fragment will return 538 * (equivalent to calendar.get(Calendar.MILLISECOND))</li> @@ -1468,11 +1468,11 @@ public class DateUtils { * <li>January 16, 2008 7:15:10.538 with Calendar.MILLISECOND as fragment will return 0 * (a millisecond cannot be split in milliseconds)</li> * </ul> - * + * * @param calendar the calendar to work with, not null - * @param fragment the {@code Calendar} field part of calendar to calculate + * @param fragment the {@code Calendar} field part of calendar to calculate * @return number of milliseconds within the fragment of date - * @throws IllegalArgumentException if the date is <code>null</code> or + * @throws IllegalArgumentException if the date is <code>null</code> or * fragment is not supported * @since 2.4 */ @@ -1480,21 +1480,21 @@ public class DateUtils { return getFragment(calendar, fragment, TimeUnit.MILLISECONDS); } /** - * <p>Returns the number of seconds within the - * fragment. All datefields greater than the fragment will be ignored.</p> - * + * <p>Returns the number of seconds within the + * fragment. All datefields greater than the fragment will be ignored.</p> + * * <p>Asking the seconds of any date will only return the number of seconds - * of the current minute (resulting in a number between 0 and 59). This - * method will retrieve the number of seconds for any fragment. - * For example, if you want to calculate the number of seconds past today, + * of the current minute (resulting in a number between 0 and 59). This + * method will retrieve the number of seconds for any fragment. + * For example, if you want to calculate the number of seconds past today, * your fragment is Calendar.DATE or Calendar.DAY_OF_YEAR. The result will - * be all seconds of the past hour(s) and minutes(s).</p> - * - * <p>Valid fragments are: Calendar.YEAR, Calendar.MONTH, both - * Calendar.DAY_OF_YEAR and Calendar.DATE, Calendar.HOUR_OF_DAY, + * be all seconds of the past hour(s) and minutes(s).</p> + * + * <p>Valid fragments are: Calendar.YEAR, Calendar.MONTH, both + * Calendar.DAY_OF_YEAR and Calendar.DATE, Calendar.HOUR_OF_DAY, * Calendar.MINUTE, Calendar.SECOND and Calendar.MILLISECOND - * A fragment less than or equal to a SECOND field will return 0.</p> - * + * A fragment less than or equal to a SECOND field will return 0.</p> + * * <ul> * <li>January 1, 2008 7:15:10.538 with Calendar.MINUTE as fragment will return 10 * (equivalent to calendar.get(Calendar.SECOND))</li> @@ -1505,34 +1505,34 @@ public class DateUtils { * <li>January 16, 2008 7:15:10.538 with Calendar.MILLISECOND as fragment will return 0 * (a millisecond cannot be split in seconds)</li> * </ul> - * + * * @param calendar the calendar to work with, not null - * @param fragment the {@code Calendar} field part of calendar to calculate + * @param fragment the {@code Calendar} field part of calendar to calculate * @return number of seconds within the fragment of date - * @throws IllegalArgumentException if the date is <code>null</code> or + * @throws IllegalArgumentException if the date is <code>null</code> or * fragment is not supported * @since 2.4 */ public static long getFragmentInSeconds(final Calendar calendar, final int fragment) { return getFragment(calendar, fragment, TimeUnit.SECONDS); } - + /** - * <p>Returns the number of minutes within the - * fragment. All datefields greater than the fragment will be ignored.</p> - * + * <p>Returns the number of minutes within the + * fragment. All datefields greater than the fragment will be ignored.</p> + * * <p>Asking the minutes of any date will only return the number of minutes - * of the current hour (resulting in a number between 0 and 59). This - * method will retrieve the number of minutes for any fragment. - * For example, if you want to calculate the number of minutes past this month, - * your fragment is Calendar.MONTH. The result will be all minutes of the - * past day(s) and hour(s).</p> - * - * <p>Valid fragments are: Calendar.YEAR, Calendar.MONTH, both - * Calendar.DAY_OF_YEAR and Calendar.DATE, Calendar.HOUR_OF_DAY, + * of the current hour (resulting in a number between 0 and 59). This + * method will retrieve the number of minutes for any fragment. + * For example, if you want to calculate the number of minutes past this month, + * your fragment is Calendar.MONTH. The result will be all minutes of the + * past day(s) and hour(s).</p> + * + * <p>Valid fragments are: Calendar.YEAR, Calendar.MONTH, both + * Calendar.DAY_OF_YEAR and Calendar.DATE, Calendar.HOUR_OF_DAY, * Calendar.MINUTE, Calendar.SECOND and Calendar.MILLISECOND - * A fragment less than or equal to a MINUTE field will return 0.</p> - * + * A fragment less than or equal to a MINUTE field will return 0.</p> + * * <ul> * <li>January 1, 2008 7:15:10.538 with Calendar.HOUR_OF_DAY as fragment will return 15 * (equivalent to calendar.get(Calendar.MINUTES))</li> @@ -1543,34 +1543,34 @@ public class DateUtils { * <li>January 16, 2008 7:15:10.538 with Calendar.MILLISECOND as fragment will return 0 * (a millisecond cannot be split in minutes)</li> * </ul> - * + * * @param calendar the calendar to work with, not null - * @param fragment the {@code Calendar} field part of calendar to calculate + * @param fragment the {@code Calendar} field part of calendar to calculate * @return number of minutes within the fragment of date - * @throws IllegalArgumentException if the date is <code>null</code> or + * @throws IllegalArgumentException if the date is <code>null</code> or * fragment is not supported * @since 2.4 */ public static long getFragmentInMinutes(final Calendar calendar, final int fragment) { return getFragment(calendar, fragment, TimeUnit.MINUTES); } - + /** - * <p>Returns the number of hours within the - * fragment. All datefields greater than the fragment will be ignored.</p> - * + * <p>Returns the number of hours within the + * fragment. All datefields greater than the fragment will be ignored.</p> + * * <p>Asking the hours of any date will only return the number of hours - * of the current day (resulting in a number between 0 and 23). This - * method will retrieve the number of hours for any fragment. - * For example, if you want to calculate the number of hours past this month, - * your fragment is Calendar.MONTH. The result will be all hours of the - * past day(s).</p> - * - * <p>Valid fragments are: Calendar.YEAR, Calendar.MONTH, both - * Calendar.DAY_OF_YEAR and Calendar.DATE, Calendar.HOUR_OF_DAY, + * of the current day (resulting in a number between 0 and 23). This + * method will retrieve the number of hours for any fragment. + * For example, if you want to calculate the number of hours past this month, + * your fragment is Calendar.MONTH. The result will be all hours of the + * past day(s).</p> + * + * <p>Valid fragments are: Calendar.YEAR, Calendar.MONTH, both + * Calendar.DAY_OF_YEAR and Calendar.DATE, Calendar.HOUR_OF_DAY, * Calendar.MINUTE, Calendar.SECOND and Calendar.MILLISECOND - * A fragment less than or equal to a HOUR field will return 0.</p> - * + * A fragment less than or equal to a HOUR field will return 0.</p> + * * <ul> * <li>January 1, 2008 7:15:10.538 with Calendar.DAY_OF_YEAR as fragment will return 7 * (equivalent to calendar.get(Calendar.HOUR_OF_DAY))</li> @@ -1581,34 +1581,34 @@ public class DateUtils { * <li>January 16, 2008 7:15:10.538 with Calendar.MILLISECOND as fragment will return 0 * (a millisecond cannot be split in hours)</li> * </ul> - * + * * @param calendar the calendar to work with, not null - * @param fragment the {@code Calendar} field part of calendar to calculate + * @param fragment the {@code Calendar} field part of calendar to calculate * @return number of hours within the fragment of date - * @throws IllegalArgumentException if the date is <code>null</code> or + * @throws IllegalArgumentException if the date is <code>null</code> or * fragment is not supported * @since 2.4 */ public static long getFragmentInHours(final Calendar calendar, final int fragment) { return getFragment(calendar, fragment, TimeUnit.HOURS); } - + /** - * <p>Returns the number of days within the - * fragment. All datefields greater than the fragment will be ignored.</p> - * + * <p>Returns the number of days within the + * fragment. All datefields greater than the fragment will be ignored.</p> + * * <p>Asking the days of any date will only return the number of days - * of the current month (resulting in a number between 1 and 31). This - * method will retrieve the number of days for any fragment. - * For example, if you want to calculate the number of days past this year, - * your fragment is Calendar.YEAR. The result will be all days of the - * past month(s).</p> - * - * <p>Valid fragments are: Calendar.YEAR, Calendar.MONTH, both - * Calendar.DAY_OF_YEAR and Calendar.DATE, Calendar.HOUR_OF_DAY, + * of the current month (resulting in a number between 1 and 31). This + * method will retrieve the number of days for any fragment. + * For example, if you want to calculate the number of days past this year, + * your fragment is Calendar.YEAR. The result will be all days of the + * past month(s).</p> + * + * <p>Valid fragments are: Calendar.YEAR, Calendar.MONTH, both + * Calendar.DAY_OF_YEAR and Calendar.DATE, Calendar.HOUR_OF_DAY, * Calendar.MINUTE, Calendar.SECOND and Calendar.MILLISECOND - * A fragment less than or equal to a DAY field will return 0.</p> - * + * A fragment less than or equal to a DAY field will return 0.</p> + * * <ul> * <li>January 28, 2008 with Calendar.MONTH as fragment will return 28 * (equivalent to calendar.get(Calendar.DAY_OF_MONTH))</li> @@ -1621,26 +1621,26 @@ public class DateUtils { * <li>January 28, 2008 with Calendar.MILLISECOND as fragment will return 0 * (a millisecond cannot be split in days)</li> * </ul> - * + * * @param calendar the calendar to work with, not null - * @param fragment the {@code Calendar} field part of calendar to calculate + * @param fragment the {@code Calendar} field part of calendar to calculate * @return number of days within the fragment of date - * @throws IllegalArgumentException if the date is <code>null</code> or + * @throws IllegalArgumentException if the date is <code>null</code> or * fragment is not supported * @since 2.4 */ public static long getFragmentInDays(final Calendar calendar, final int fragment) { return getFragment(calendar, fragment, TimeUnit.DAYS); } - + /** * Gets a Date fragment for any unit. - * + * * @param date the date to work with, not null - * @param fragment the Calendar field part of date to calculate + * @param fragment the Calendar field part of date to calculate * @param unit the time unit * @return number of units within the fragment of the date - * @throws IllegalArgumentException if the date is <code>null</code> or + * @throws IllegalArgumentException if the date is <code>null</code> or * fragment is not supported * @since 2.4 */ @@ -1653,24 +1653,24 @@ public class DateUtils { /** * Gets a Calendar fragment for any unit. - * + * * @param calendar the calendar to work with, not null - * @param fragment the Calendar field part of calendar to calculate + * @param fragment the Calendar field part of calendar to calculate * @param unit the time unit * @return number of units within the fragment of the calendar - * @throws IllegalArgumentException if the date is <code>null</code> or + * @throws IllegalArgumentException if the date is <code>null</code> or * fragment is not supported * @since 2.4 */ private static long getFragment(final Calendar calendar, final int fragment, final TimeUnit unit) { if(calendar == null) { - throw new IllegalArgumentException("The date must not be null"); + throw new IllegalArgumentException("The date must not be null"); } long result = 0; - + final int offset = (unit == TimeUnit.DAYS) ? 0 : 1; - + // Fragments bigger than a day require a breakdown to days switch (fragment) { case Calendar.YEAR: @@ -1687,7 +1687,7 @@ public class DateUtils { // Number of days already calculated for these cases case Calendar.YEAR: case Calendar.MONTH: - + // The rest of the valid cases case Calendar.DAY_OF_YEAR: case Calendar.DATE: @@ -1707,11 +1707,11 @@ public class DateUtils { } return result; } - + /** - * Determines if two calendars are equal up to no more than the specified + * Determines if two calendars are equal up to no more than the specified * most significant field. - * + * * @param cal1 the first calendar, not <code>null</code> * @param cal2 the second calendar, not <code>null</code> * @param field the field from {@code Calendar} @@ -1726,9 +1726,9 @@ public class DateUtils { } /** - * Determines if two dates are equal up to no more than the specified + * Determines if two dates are equal up to no more than the specified * most significant field. - * + * * @param date1 the first date, not <code>null</code> * @param date2 the second date, not <code>null</code> * @param field the field from {@code Calendar} @@ -1743,13 +1743,13 @@ public class DateUtils { } /** - * Determines how two calendars compare up to no more than the specified + * Determines how two calendars compare up to no more than the specified * most significant field. - * + * * @param cal1 the first calendar, not <code>null</code> * @param cal2 the second calendar, not <code>null</code> * @param field the field from {@code Calendar} - * @return a negative integer, zero, or a positive integer as the first + * @return a negative integer, zero, or a positive integer as the first * calendar is less than, equal to, or greater than the second. * @throws IllegalArgumentException if any argument is <code>null</code> * @see #truncate(Calendar, int) @@ -1763,13 +1763,13 @@ public class DateUtils { } /** - * Determines how two dates compare up to no more than the specified + * Determines how two dates compare up to no more than the specified * most significant field. - * + * * @param date1 the first date, not <code>null</code> * @param date2 the second date, not <code>null</code> * @param field the field from <code>Calendar</code> - * @return a negative integer, zero, or a positive integer as the first + * @return a negative integer, zero, or a positive integer as the first * date is less than, equal to, or greater than the second. * @throws IllegalArgumentException if any argument is <code>null</code> * @see #truncate(Calendar, int) @@ -1793,9 +1793,9 @@ public class DateUtils { static class DateIterator implements Iterator<Calendar> { private final Calendar endFinal; private final Calendar spot; - + /** - * Constructs a DateIterator that ranges from one date to another. + * Constructs a DateIterator that ranges from one date to another. * * @param startFinal start date (inclusive) * @param endFinal end date (inclusive) @@ -1833,7 +1833,7 @@ public class DateUtils { /** * Always throws UnsupportedOperationException. - * + * * @throws UnsupportedOperationException * @see java.util.Iterator#remove() */ diff --git a/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java b/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java index d1396667c..564ea1604 100644 --- a/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java +++ b/src/main/java/org/apache/commons/lang3/time/DurationFormatUtils.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.Validate; /** - * <p>Duration formatting utilities and constants. The following table describes the tokens + * <p>Duration formatting utilities and constants. The following table describes the tokens * used in the pattern language for formatting. </p> * <table border="1" summary="Pattern Tokens"> * <tr><th>character</th><th>duration element</th></tr> @@ -62,7 +62,7 @@ public class DurationFormatUtils { /** * <p>Pattern used with <code>FastDateFormat</code> and <code>SimpleDateFormat</code> * for the ISO 8601 period format used in durations.</p> - * + * * @see org.apache.commons.lang3.time.FastDateFormat * @see java.text.SimpleDateFormat */ @@ -71,7 +71,7 @@ public class DurationFormatUtils { //----------------------------------------------------------------------- /** * <p>Formats the time gap as a string.</p> - * + * * <p>The format used is ISO 8601-like: {@code HH:mm:ss.SSS}.</p> * * @param durationMillis the duration to format @@ -84,12 +84,12 @@ public class DurationFormatUtils { /** * <p>Formats the time gap as a string.</p> - * + * * <p>The format used is the ISO 8601 period format.</p> - * + * * <p>This method formats durations using the days and lower fields of the * ISO format pattern, such as P7D6TH5M4.321S.</p> - * + * * @param durationMillis the duration to format * @return the formatted duration, not null * @throws java.lang.IllegalArgumentException if durationMillis is negative @@ -100,10 +100,10 @@ public class DurationFormatUtils { /** * <p>Formats the time gap as a string, using the specified format, and padding with zeros.</p> - * + * * <p>This method formats durations using the days and lower fields of the * format pattern. Months and larger are not used.</p> - * + * * @param durationMillis the duration to format * @param format the way in which to format the duration, not null * @return the formatted duration, not null @@ -116,10 +116,10 @@ public class DurationFormatUtils { /** * <p>Formats the time gap as a string, using the specified format. * Padding the left hand side of numbers with zeroes is optional.</p> - * + * * <p>This method formats durations using the days and lower fields of the * format pattern. Months and larger are not used.</p> - * + * * @param durationMillis the duration to format * @param format the way in which to format the duration, not null * @param padWithZeros whether to pad the left hand side of numbers with 0's @@ -127,7 +127,7 @@ public class DurationFormatUtils { * @throws java.lang.IllegalArgumentException if durationMillis is negative */ public static String formatDuration(final long durationMillis, final String format, final boolean padWithZeros) { - Validate.inclusiveBetween(0, Long.MAX_VALUE, durationMillis, "durationMillis must not be negative"); + Validate.inclusiveBetween(0, Long.MAX_VALUE, durationMillis, "durationMillis must not be negative"); final Token[] tokens = lexx(format); @@ -136,7 +136,7 @@ public class DurationFormatUtils { long minutes = 0; long seconds = 0; long milliseconds = durationMillis; - + if (Token.containsTokenWithValue(tokens, d) ) { days = milliseconds / DateUtils.MILLIS_PER_DAY; milliseconds = milliseconds - (days * DateUtils.MILLIS_PER_DAY); @@ -159,10 +159,10 @@ public class DurationFormatUtils { /** * <p>Formats an elapsed time into a pluralization correct string.</p> - * + * * <p>This method formats durations using the days and lower fields of the * format pattern. Months and larger are not used.</p> - * + * * @param durationMillis the elapsed time to report in milliseconds * @param suppressLeadingZeroElements suppresses leading 0 elements * @param suppressTrailingZeroElements suppresses trailing 0 elements @@ -175,7 +175,7 @@ public class DurationFormatUtils { final boolean suppressTrailingZeroElements) { // This method is generally replaceable by the format method, but - // there are a series of tweaks and special cases that require + // there are a series of tweaks and special cases that require // trickery to replicate. String duration = formatDuration(durationMillis, "d' days 'H' hours 'm' minutes 's' seconds'"); if (suppressLeadingZeroElements) { @@ -225,9 +225,9 @@ public class DurationFormatUtils { //----------------------------------------------------------------------- /** * <p>Formats the time gap as a string.</p> - * + * * <p>The format used is the ISO 8601 period format.</p> - * + * * @param startMillis the start of the duration to format * @param endMillis the end of the duration to format * @return the formatted duration, not null @@ -240,7 +240,7 @@ public class DurationFormatUtils { /** * <p>Formats the time gap as a string, using the specified format. * Padding the left hand side of numbers with zeroes is optional. - * + * * @param startMillis the start of the duration * @param endMillis the end of the duration * @param format the way in which to format the duration, not null @@ -253,20 +253,20 @@ public class DurationFormatUtils { /** * <p>Formats the time gap as a string, using the specified format. - * Padding the left hand side of numbers with zeroes is optional and + * Padding the left hand side of numbers with zeroes is optional and * the timezone may be specified. </p> * - * <p>When calculating the difference between months/days, it chooses to - * calculate months first. So when working out the number of months and - * days between January 15th and March 10th, it choose 1 month and - * 23 days gained by choosing January->February = 1 month and then - * calculating days forwards, and not the 1 month and 26 days gained by - * choosing March -> February = 1 month and then calculating days + * <p>When calculating the difference between months/days, it chooses to + * calculate months first. So when working out the number of months and + * days between January 15th and March 10th, it choose 1 month and + * 23 days gained by choosing January->February = 1 month and then + * calculating days forwards, and not the 1 month and 26 days gained by + * choosing March -> February = 1 month and then calculating days * backwards. </p> * * <p>For more control, the <a href="http://joda-time.sf.net/">Joda-Time</a> * library is recommended.</p> - * + * * @param startMillis the start of the duration * @param endMillis the end of the duration * @param format the way in which to format the duration, not null @@ -275,20 +275,20 @@ public class DurationFormatUtils { * @return the formatted duration, not null * @throws java.lang.IllegalArgumentException if startMillis is greater than endMillis */ - public static String formatPeriod(final long startMillis, final long endMillis, final String format, final boolean padWithZeros, + public static String formatPeriod(final long startMillis, final long endMillis, final String format, final boolean padWithZeros, final TimeZone timezone) { Validate.isTrue(startMillis <= endMillis, "startMillis must not be greater than endMillis"); - - - // Used to optimise for differences under 28 days and - // called formatDuration(millis, format); however this did not work - // over leap years. - // TODO: Compare performance to see if anything was lost by - // losing this optimisation. - + + + // Used to optimise for differences under 28 days and + // called formatDuration(millis, format); however this did not work + // over leap years. + // TODO: Compare performance to see if anything was lost by + // losing this optimisation. + final Token[] tokens = lexx(format); - // timezones get funky around 0, so normalizing everything to GMT + // timezones get funky around 0, so normalizing everything to GMT // stops the hours being off final Calendar start = Calendar.getInstance(timezone); start.setTime(new Date(startMillis)); @@ -321,7 +321,7 @@ public class DurationFormatUtils { hours += 24; days -= 1; } - + if (Token.containsTokenWithValue(tokens, M)) { while (days < 0) { days += start.getActualMaximum(Calendar.DAY_OF_MONTH); @@ -349,42 +349,42 @@ public class DurationFormatUtils { // target is end-year -1 target -= 1; } - + while (start.get(Calendar.YEAR) != target) { days += start.getActualMaximum(Calendar.DAY_OF_YEAR) - start.get(Calendar.DAY_OF_YEAR); - + // Not sure I grok why this is needed, but the brutal tests show it is if (start instanceof GregorianCalendar && start.get(Calendar.MONTH) == Calendar.FEBRUARY && start.get(Calendar.DAY_OF_MONTH) == 29) { days += 1; } - + start.add(Calendar.YEAR, 1); - + days += start.get(Calendar.DAY_OF_YEAR); } - + years = 0; } - + while( start.get(Calendar.MONTH) != end.get(Calendar.MONTH) ) { days += start.getActualMaximum(Calendar.DAY_OF_MONTH); start.add(Calendar.MONTH, 1); } - - months = 0; + + months = 0; while (days < 0) { days += start.getActualMaximum(Calendar.DAY_OF_MONTH); months -= 1; start.add(Calendar.MONTH, 1); } - + } - // The rest of this code adds in values that - // aren't requested. This allows the user to ask for the + // The rest of this code adds in values that + // aren't requested. This allows the user to ask for the // number of months and get the real count and not just 0->11. if (!Token.containsTokenWithValue(tokens, d)) { @@ -410,7 +410,7 @@ public class DurationFormatUtils { //----------------------------------------------------------------------- /** * <p>The internal method to do the formatting.</p> - * + * * @param tokens the tokens * @param years the number of years * @param months the number of months @@ -486,7 +486,7 @@ public class DurationFormatUtils { static final Object m = "m"; static final Object s = "s"; static final Object S = "S"; - + /** * Parses a classic date format string into Tokens * @@ -602,7 +602,7 @@ public class DurationFormatUtils { } /** - * Wraps a token around a repeated number of a value, for example it would + * Wraps a token around a repeated number of a value, for example it would * store 'yyyy' as a value for y and a count of 4. * * @param value to wrap @@ -616,7 +616,7 @@ public class DurationFormatUtils { /** * Adds another one of the value */ - void increment() { + void increment() { count++; } @@ -631,7 +631,7 @@ public class DurationFormatUtils { /** * Gets the particular value this token represents. - * + * * @return Object value */ Object getValue() { @@ -666,9 +666,9 @@ public class DurationFormatUtils { } /** - * Returns a hash code for the token equal to the - * hash code for the token's value. Thus 'TT' and 'TTTT' - * will have the same hash code. + * Returns a hash code for the token equal to the + * hash code for the token's value. Thus 'TT' and 'TTTT' + * will have the same hash code. * * @return The hash code for the token */ diff --git a/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java b/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java index e7a25acc9..b85993283 100644 --- a/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java +++ b/src/main/java/org/apache/commons/lang3/time/FastDateFormat.java @@ -30,16 +30,16 @@ import java.util.TimeZone; * <p>FastDateFormat is a fast and thread-safe version of * {@link java.text.SimpleDateFormat}.</p> * - * <p>To obtain an instance of FastDateFormat, use one of the static factory methods: - * {@link #getInstance(String, TimeZone, Locale)}, {@link #getDateInstance(int, TimeZone, Locale)}, - * {@link #getTimeInstance(int, TimeZone, Locale)}, or {@link #getDateTimeInstance(int, int, TimeZone, Locale)} + * <p>To obtain an instance of FastDateFormat, use one of the static factory methods: + * {@link #getInstance(String, TimeZone, Locale)}, {@link #getDateInstance(int, TimeZone, Locale)}, + * {@link #getTimeInstance(int, TimeZone, Locale)}, or {@link #getDateTimeInstance(int, int, TimeZone, Locale)} * </p> - * + * * <p>Since FastDateFormat is thread safe, you can use a static member instance:</p> * <code> * private static final FastDateFormat DATE_FORMATTER = FastDateFormat.getDateTimeInstance(FastDateFormat.LONG, FastDateFormat.SHORT); * </code> - * + * * <p>This class can be used as a direct replacement to * {@code SimpleDateFormat} in most formatting and parsing situations. * This class is especially useful in multi-threaded server environments. @@ -70,7 +70,7 @@ import java.util.TimeZone; * @since 2.0 */ public class FastDateFormat extends Format implements DateParser, DatePrinter { - + /** * Required for serialization support. * @@ -81,19 +81,19 @@ public class FastDateFormat extends Format implements DateParser, DatePrinter { /** * FULL locale dependent date or time style. */ - + public static final int FULL = DateFormat.FULL; - + /** * LONG locale dependent date or time style. */ public static final int LONG = DateFormat.LONG; - + /** * MEDIUM locale dependent date or time style. */ public static final int MEDIUM = DateFormat.MEDIUM; - + /** * SHORT locale dependent date or time style. */ diff --git a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java index 9cf1a1cb2..bcb51181f 100644 --- a/src/main/java/org/apache/commons/lang3/time/FastDateParser.java +++ b/src/main/java/org/apache/commons/lang3/time/FastDateParser.java @@ -43,14 +43,14 @@ import java.util.regex.Pattern; * <p>FastDateParser is a fast and thread-safe version of * {@link java.text.SimpleDateFormat}.</p> * - * <p>To obtain a proxy to a FastDateParser, use {@link FastDateFormat#getInstance(String, TimeZone, Locale)} + * <p>To obtain a proxy to a FastDateParser, use {@link FastDateFormat#getInstance(String, TimeZone, Locale)} * or another variation of the factory methods of {@link FastDateFormat}.</p> - * + * * <p>Since FastDateParser is thread safe, you can use a static member instance:</p> * <code> * private static final DateParser DATE_PARSER = FastDateFormat.getInstance("yyyy-MM-dd"); * </code> - * + * * <p>This class can be used as a direct replacement for * <code>SimpleDateFormat</code> in most parsing situations. * This class is especially useful in multi-threaded server environments. @@ -103,8 +103,8 @@ public class FastDateParser implements DateParser, Serializable { /** * <p>Constructs a new FastDateParser.</p> - * - * Use {@link FastDateFormat#getInstance(String, TimeZone, Locale)} or another variation of the + * + * Use {@link FastDateFormat#getInstance(String, TimeZone, Locale)} or another variation of the * factory methods of {@link FastDateFormat} to get a cached FastDateParser instance. * * @param pattern non-null {@link java.text.SimpleDateFormat} compatible @@ -381,8 +381,8 @@ public class FastDateParser implements DateParser, Serializable { /** * This implementation updates the ParsePosition if the parse succeeds. - * However, it sets the error index to the position before the failed field unlike - * the method {@link java.text.SimpleDateFormat#parse(String, ParsePosition)} which sets + * However, it sets the error index to the position before the failed field unlike + * the method {@link java.text.SimpleDateFormat#parse(String, ParsePosition)} which sets * the error index to after the failed field. * <p> * To determine if the parse has succeeded, the caller must check if the current parse position @@ -405,7 +405,7 @@ public class FastDateParser implements DateParser, Serializable { * Upon success, the ParsePosition index is updated to indicate how much of the source text was consumed. * Not all source text needs to be consumed. Upon parse failure, ParsePosition error index is updated to * the offset of the source text which does not match the supplied format. - * + * * @param source The text to parse. * @param pos On input, the position in the source to start parsing, on output, updated position. * @param calendar The calendar into which to set parsed fields. @@ -566,7 +566,7 @@ public class FastDateParser implements DateParser, Serializable { return getLocaleSpecificStrategy(Calendar.ERA, definingCalendar); case 'H': // Hour in day (0-23) return HOUR_OF_DAY_STRATEGY; - case 'K': // Hour in am/pm (0-11) + case 'K': // Hour in am/pm (0-11) return HOUR_STRATEGY; case 'M': return width>=3 ?getLocaleSpecificStrategy(Calendar.MONTH, definingCalendar) :NUMBER_MONTH_STRATEGY; @@ -632,7 +632,7 @@ public class FastDateParser implements DateParser, Serializable { final ConcurrentMap<Locale, Strategy> cache = getCache(field); Strategy strategy = cache.get(locale); if (strategy == null) { - strategy = field == Calendar.ZONE_OFFSET + strategy = field == Calendar.ZONE_OFFSET ? new TimeZoneStrategy(locale) : new CaseInsensitiveTextStrategy(field, definingCalendar, locale); final Strategy inCache = cache.putIfAbsent(locale, strategy); @@ -701,7 +701,7 @@ public class FastDateParser implements DateParser, Serializable { CaseInsensitiveTextStrategy(final int field, final Calendar definingCalendar, final Locale locale) { this.field = field; this.locale = locale; - + final StringBuilder regex = new StringBuilder(); regex.append("((?iu)"); lKeyValues = appendDisplayNames(definingCalendar, locale, field, regex); @@ -903,9 +903,9 @@ public class FastDateParser implements DateParser, Serializable { } } } - + private static class ISO8601TimeZoneStrategy extends PatternStrategy { - // Z, +hh, -hh, +hhmm, -hhmm, +hh:mm or -hh:mm + // Z, +hh, -hh, +hhmm, -hhmm, +hh:mm or -hh:mm /** * Construct a Strategy that parses a TimeZone @@ -914,7 +914,7 @@ public class FastDateParser implements DateParser, Serializable { ISO8601TimeZoneStrategy(final String pattern) { createPattern(pattern); } - + /** * {@inheritDoc} */ @@ -926,14 +926,14 @@ public class FastDateParser implements DateParser, Serializable { cal.setTimeZone(TimeZone.getTimeZone("GMT" + value)); } } - + private static final Strategy ISO_8601_1_STRATEGY = new ISO8601TimeZoneStrategy("(Z|(?:[+-]\\d{2}))"); private static final Strategy ISO_8601_2_STRATEGY = new ISO8601TimeZoneStrategy("(Z|(?:[+-]\\d{2}\\d{2}))"); private static final Strategy ISO_8601_3_STRATEGY = new ISO8601TimeZoneStrategy("(Z|(?:[+-]\\d{2}(?::)\\d{2}))"); /** * Factory method for ISO8601TimeZoneStrategies. - * + * * @param tokenLen a token indicating the length of the TimeZone String to be formatted. * @return a ISO8601TimeZoneStrategy that can format TimeZone String of length {@code tokenLen}. If no such * strategy exists, an IllegalArgumentException will be thrown. diff --git a/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java b/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java index fafa71cae..b603fac78 100644 --- a/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java +++ b/src/main/java/org/apache/commons/lang3/time/FastDatePrinter.java @@ -37,14 +37,14 @@ import org.apache.commons.lang3.exception.ExceptionUtils; * <p>FastDatePrinter is a fast and thread-safe version of * {@link java.text.SimpleDateFormat}.</p> * - * <p>To obtain a FastDatePrinter, use {@link FastDateFormat#getInstance(String, TimeZone, Locale)} + * <p>To obtain a FastDatePrinter, use {@link FastDateFormat#getInstance(String, TimeZone, Locale)} * or another variation of the factory methods of {@link FastDateFormat}.</p> - * + * * <p>Since FastDatePrinter is thread safe, you can use a static member instance:</p> * <code> * private static final DatePrinter DATE_PRINTER = FastDateFormat.getInstance("yyyy-MM-dd"); * </code> - * + * * <p>This class can be used as a direct replacement to * {@code SimpleDateFormat} in most formatting situations. * This class is especially useful in multi-threaded server environments. @@ -63,7 +63,7 @@ import org.apache.commons.lang3.exception.ExceptionUtils; * ISO 8601 extended format time zones (eg. {@code +08:00} or {@code -11:00}). * This introduces a minor incompatibility with Java 1.4, but at a gain of * useful functionality.</p> - * + * * <p>Starting with JDK7, ISO 8601 support was added using the pattern {@code 'X'}. * To maintain compatibility, {@code 'ZZ'} will continue to be supported, but using * one of the {@code 'X'} formats is recommended. @@ -139,7 +139,7 @@ public class FastDatePrinter implements DatePrinter, Serializable { //----------------------------------------------------------------------- /** * <p>Constructs a new FastDatePrinter.</p> - * Use {@link FastDateFormat#getInstance(String, TimeZone, Locale)} or another variation of the + * Use {@link FastDateFormat#getInstance(String, TimeZone, Locale)} or another variation of the * factory methods of {@link FastDateFormat} to get a cached FastDatePrinter instance. * * @param pattern {@link java.text.SimpleDateFormat} compatible pattern @@ -276,9 +276,9 @@ public class FastDatePrinter implements DatePrinter, Serializable { case 'K': // hour in am/pm (0..11) rule = selectNumberRule(Calendar.HOUR, tokenLen); break; - case 'X': // ISO 8601 + case 'X': // ISO 8601 rule = Iso8601_Rule.getRule(tokenLen); - break; + break; case 'z': // time zone (text) if (tokenLen >= 4) { rule = new TimeZoneNameRule(mTimeZone, mLocale, TimeZone.LONG); @@ -632,7 +632,7 @@ public class FastDatePrinter implements DatePrinter, Serializable { } final FastDatePrinter other = (FastDatePrinter) obj; return mPattern.equals(other.mPattern) - && mTimeZone.equals(other.mTimeZone) + && mTimeZone.equals(other.mTimeZone) && mLocale.equals(other.mLocale); } @@ -1347,7 +1347,7 @@ public class FastDatePrinter implements DatePrinter, Serializable { TimeZoneNameRule(final TimeZone timeZone, final Locale locale, final int style) { mLocale = locale; mStyle = style; - + mStandard = getTimeZoneDisplay(timeZone, false, style, locale); mDaylight = getTimeZoneDisplay(timeZone, true, style, locale); } @@ -1384,7 +1384,7 @@ public class FastDatePrinter implements DatePrinter, Serializable { private static class TimeZoneNumberRule implements Rule { static final TimeZoneNumberRule INSTANCE_COLON = new TimeZoneNumberRule(true); static final TimeZoneNumberRule INSTANCE_NO_COLON = new TimeZoneNumberRule(false); - + final boolean mColon; /** @@ -1409,7 +1409,7 @@ public class FastDatePrinter implements DatePrinter, Serializable { */ @Override public void appendTo(final Appendable buffer, final Calendar calendar) throws IOException { - + int offset = calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET); if (offset < 0) { @@ -1436,9 +1436,9 @@ public class FastDatePrinter implements DatePrinter, Serializable { * or {@code +/-HH:MM}.</p> */ private static class Iso8601_Rule implements Rule { - + // Sign TwoDigitHours or Z - static final Iso8601_Rule ISO8601_HOURS = new Iso8601_Rule(3); + static final Iso8601_Rule ISO8601_HOURS = new Iso8601_Rule(3); // Sign TwoDigitHours Minutes or Z static final Iso8601_Rule ISO8601_HOURS_MINUTES = new Iso8601_Rule(5); // Sign TwoDigitHours : Minutes or Z @@ -1460,10 +1460,10 @@ public class FastDatePrinter implements DatePrinter, Serializable { case 3: return Iso8601_Rule.ISO8601_HOURS_COLON_MINUTES; default: - throw new IllegalArgumentException("invalid number of X"); + throw new IllegalArgumentException("invalid number of X"); } - } - + } + final int length; /** @@ -1493,7 +1493,7 @@ public class FastDatePrinter implements DatePrinter, Serializable { buffer.append("Z"); return; } - + if (offset < 0) { buffer.append('-'); offset = -offset; @@ -1507,7 +1507,7 @@ public class FastDatePrinter implements DatePrinter, Serializable { if (length<5) { return; } - + if (length==6) { buffer.append(':'); } diff --git a/src/main/java/org/apache/commons/lang3/time/FormatCache.java b/src/main/java/org/apache/commons/lang3/time/FormatCache.java index 22850f632..f6ff481da 100644 --- a/src/main/java/org/apache/commons/lang3/time/FormatCache.java +++ b/src/main/java/org/apache/commons/lang3/time/FormatCache.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,27 +29,27 @@ import org.apache.commons.lang3.Validate; /** * <p>FormatCache is a cache and factory for {@link Format}s.</p> - * + * * @since 3.0 */ // TODO: Before making public move from getDateTimeInstance(Integer,...) to int; or some other approach. abstract class FormatCache<F extends Format> { - + /** * No date or no time. Used in same parameters as DateFormat.SHORT or DateFormat.LONG */ static final int NONE= -1; - - private final ConcurrentMap<MultipartKey, F> cInstanceCache + + private final ConcurrentMap<MultipartKey, F> cInstanceCache = new ConcurrentHashMap<>(7); - - private static final ConcurrentMap<MultipartKey, String> cDateTimeInstanceCache + + private static final ConcurrentMap<MultipartKey, String> cDateTimeInstanceCache = new ConcurrentHashMap<>(7); /** * <p>Gets a formatter instance using the default pattern in the * default timezone and locale.</p> - * + * * @return a date/time formatter */ public F getInstance() { @@ -59,7 +59,7 @@ abstract class FormatCache<F extends Format> { /** * <p>Gets a formatter instance using the specified pattern, time zone * and locale.</p> - * + * * @param pattern {@link java.text.SimpleDateFormat} compatible * pattern, non-null * @param timeZone the time zone, null means use the default TimeZone @@ -78,22 +78,22 @@ abstract class FormatCache<F extends Format> { } final MultipartKey key = new MultipartKey(pattern, timeZone, locale); F format = cInstanceCache.get(key); - if (format == null) { + if (format == null) { format = createInstance(pattern, timeZone, locale); final F previousValue= cInstanceCache.putIfAbsent(key, format); if (previousValue != null) { // another thread snuck in and did the same work // we should return the instance that is in ConcurrentMap - format= previousValue; + format= previousValue; } } return format; } - + /** * <p>Create a format instance using the specified pattern, time zone * and locale.</p> - * + * * @param pattern {@link java.text.SimpleDateFormat} compatible pattern, this will not be null. * @param timeZone time zone, this will not be null. * @param locale locale, this will not be null. @@ -102,11 +102,11 @@ abstract class FormatCache<F extends Format> { * or <code>null</code> */ abstract protected F createInstance(String pattern, TimeZone timeZone, Locale locale); - + /** * <p>Gets a date/time formatter instance using the specified style, * time zone and locale.</p> - * + * * @param dateStyle date style: FULL, LONG, MEDIUM, or SHORT, null indicates no date in format * @param timeStyle time style: FULL, LONG, MEDIUM, or SHORT, null indicates no time in format * @param timeZone optional time zone, overrides time zone of @@ -116,7 +116,7 @@ abstract class FormatCache<F extends Format> { * @throws IllegalArgumentException if the Locale has no date/time * pattern defined */ - // This must remain private, see LANG-884 + // This must remain private, see LANG-884 private F getDateTimeInstance(final Integer dateStyle, final Integer timeStyle, final TimeZone timeZone, Locale locale) { if (locale == null) { locale = Locale.getDefault(); @@ -128,7 +128,7 @@ abstract class FormatCache<F extends Format> { /** * <p>Gets a date/time formatter instance using the specified style, * time zone and locale.</p> - * + * * @param dateStyle date style: FULL, LONG, MEDIUM, or SHORT * @param timeStyle time style: FULL, LONG, MEDIUM, or SHORT * @param timeZone optional time zone, overrides time zone of @@ -146,7 +146,7 @@ abstract class FormatCache<F extends Format> { /** * <p>Gets a date formatter instance using the specified style, * time zone and locale.</p> - * + * * @param dateStyle date style: FULL, LONG, MEDIUM, or SHORT * @param timeZone optional time zone, overrides time zone of * formatted date, null means use default Locale @@ -163,7 +163,7 @@ abstract class FormatCache<F extends Format> { /** * <p>Gets a time formatter instance using the specified style, * time zone and locale.</p> - * + * * @param timeStyle time style: FULL, LONG, MEDIUM, or SHORT * @param timeZone optional time zone, overrides time zone of * formatted date, null means use default Locale @@ -179,7 +179,7 @@ abstract class FormatCache<F extends Format> { /** * <p>Gets a date/time format for the specified styles and locale.</p> - * + * * @param dateStyle date style: FULL, LONG, MEDIUM, or SHORT, null indicates no date in format * @param timeStyle time style: FULL, LONG, MEDIUM, or SHORT, null indicates no time in format * @param locale The non-null locale of the desired format @@ -195,10 +195,10 @@ abstract class FormatCache<F extends Format> { try { DateFormat formatter; if (dateStyle == null) { - formatter = DateFormat.getTimeInstance(timeStyle.intValue(), locale); + formatter = DateFormat.getTimeInstance(timeStyle.intValue(), locale); } else if (timeStyle == null) { - formatter = DateFormat.getDateInstance(dateStyle.intValue(), locale); + formatter = DateFormat.getDateInstance(dateStyle.intValue(), locale); } else { formatter = DateFormat.getDateTimeInstance(dateStyle.intValue(), timeStyle.intValue(), locale); diff --git a/src/main/java/org/apache/commons/lang3/time/StopWatch.java b/src/main/java/org/apache/commons/lang3/time/StopWatch.java index 0bd60a745..573fa8646 100644 --- a/src/main/java/org/apache/commons/lang3/time/StopWatch.java +++ b/src/main/java/org/apache/commons/lang3/time/StopWatch.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,7 +23,7 @@ import java.util.concurrent.TimeUnit; * <p> * <code>StopWatch</code> provides a convenient API for timings. * </p> - * + * * <p> * To start the watch, call {@link #start()} or {@link StopWatch#createStarted()}. At this point you can: * </p> @@ -34,26 +34,26 @@ import java.util.concurrent.TimeUnit; * suspend and resume will not be counted in the total. At this point, these three options are available again.</li> * <li>{@link #stop()} the watch to complete the timing session.</li> * </ul> - * + * * <p> * It is intended that the output methods {@link #toString()} and {@link #getTime()} should only be called after stop, * split or suspend, however a suitable result will be returned at other points. * </p> - * + * * <p> * NOTE: As from v2.1, the methods protect against inappropriate calls. Thus you cannot now call stop before start, * resume before suspend or unsplit before split. * </p> - * + * * <p> * 1. split(), suspend(), or stop() cannot be invoked twice<br> * 2. unsplit() may only be called if the watch has been split()<br> * 3. resume() may only be called if the watch has been suspend()<br> * 4. start() cannot be called twice without calling reset() * </p> - * + * * <p>This class is not thread-safe</p> - * + * * @since 2.0 */ public class StopWatch { @@ -64,7 +64,7 @@ public class StopWatch { /** * Provides a started stopwatch for convenience. * - * @return StopWatch a stopwatch that's already been started. + * @return StopWatch a stopwatch that's already been started. * * @since 3.5 */ @@ -73,7 +73,7 @@ public class StopWatch { sw.start(); return sw; } - + /** * Enumeration type which indicates the status of stopwatch. */ @@ -136,7 +136,7 @@ public class StopWatch { /** * Enumeration type which indicates the split status of stopwatch. - */ + */ private enum SplitState { SPLIT, UNSPLIT @@ -157,8 +157,8 @@ public class StopWatch { private long startTime; /** - * The start time in Millis - nanoTime is only for elapsed time so we - * need to also store the currentTimeMillis to maintain the old + * The start time in Millis - nanoTime is only for elapsed time so we + * need to also store the currentTimeMillis to maintain the old * getStartTime API. */ private long startTimeMillis; @@ -181,11 +181,11 @@ public class StopWatch { * <p> * Start the stopwatch. * </p> - * + * * <p> * This method starts a new timing session, clearing any previous values. * </p> - * + * * @throws IllegalStateException * if the StopWatch is already running. */ @@ -206,11 +206,11 @@ public class StopWatch { * <p> * Stop the stopwatch. * </p> - * + * * <p> * This method ends a new timing session, allowing the time to be retrieved. * </p> - * + * * @throws IllegalStateException * if the StopWatch is not running. */ @@ -228,7 +228,7 @@ public class StopWatch { * <p> * Resets the stopwatch. Stops it if need be. * </p> - * + * * <p> * This method clears the internal values to allow the object to be reused. * </p> @@ -242,12 +242,12 @@ public class StopWatch { * <p> * Split the time. * </p> - * + * * <p> * This method sets the stop time of the watch to allow a time to be extracted. The start time is unaffected, * enabling {@link #unsplit()} to continue the timing from the original start point. * </p> - * + * * @throws IllegalStateException * if the StopWatch is not running. */ @@ -263,12 +263,12 @@ public class StopWatch { * <p> * Remove a split. * </p> - * + * * <p> * This method clears the stop time. The start time is unaffected, enabling timing from the original start point to * continue. * </p> - * + * * @throws IllegalStateException * if the StopWatch has not been split. */ @@ -283,12 +283,12 @@ public class StopWatch { * <p> * Suspend the stopwatch for later resumption. * </p> - * + * * <p> * This method suspends the watch until it is resumed. The watch will not include time between the suspend and * resume calls in the total time. * </p> - * + * * @throws IllegalStateException * if the StopWatch is not currently running. */ @@ -304,12 +304,12 @@ public class StopWatch { * <p> * Resume the stopwatch after a suspend. * </p> - * + * * <p> * This method resumes the watch after it was suspended. The watch will not include time between the suspend and * resume calls in the total time. * </p> - * + * * @throws IllegalStateException * if the StopWatch has not been suspended. */ @@ -325,12 +325,12 @@ public class StopWatch { * <p> * Get the time on the stopwatch. * </p> - * + * * <p> * This is either the time between the start and the moment this method is called, or the amount of time between * start and stop. * </p> - * + * * @return the time in milliseconds */ public long getTime() { @@ -341,14 +341,14 @@ public class StopWatch { * <p> * Get the time on the stopwatch in the specified TimeUnit. * </p> - * + * * <p> * This is either the time between the start and the moment this method is called, or the amount of time between * start and stop. The resulting time will be expressed in the desired TimeUnit with any remainder rounded down. * For example, if the specified unit is {@code TimeUnit.HOURS} and the stopwatch time is 59 minutes, then the * result returned will be {@code 0}. * </p> - * + * * @param timeUnit the unit of time, not null * @return the time in the specified TimeUnit, rounded down * @since 3.5 @@ -361,12 +361,12 @@ public class StopWatch { * <p> * Get the time on the stopwatch in nanoseconds. * </p> - * + * * <p> * This is either the time between the start and the moment this method is called, or the amount of time between * start and stop. * </p> - * + * * @return the time in nanoseconds * @since 3.0 */ @@ -385,13 +385,13 @@ public class StopWatch { * <p> * Get the split time on the stopwatch. * </p> - * + * * <p> * This is the time between start and latest split. * </p> - * + * * @return the split time in milliseconds - * + * * @throws IllegalStateException * if the StopWatch has not yet been split. * @since 2.1 @@ -403,13 +403,13 @@ public class StopWatch { * <p> * Get the split time on the stopwatch in nanoseconds. * </p> - * + * * <p> * This is the time between start and latest split. * </p> - * + * * @return the split time in nanoseconds - * + * * @throws IllegalStateException * if the StopWatch has not yet been split. * @since 3.0 @@ -423,7 +423,7 @@ public class StopWatch { /** * Returns the time this stopwatch was started. - * + * * @return the time this stopwatch was started * @throws IllegalStateException * if this StopWatch has not been started @@ -441,11 +441,11 @@ public class StopWatch { * <p> * Gets a summary of the time that the stopwatch recorded as a string. * </p> - * + * * <p> * The format used is ISO 8601-like, <i>hours</i>:<i>minutes</i>:<i>seconds</i>.<i>milliseconds</i>. * </p> - * + * * @return the time as a String */ @Override @@ -457,11 +457,11 @@ public class StopWatch { * <p> * Gets a summary of the split time that the stopwatch recorded as a string. * </p> - * + * * <p> * The format used is ISO 8601-like, <i>hours</i>:<i>minutes</i>:<i>seconds</i>.<i>milliseconds</i>. * </p> - * + * * @return the split time as a String * @since 2.1 */ @@ -509,6 +509,6 @@ public class StopWatch { */ public boolean isStopped() { return runningState.isStopped(); - } + } } diff --git a/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java b/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java index 3df3a7fa0..e84c49b11 100644 --- a/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java +++ b/src/main/java/org/apache/commons/lang3/tuple/ImmutablePair.java @@ -18,12 +18,12 @@ package org.apache.commons.lang3.tuple; /** * <p>An immutable pair consisting of two {@code Object} elements.</p> - * + * * <p>Although the implementation is immutable, there is no restriction on the objects * that may be stored. If mutable objects are stored in the pair, then the pair * itself effectively becomes mutable. The class is also {@code final}, so a subclass * can not add undesirable behaviour.</p> - * + * * <p>#ThreadSafe# if both paired objects are thread-safe</p> * * @param <L> the left element type @@ -55,7 +55,7 @@ public final class ImmutablePair<L, R> extends Pair<L, R> { public static <L, R> ImmutablePair<L, R> nullPair() { return NULL; } - + /** Left object */ public final L left; /** Right object */ @@ -63,10 +63,10 @@ public final class ImmutablePair<L, R> extends Pair<L, R> { /** * <p>Obtains an immutable pair of from two objects inferring the generic types.</p> - * + * * <p>This factory allows the pair to be created using inference to * obtain the generic types.</p> - * + * * @param <L> the left element type * @param <R> the right element type * @param left the left element, may be null @@ -108,7 +108,7 @@ public final class ImmutablePair<L, R> extends Pair<L, R> { /** * <p>Throws {@code UnsupportedOperationException}.</p> - * + * * <p>This pair is immutable, so this operation is not supported.</p> * * @param value the value to set diff --git a/src/main/java/org/apache/commons/lang3/tuple/ImmutableTriple.java b/src/main/java/org/apache/commons/lang3/tuple/ImmutableTriple.java index 83e212efc..725f7212b 100644 --- a/src/main/java/org/apache/commons/lang3/tuple/ImmutableTriple.java +++ b/src/main/java/org/apache/commons/lang3/tuple/ImmutableTriple.java @@ -18,12 +18,12 @@ package org.apache.commons.lang3.tuple; /** * <p>An immutable triple consisting of three {@code Object} elements.</p> - * + * * <p>Although the implementation is immutable, there is no restriction on the objects * that may be stored. If mutable objects are stored in the triple, then the triple * itself effectively becomes mutable. The class is also {@code final}, so a subclass * can not add undesirable behaviour.</p> - * + * * <p>#ThreadSafe# if all three objects are thread-safe</p> * * @param <L> the left element type @@ -50,14 +50,14 @@ public final class ImmutableTriple<L, M, R> extends Triple<L, M, R> { * @param <L> the left element of this triple. Value is {@code null}. * @param <M> the middle element of this triple. Value is {@code null}. * @param <R> the right element of this triple. Value is {@code null}. - * @return an immutable triple of nulls. + * @return an immutable triple of nulls. * @since 3.6 */ @SuppressWarnings("unchecked") public static <L, M, R> ImmutableTriple<L, M, R> nullTriple() { return NULL; } - + /** Left object */ public final L left; /** Middle object */ @@ -67,10 +67,10 @@ public final class ImmutableTriple<L, M, R> extends Triple<L, M, R> { /** * <p>Obtains an immutable triple of from three objects inferring the generic types.</p> - * + * * <p>This factory allows the triple to be created using inference to * obtain the generic types.</p> - * + * * @param <L> the left element type * @param <M> the middle element type * @param <R> the right element type diff --git a/src/main/java/org/apache/commons/lang3/tuple/MutablePair.java b/src/main/java/org/apache/commons/lang3/tuple/MutablePair.java index 3c99ac404..852edae9f 100644 --- a/src/main/java/org/apache/commons/lang3/tuple/MutablePair.java +++ b/src/main/java/org/apache/commons/lang3/tuple/MutablePair.java @@ -18,7 +18,7 @@ package org.apache.commons.lang3.tuple; /** * <p>A mutable pair consisting of two {@code Object} elements.</p> - * + * * <p>Not #ThreadSafe#</p> * * @param <L> the left element type @@ -38,10 +38,10 @@ public class MutablePair<L, R> extends Pair<L, R> { /** * <p>Obtains an immutable pair of from two objects inferring the generic types.</p> - * + * * <p>This factory allows the pair to be created using inference to * obtain the generic types.</p> - * + * * @param <L> the left element type * @param <R> the right element type * @param left the left element, may be null @@ -82,7 +82,7 @@ public class MutablePair<L, R> extends Pair<L, R> { /** * Sets the left element of the pair. - * + * * @param left the new value of the left element, may be null */ public void setLeft(final L left) { @@ -99,7 +99,7 @@ public class MutablePair<L, R> extends Pair<L, R> { /** * Sets the right element of the pair. - * + * * @param right the new value of the right element, may be null */ public void setRight(final R right) { @@ -109,7 +109,7 @@ public class MutablePair<L, R> extends Pair<L, R> { /** * Sets the {@code Map.Entry} value. * This sets the right element of the pair. - * + * * @param value the right value to set, not null * @return the old value for the right element */ diff --git a/src/main/java/org/apache/commons/lang3/tuple/Pair.java b/src/main/java/org/apache/commons/lang3/tuple/Pair.java index de9517000..3414d04a5 100644 --- a/src/main/java/org/apache/commons/lang3/tuple/Pair.java +++ b/src/main/java/org/apache/commons/lang3/tuple/Pair.java @@ -24,11 +24,11 @@ import org.apache.commons.lang3.builder.CompareToBuilder; /** * <p>A pair consisting of two elements.</p> - * + * * <p>This class is an abstract implementation defining the basic API. * It refers to the elements as 'left' and 'right'. It also implements the * {@code Map.Entry} interface where the key is 'left' and the value is 'right'.</p> - * + * * <p>Subclass implementations may be mutable or immutable. * However, there is no restriction on the type of the stored objects that may be stored. * If mutable objects are stored in the pair, then the pair itself effectively becomes mutable.</p> @@ -45,10 +45,10 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L, /** * <p>Obtains an immutable pair of from two objects inferring the generic types.</p> - * + * * <p>This factory allows the pair to be created using inference to * obtain the generic types.</p> - * + * * @param <L> the left element type * @param <R> the right element type * @param left the left element, may be null @@ -62,28 +62,28 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L, //----------------------------------------------------------------------- /** * <p>Gets the left element from this pair.</p> - * + * * <p>When treated as a key-value pair, this is the key.</p> - * + * * @return the left element, may be null */ public abstract L getLeft(); /** * <p>Gets the right element from this pair.</p> - * + * * <p>When treated as a key-value pair, this is the value.</p> - * + * * @return the right element, may be null */ public abstract R getRight(); /** * <p>Gets the key from this pair.</p> - * + * * <p>This method implements the {@code Map.Entry} interface returning the * left element as the key.</p> - * + * * @return the left element as the key, may be null */ @Override @@ -93,10 +93,10 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L, /** * <p>Gets the value from this pair.</p> - * + * * <p>This method implements the {@code Map.Entry} interface returning the * right element as the value.</p> - * + * * @return the right element as the value, may be null */ @Override @@ -108,7 +108,7 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L, /** * <p>Compares the pair based on the left element followed by the right element. * The types must be {@code Comparable}.</p> - * + * * @param other the other pair, not null * @return negative if this is less, zero if equal, positive if greater */ @@ -120,7 +120,7 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L, /** * <p>Compares this pair to another based on the two elements.</p> - * + * * @param obj the object to compare to, null returns false * @return true if the elements of the pair are equal */ @@ -140,7 +140,7 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L, /** * <p>Returns a suitable hash code. * The hash code follows the definition in {@code Map.Entry}.</p> - * + * * @return the hash code */ @Override @@ -152,7 +152,7 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L, /** * <p>Returns a String representation of this pair using the format {@code ($left,$right)}.</p> - * + * * @return a string describing this object, not null */ @Override @@ -162,12 +162,12 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L, /** * <p>Formats the receiver using the given format.</p> - * + * * <p>This uses {@link java.util.Formattable} to perform the formatting. Two variables may * be used to embed the left and right elements. Use {@code %1$s} for the left * element (key) and {@code %2$s} for the right element (value). * The default format used by {@code toString()} is {@code (%1$s,%2$s)}.</p> - * + * * @param format the format string, optionally containing {@code %1$s} and {@code %2$s}, not null * @return the formatted string, not null */ diff --git a/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java b/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java index ee4a3618f..390b5f7e3 100644 --- a/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/AnnotationUtilsTest.java @@ -350,7 +350,7 @@ public class AnnotationUtilsTest { NestAnnotation nest(); NestAnnotation[] nests(); } - + @Retention(RUNTIME) public @interface NestAnnotation { String string(); diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java index 28c6bbd14..dbbcdfd59 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsAddTest.java @@ -224,7 +224,7 @@ public class ArrayUtilsAddTest { assertTrue(Arrays.equals(new Float[]{Float.valueOf(3)}, newArray)); assertEquals(Float.class, newArray.getClass().getComponentType()); } - + @Test public void testLANG571(){ final String[] stringArray=null; diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsInsertTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsInsertTest.java index 86b091613..80ff24d10 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsInsertTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsInsertTest.java @@ -28,34 +28,34 @@ import org.junit.Test; * Tests ArrayUtils insert methods. */ public class ArrayUtilsInsertTest { - + @Test public void testInsertBooleans() throws Exception { final boolean[] array = {true,false,true}; final boolean[] values = {false,true,false}; - + boolean[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); - assertArrayEquals(new boolean[0], ArrayUtils.insert(0, new boolean[0], null)); + + assertNull(ArrayUtils.insert(42, null, array)); + assertArrayEquals(new boolean[0], ArrayUtils.insert(0, new boolean[0], null)); assertNull(ArrayUtils.insert(42, (boolean[]) null, null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + 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)); @@ -69,29 +69,29 @@ public class ArrayUtilsInsertTest { public void testInsertBytes() throws Exception { final byte[] array = {1,2,3}; final byte[] values = {4,5,6}; - + byte[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); + + assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new byte[0], ArrayUtils.insert(0, new byte[0], null)); assertNull(ArrayUtils.insert(42, (byte[]) null, null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + 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)); @@ -99,34 +99,34 @@ public class ArrayUtilsInsertTest { 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() throws Exception { final char[] array = {'a','b','c'}; final char[] values = {'d','e','f'}; - + char[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); + + assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new char[0], ArrayUtils.insert(0, new char[0], null)); assertNull(ArrayUtils.insert(42, (char[]) null, null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + 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')); @@ -134,219 +134,219 @@ public class ArrayUtilsInsertTest { 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() throws Exception { final double[] array = {1,2,3}; final double[] values = {4,5,6}; final double delta = 0.000001; - + double[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result, delta); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); + + assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new double[0], ArrayUtils.insert(0, new double[0], null), delta); assertNull(ArrayUtils.insert(42, (double[]) null, null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + 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() throws Exception { final float[] array = {1,2,3}; final float[] values = {4,5,6}; final float delta = 0.000001f; - + float[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result, delta); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); + + assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new float[0], ArrayUtils.insert(0, new float[0], null), delta); assertNull(ArrayUtils.insert(42, (float[]) null, null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + 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() throws Exception { final int[] array = {1,2,3}; final int[] values = {4,5,6}; - + int[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); + + assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new int[0], ArrayUtils.insert(0, new int[0], null)); assertNull(ArrayUtils.insert(42, (int[]) null, null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + 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() throws Exception { final long[] array = {1,2,3}; final long[] values = {4,5,6}; - + long[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); + + assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new long[0], ArrayUtils.insert(0, new long[0], null)); assertNull(ArrayUtils.insert(42, (long[]) null, null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + 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() throws Exception { final short[] array = {1,2,3}; final short[] values = {4,5,6}; - + short[] result = ArrayUtils.insert(42, array, null); assertArrayEquals(array, result); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); + + assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new short[0], ArrayUtils.insert(0, new short[0], null)); assertNull(ArrayUtils.insert(42, (short[]) null, null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + 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() throws Exception { final String[] array = {"a","b","c"}; final String[] values = {"d","e","f"}; - + String[] result = ArrayUtils.insert(42, array, (String[]) null); assertArrayEquals(array, result); assertFalse(array == result); - - assertNull(ArrayUtils.insert(42, null, array)); + + assertNull(ArrayUtils.insert(42, null, array)); assertArrayEquals(new String[0], ArrayUtils.insert(0, new String[0], (String[]) null)); assertNull(ArrayUtils.insert(42, null, (String[]) null)); - + try { ArrayUtils.insert(-1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected } - + try { ArrayUtils.insert(array.length + 1, array, array); fail("Expected IndexOutOfBoundsException"); } catch (IndexOutOfBoundsException e) { // expected - } - + } + 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)); - } + } } diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java index 341402778..9e596d4a7 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveMultipleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java index 0572f8cef..95ea490f3 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsRemoveTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -104,7 +104,7 @@ public class ArrayUtilsRemoveTest { fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} } - + @Test public void testRemoveByteArray() { byte[] array; @@ -133,7 +133,7 @@ public class ArrayUtilsRemoveTest { fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} } - + @Test public void testRemoveCharArray() { char[] array; @@ -162,7 +162,7 @@ public class ArrayUtilsRemoveTest { fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} } - + @Test public void testRemoveDoubleArray() { double[] array; @@ -191,7 +191,7 @@ public class ArrayUtilsRemoveTest { fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} } - + @Test public void testRemoveFloatArray() { float[] array; @@ -220,7 +220,7 @@ public class ArrayUtilsRemoveTest { fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} } - + @Test public void testRemoveIntArray() { int[] array; @@ -249,7 +249,7 @@ public class ArrayUtilsRemoveTest { fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} } - + @Test public void testRemoveLongArray() { long[] array; @@ -278,7 +278,7 @@ public class ArrayUtilsRemoveTest { fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} } - + @Test public void testRemoveShortArray() { short[] array; @@ -307,7 +307,7 @@ public class ArrayUtilsRemoveTest { fail("IndexOutOfBoundsException expected"); } catch (final IndexOutOfBoundsException e) {} } - + @Test public void testRemoveElementObjectArray() { Object[] array; @@ -326,7 +326,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new Object[] {"b", "a"}, array)); assertEquals(Object.class, array.getClass().getComponentType()); } - + @Test public void testRemoveElementBooleanArray() { boolean[] array; @@ -345,7 +345,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new boolean[] {false, true}, array)); assertEquals(Boolean.TYPE, array.getClass().getComponentType()); } - + @Test public void testRemoveElementByteArray() { byte[] array; @@ -364,7 +364,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new byte[] {2, 1}, array)); assertEquals(Byte.TYPE, array.getClass().getComponentType()); } - + @Test public void testRemoveElementCharArray() { char[] array; @@ -383,7 +383,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new char[] {'b', 'a'}, array)); assertEquals(Character.TYPE, array.getClass().getComponentType()); } - + @Test @SuppressWarnings("cast") public void testRemoveElementDoubleArray() { @@ -403,7 +403,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new double[] {2, 1}, array)); assertEquals(Double.TYPE, array.getClass().getComponentType()); } - + @Test @SuppressWarnings("cast") public void testRemoveElementFloatArray() { @@ -423,7 +423,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new float[] {2, 1}, array)); assertEquals(Float.TYPE, array.getClass().getComponentType()); } - + @Test public void testRemoveElementIntArray() { int[] array; @@ -442,7 +442,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new int[] {2, 1}, array)); assertEquals(Integer.TYPE, array.getClass().getComponentType()); } - + @Test @SuppressWarnings("cast") public void testRemoveElementLongArray() { @@ -462,7 +462,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new long[] {2, 1}, array)); assertEquals(Long.TYPE, array.getClass().getComponentType()); } - + @Test public void testRemoveElementShortArray() { short[] array; @@ -481,7 +481,7 @@ public class ArrayUtilsRemoveTest { assertTrue(Arrays.equals(new short[] {2, 1}, array)); assertEquals(Short.TYPE, array.getClass().getComponentType()); } - + @Test public void testRemoveAllBooleanOccurences() { @@ -524,7 +524,7 @@ public class ArrayUtilsRemoveTest { a = new char[] { '1', '2', '2', '3', '2' }; assertTrue(Arrays.equals(new char[] { '1', '2', '2', '3', '2' }, ArrayUtils.removeAllOccurences(a, '4'))); } - + @Test public void testRemoveAllByteOccurences() { byte[] a = null; @@ -568,7 +568,7 @@ public class ArrayUtilsRemoveTest { } @Test - public void testRemoveAllIntOccurences() { + public void testRemoveAllIntOccurences() { int[] a = null; assertNull(ArrayUtils.removeAllOccurences(a, 2)); @@ -586,10 +586,10 @@ public class ArrayUtilsRemoveTest { a = new int[] { 1, 2, 2, 3, 2 }; assertTrue(Arrays.equals(new int[] { 1, 2, 2, 3, 2 }, ArrayUtils.removeAllOccurences(a, 4))); - } - + } + @Test - public void testRemoveAllLongOccurences() { + public void testRemoveAllLongOccurences() { long[] a = null; assertNull(ArrayUtils.removeAllOccurences(a, 2)); @@ -610,7 +610,7 @@ public class ArrayUtilsRemoveTest { } @Test - public void testRemoveAllFloatOccurences() { + public void testRemoveAllFloatOccurences() { float[] a = null; assertNull(ArrayUtils.removeAllOccurences(a, 2)); @@ -631,7 +631,7 @@ public class ArrayUtilsRemoveTest { } @Test - public void testRemoveAllDoubleOccurences() { + public void testRemoveAllDoubleOccurences() { double[] a = null; assertNull(ArrayUtils.removeAllOccurences(a, 2)); @@ -652,7 +652,7 @@ public class ArrayUtilsRemoveTest { } @Test - public void testRemoveAllObjectOccurences() { + public void testRemoveAllObjectOccurences() { String[] a = null; assertNull(ArrayUtils.removeAllOccurences(a, "2")); diff --git a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java index a2d3a21ed..cffae29d9 100644 --- a/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/ArrayUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -52,7 +52,7 @@ public class ArrayUtilsTest { assertTrue(Modifier.isPublic(ArrayUtils.class.getModifiers())); assertFalse(Modifier.isFinal(ArrayUtils.class.getModifiers())); } - + //----------------------------------------------------------------------- @Test public void testToString() { @@ -61,7 +61,7 @@ public class ArrayUtilsTest { assertEquals("{}", ArrayUtils.toString(new String[0])); assertEquals("{<null>}", ArrayUtils.toString(new String[] {null})); assertEquals("{pink,blue}", ArrayUtils.toString(new String[] {"pink","blue"})); - + assertEquals("<empty>", ArrayUtils.toString(null, "<empty>")); assertEquals("{}", ArrayUtils.toString(new Object[0], "<empty>")); assertEquals("{}", ArrayUtils.toString(new String[0], "<empty>")); @@ -76,12 +76,12 @@ public class ArrayUtilsTest { final long[][] array2 = new long[][] {{2,5}, {4,6}}; assertTrue(ArrayUtils.hashCode(array1) == ArrayUtils.hashCode(array1)); assertFalse(ArrayUtils.hashCode(array1) == ArrayUtils.hashCode(array2)); - + final Object[] array3 = new Object[] {new String(new char[] {'A', 'B'})}; final Object[] array4 = new Object[] {"AB"}; assertTrue(ArrayUtils.hashCode(array3) == ArrayUtils.hashCode(array3)); assertTrue(ArrayUtils.hashCode(array3) == ArrayUtils.hashCode(array4)); - + final Object[] arrayA = new Object[] {new boolean[] {true, false}, new int[] {6, 7}}; final Object[] arrayB = new Object[] {new boolean[] {true, false}, new int[] {6, 7}}; assertTrue(ArrayUtils.hashCode(arrayB) == ArrayUtils.hashCode(arrayA)); @@ -150,7 +150,7 @@ public class ArrayUtilsTest { assertTrue(ArrayUtils.isEquals(null, null)); assertFalse(ArrayUtils.isEquals(null, array4)); } - + //----------------------------------------------------------------------- /** * Tests generic array creation with parameters of same type. @@ -223,15 +223,15 @@ public class ArrayUtilsTest { { return ArrayUtils.toArray(items); } - + //----------------------------------------------------------------------- @Test public void testToMap() { Map<?, ?> map = ArrayUtils.toMap(new String[][] {{"foo", "bar"}, {"hello", "world"}}); - + assertEquals("bar", map.get("foo")); assertEquals("world", map.get("hello")); - + assertEquals(null, ArrayUtils.toMap(null)); try { ArrayUtils.toMap(new String[][] {{"foo", "bar"}, {"short"}}); @@ -245,7 +245,7 @@ public class ArrayUtilsTest { ArrayUtils.toMap(new Object[] {new Object[] {"foo", "bar"}, null}); fail("exception expected"); } catch (final IllegalArgumentException ex) {} - + map = ArrayUtils.toMap(new Object[] {new Map.Entry<Object, Object>() { @Override public Object getKey() { @@ -279,7 +279,7 @@ public class ArrayUtilsTest { Object[] cloned1 = ArrayUtils.clone(original1); assertTrue(Arrays.equals(original1, cloned1)); assertTrue(original1 != cloned1); - + final StringBuilder builder = new StringBuilder("pick"); original1 = new Object[] {builder, "a", new String[] {"stick"}}; cloned1 = ArrayUtils.clone(original1); @@ -298,7 +298,7 @@ public class ArrayUtilsTest { assertTrue(Arrays.equals(original, cloned)); assertTrue(original != cloned); } - + @Test public void testCloneLong() { assertEquals(null, ArrayUtils.clone((long[]) null)); @@ -307,7 +307,7 @@ public class ArrayUtilsTest { assertTrue(Arrays.equals(original, cloned)); assertTrue(original != cloned); } - + @Test public void testCloneInt() { assertEquals(null, ArrayUtils.clone((int[]) null)); @@ -316,7 +316,7 @@ public class ArrayUtilsTest { assertTrue(Arrays.equals(original, cloned)); assertTrue(original != cloned); } - + @Test public void testCloneShort() { assertEquals(null, ArrayUtils.clone((short[]) null)); @@ -325,7 +325,7 @@ public class ArrayUtilsTest { assertTrue(Arrays.equals(original, cloned)); assertTrue(original != cloned); } - + @Test public void testCloneChar() { assertEquals(null, ArrayUtils.clone((char[]) null)); @@ -334,7 +334,7 @@ public class ArrayUtilsTest { assertTrue(Arrays.equals(original, cloned)); assertTrue(original != cloned); } - + @Test public void testCloneByte() { assertEquals(null, ArrayUtils.clone((byte[]) null)); @@ -343,7 +343,7 @@ public class ArrayUtilsTest { assertTrue(Arrays.equals(original, cloned)); assertTrue(original != cloned); } - + @Test public void testCloneDouble() { assertEquals(null, ArrayUtils.clone((double[]) null)); @@ -352,7 +352,7 @@ public class ArrayUtilsTest { assertTrue(Arrays.equals(original, cloned)); assertTrue(original != cloned); } - + @Test public void testCloneFloat() { assertEquals(null, ArrayUtils.clone((float[]) null)); @@ -365,36 +365,36 @@ public class ArrayUtilsTest { //----------------------------------------------------------------------- private class TestClass{} - + @Test public void testNullToEmptyGenericNull() { final TestClass[] output = ArrayUtils.nullToEmpty(null, TestClass[].class); - + assertTrue(output != null); assertTrue(output.length == 0); } - + @Test public void testNullToEmptyGenericEmpty() { final TestClass[] input = new TestClass[]{}; final TestClass[] output = ArrayUtils.nullToEmpty(input, TestClass[].class); - + assertSame(input, output); } - + @Test public void testNullToEmptyGeneric() { final TestClass[] input = new TestClass[]{new TestClass(), new TestClass()}; final TestClass[] output = ArrayUtils.nullToEmpty(input, TestClass[].class); - + assertSame(input, output); } - + @Test(expected=IllegalArgumentException.class) public void testNullToEmptyGenericNullType() { final TestClass[] input = new TestClass[]{}; ArrayUtils.nullToEmpty(input, null); - } + } @Test public void testNullToEmptyBooleanNull() throws Exception { @@ -790,7 +790,7 @@ public class ArrayUtilsTest { StringUtils.join(ArrayUtils.subarray(objectArray, 2, 33))); assertEquals("start undershoot, end overshoot", "abcdef", StringUtils.join(ArrayUtils.subarray(objectArray, -2, 12))); - + // array type tests final Date[] dateArray = { new java.sql.Date(new Date().getTime()), new Date(), new Date(), new Date(), new Date() }; @@ -1431,7 +1431,7 @@ public class ArrayUtilsTest { ArrayUtils.subarray(array, 2, 4).getClass().getComponentType()); } - + //----------------------------------------------------------------------- @Test public void testSameLength() { @@ -1439,22 +1439,22 @@ public class ArrayUtilsTest { final Object[] emptyArray = new Object[0]; final Object[] oneArray = new Object[] {"pick"}; final Object[] twoArray = new Object[] {"pick", "stick"}; - + assertTrue(ArrayUtils.isSameLength(nullArray, nullArray)); assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(nullArray, oneArray)); assertFalse(ArrayUtils.isSameLength(nullArray, twoArray)); - + assertTrue(ArrayUtils.isSameLength(emptyArray, nullArray)); assertTrue(ArrayUtils.isSameLength(emptyArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, oneArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(oneArray, nullArray)); assertFalse(ArrayUtils.isSameLength(oneArray, emptyArray)); assertTrue(ArrayUtils.isSameLength(oneArray, oneArray)); assertFalse(ArrayUtils.isSameLength(oneArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(twoArray, nullArray)); assertFalse(ArrayUtils.isSameLength(twoArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(twoArray, oneArray)); @@ -1467,224 +1467,224 @@ public class ArrayUtilsTest { final boolean[] emptyArray = new boolean[0]; final boolean[] oneArray = new boolean[] {true}; final boolean[] twoArray = new boolean[] {true, false}; - + assertTrue(ArrayUtils.isSameLength(nullArray, nullArray)); assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(nullArray, oneArray)); assertFalse(ArrayUtils.isSameLength(nullArray, twoArray)); - + assertTrue(ArrayUtils.isSameLength(emptyArray, nullArray)); assertTrue(ArrayUtils.isSameLength(emptyArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, oneArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(oneArray, nullArray)); assertFalse(ArrayUtils.isSameLength(oneArray, emptyArray)); assertTrue(ArrayUtils.isSameLength(oneArray, oneArray)); assertFalse(ArrayUtils.isSameLength(oneArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(twoArray, nullArray)); assertFalse(ArrayUtils.isSameLength(twoArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(twoArray, oneArray)); assertTrue(ArrayUtils.isSameLength(twoArray, twoArray)); } - + @Test public void testSameLengthLong() { final long[] nullArray = null; final long[] emptyArray = new long[0]; final long[] oneArray = new long[] {0L}; final long[] twoArray = new long[] {0L, 76L}; - + assertTrue(ArrayUtils.isSameLength(nullArray, nullArray)); assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(nullArray, oneArray)); assertFalse(ArrayUtils.isSameLength(nullArray, twoArray)); - + assertTrue(ArrayUtils.isSameLength(emptyArray, nullArray)); assertTrue(ArrayUtils.isSameLength(emptyArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, oneArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(oneArray, nullArray)); assertFalse(ArrayUtils.isSameLength(oneArray, emptyArray)); assertTrue(ArrayUtils.isSameLength(oneArray, oneArray)); assertFalse(ArrayUtils.isSameLength(oneArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(twoArray, nullArray)); assertFalse(ArrayUtils.isSameLength(twoArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(twoArray, oneArray)); assertTrue(ArrayUtils.isSameLength(twoArray, twoArray)); } - + @Test public void testSameLengthInt() { final int[] nullArray = null; final int[] emptyArray = new int[0]; final int[] oneArray = new int[] {4}; final int[] twoArray = new int[] {5, 7}; - + assertTrue(ArrayUtils.isSameLength(nullArray, nullArray)); assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(nullArray, oneArray)); assertFalse(ArrayUtils.isSameLength(nullArray, twoArray)); - + assertTrue(ArrayUtils.isSameLength(emptyArray, nullArray)); assertTrue(ArrayUtils.isSameLength(emptyArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, oneArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(oneArray, nullArray)); assertFalse(ArrayUtils.isSameLength(oneArray, emptyArray)); assertTrue(ArrayUtils.isSameLength(oneArray, oneArray)); assertFalse(ArrayUtils.isSameLength(oneArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(twoArray, nullArray)); assertFalse(ArrayUtils.isSameLength(twoArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(twoArray, oneArray)); assertTrue(ArrayUtils.isSameLength(twoArray, twoArray)); } - + @Test public void testSameLengthShort() { final short[] nullArray = null; final short[] emptyArray = new short[0]; final short[] oneArray = new short[] {4}; final short[] twoArray = new short[] {6, 8}; - + assertTrue(ArrayUtils.isSameLength(nullArray, nullArray)); assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(nullArray, oneArray)); assertFalse(ArrayUtils.isSameLength(nullArray, twoArray)); - + assertTrue(ArrayUtils.isSameLength(emptyArray, nullArray)); assertTrue(ArrayUtils.isSameLength(emptyArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, oneArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(oneArray, nullArray)); assertFalse(ArrayUtils.isSameLength(oneArray, emptyArray)); assertTrue(ArrayUtils.isSameLength(oneArray, oneArray)); assertFalse(ArrayUtils.isSameLength(oneArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(twoArray, nullArray)); assertFalse(ArrayUtils.isSameLength(twoArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(twoArray, oneArray)); assertTrue(ArrayUtils.isSameLength(twoArray, twoArray)); } - + @Test public void testSameLengthChar() { final char[] nullArray = null; final char[] emptyArray = new char[0]; final char[] oneArray = new char[] {'f'}; final char[] twoArray = new char[] {'d', 't'}; - + assertTrue(ArrayUtils.isSameLength(nullArray, nullArray)); assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(nullArray, oneArray)); assertFalse(ArrayUtils.isSameLength(nullArray, twoArray)); - + assertTrue(ArrayUtils.isSameLength(emptyArray, nullArray)); assertTrue(ArrayUtils.isSameLength(emptyArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, oneArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(oneArray, nullArray)); assertFalse(ArrayUtils.isSameLength(oneArray, emptyArray)); assertTrue(ArrayUtils.isSameLength(oneArray, oneArray)); assertFalse(ArrayUtils.isSameLength(oneArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(twoArray, nullArray)); assertFalse(ArrayUtils.isSameLength(twoArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(twoArray, oneArray)); assertTrue(ArrayUtils.isSameLength(twoArray, twoArray)); } - + @Test public void testSameLengthByte() { final byte[] nullArray = null; final byte[] emptyArray = new byte[0]; final byte[] oneArray = new byte[] {3}; final byte[] twoArray = new byte[] {4, 6}; - + assertTrue(ArrayUtils.isSameLength(nullArray, nullArray)); assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(nullArray, oneArray)); assertFalse(ArrayUtils.isSameLength(nullArray, twoArray)); - + assertTrue(ArrayUtils.isSameLength(emptyArray, nullArray)); assertTrue(ArrayUtils.isSameLength(emptyArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, oneArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(oneArray, nullArray)); assertFalse(ArrayUtils.isSameLength(oneArray, emptyArray)); assertTrue(ArrayUtils.isSameLength(oneArray, oneArray)); assertFalse(ArrayUtils.isSameLength(oneArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(twoArray, nullArray)); assertFalse(ArrayUtils.isSameLength(twoArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(twoArray, oneArray)); assertTrue(ArrayUtils.isSameLength(twoArray, twoArray)); } - + @Test public void testSameLengthDouble() { final double[] nullArray = null; final double[] emptyArray = new double[0]; final double[] oneArray = new double[] {1.3d}; final double[] twoArray = new double[] {4.5d, 6.3d}; - + assertTrue(ArrayUtils.isSameLength(nullArray, nullArray)); assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(nullArray, oneArray)); assertFalse(ArrayUtils.isSameLength(nullArray, twoArray)); - + assertTrue(ArrayUtils.isSameLength(emptyArray, nullArray)); assertTrue(ArrayUtils.isSameLength(emptyArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, oneArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(oneArray, nullArray)); assertFalse(ArrayUtils.isSameLength(oneArray, emptyArray)); assertTrue(ArrayUtils.isSameLength(oneArray, oneArray)); assertFalse(ArrayUtils.isSameLength(oneArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(twoArray, nullArray)); assertFalse(ArrayUtils.isSameLength(twoArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(twoArray, oneArray)); assertTrue(ArrayUtils.isSameLength(twoArray, twoArray)); } - + @Test public void testSameLengthFloat() { final float[] nullArray = null; final float[] emptyArray = new float[0]; final float[] oneArray = new float[] {2.5f}; final float[] twoArray = new float[] {6.4f, 5.8f}; - + assertTrue(ArrayUtils.isSameLength(nullArray, nullArray)); assertTrue(ArrayUtils.isSameLength(nullArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(nullArray, oneArray)); assertFalse(ArrayUtils.isSameLength(nullArray, twoArray)); - + assertTrue(ArrayUtils.isSameLength(emptyArray, nullArray)); assertTrue(ArrayUtils.isSameLength(emptyArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, oneArray)); assertFalse(ArrayUtils.isSameLength(emptyArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(oneArray, nullArray)); assertFalse(ArrayUtils.isSameLength(oneArray, emptyArray)); assertTrue(ArrayUtils.isSameLength(oneArray, oneArray)); assertFalse(ArrayUtils.isSameLength(oneArray, twoArray)); - + assertFalse(ArrayUtils.isSameLength(twoArray, nullArray)); assertFalse(ArrayUtils.isSameLength(twoArray, emptyArray)); assertFalse(ArrayUtils.isSameLength(twoArray, oneArray)); assertTrue(ArrayUtils.isSameLength(twoArray, twoArray)); } - + //----------------------------------------------------------------------- @Test public void testSameType() { @@ -1700,14 +1700,14 @@ public class ArrayUtilsTest { ArrayUtils.isSameType(new Object[0], null); fail(); } catch (final IllegalArgumentException ex) {} - + assertTrue(ArrayUtils.isSameType(new Object[0], new Object[0])); assertFalse(ArrayUtils.isSameType(new String[0], new Object[0])); assertTrue(ArrayUtils.isSameType(new String[0][0], new String[0][0])); assertFalse(ArrayUtils.isSameType(new String[0], new String[0][0])); assertFalse(ArrayUtils.isSameType(new String[0][0], new String[0])); } - + //----------------------------------------------------------------------- @Test public void testReverse() { @@ -1715,13 +1715,13 @@ public class ArrayUtilsTest { final String str2 = "a"; final String[] str3 = new String[] {"stick"}; final String str4 = "up"; - + Object[] array = new Object[] {str1, str2, str3}; ArrayUtils.reverse(array); assertEquals(array[0], str3); assertEquals(array[1], str2); assertEquals(array[2], str1); - + array = new Object[] {str1, str2, str3, str4}; ArrayUtils.reverse(array); assertEquals(array[0], str4); @@ -1746,7 +1746,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array); assertEquals(null, array); } - + @Test public void testReverseInt() { int[] array = new int[] {1, 2, 3}; @@ -1759,7 +1759,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array); assertEquals(null, array); } - + @Test public void testReverseShort() { short[] array = new short[] {1, 2, 3}; @@ -1772,7 +1772,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array); assertEquals(null, array); } - + @Test public void testReverseChar() { char[] array = new char[] {'a', 'f', 'C'}; @@ -1785,7 +1785,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array); assertEquals(null, array); } - + @Test public void testReverseByte() { byte[] array = new byte[] {2, 3, 4}; @@ -1798,7 +1798,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array); assertEquals(null, array); } - + @Test public void testReverseDouble() { double[] array = new double[] {0.3d, 0.4d, 0.5d}; @@ -1811,7 +1811,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array); assertEquals(null, array); } - + @Test public void testReverseFloat() { float[] array = new float[] {0.3f, 0.4f, 0.5f}; @@ -1824,7 +1824,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array); assertEquals(null, array); } - + @Test public void testReverseBoolean() { boolean[] array = new boolean[] {false, false, true}; @@ -1837,7 +1837,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array); assertEquals(null, array); } - + @Test public void testReverseBooleanRange() { boolean[] array = new boolean[] {false, false, true}; @@ -1869,7 +1869,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array, 0, 3); assertEquals(null, array); } - + @Test public void testReverseByteRange() { byte[] array = new byte[] {1, 2, 3}; @@ -1901,7 +1901,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array, 0, 3); assertEquals(null, array); } - + @Test public void testReverseCharRange() { char[] array = new char[] {1, 2, 3}; @@ -1933,7 +1933,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array, 0, 3); assertEquals(null, array); } - + @Test public void testReverseDoubleRange() { double[] array = new double[] {1, 2, 3}; @@ -1965,7 +1965,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array, 0, 3); assertEquals(null, array); } - + @Test public void testReverseFloatRange() { float[] array = new float[] {1, 2, 3}; @@ -1997,7 +1997,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array, 0, 3); assertEquals(null, array); } - + @Test public void testReverseIntRange() { int[] array = new int[] {1, 2, 3}; @@ -2029,7 +2029,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array, 0, 3); assertEquals(null, array); } - + @Test public void testReverseLongRange() { long[] array = new long[] {1, 2, 3}; @@ -2061,7 +2061,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array, 0, 3); assertEquals(null, array); } - + @Test public void testReverseShortRange() { short[] array = new short[] {1, 2, 3}; @@ -2093,7 +2093,7 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array, 0, 3); assertEquals(null, array); } - + @Test public void testReverseObjectRange() { String[] array = new String[] {"1", "2", "3"}; @@ -2125,23 +2125,23 @@ public class ArrayUtilsTest { ArrayUtils.reverse(array, 0, 3); assertEquals(null, array); } - + //----------------------------------------------------------------------- @Test public void testSwapChar() { char[] array = new char[] {1, 2, 3}; ArrayUtils.swap(array, 0, 2); assertArrayEquals(new char[] {3, 2, 1}, array); - + array = new char[] {1, 2, 3}; ArrayUtils.swap(array, 0, 0); assertArrayEquals(new char[] {1, 2, 3}, array); - + array = new char[] {1, 2, 3}; ArrayUtils.swap(array, 1, 0); assertArrayEquals(new char[] {2, 1, 3}, array); } - + @Test public void testSwapCharRange() { char[] array = new char[] {1, 2, 3, 4}; @@ -2156,32 +2156,32 @@ public class ArrayUtilsTest { assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); - + array = new char[] {1, 2, 3}; ArrayUtils.swap(array, 0, 2, 2); assertEquals(3, array[0]); assertEquals(2, array[1]); assertEquals(1, array[2]); - + array = new char[] {1, 2, 3}; ArrayUtils.swap(array, -1, 2, 2); assertEquals(3, array[0]); assertEquals(2, array[1]); assertEquals(1, array[2]); - + array = new char[] {1, 2, 3}; ArrayUtils.swap(array, 0, -1, 2); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); - + array = new char[] {1, 2, 3}; ArrayUtils.swap(array, -1, -1, 2); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); } - + @Test public void testSwapByte() { final byte[] array = new byte[] {1, 2, 3}; @@ -2190,21 +2190,21 @@ public class ArrayUtilsTest { assertEquals(2, array[1]); assertEquals(1, array[2]); } - + @Test public void testSwapNullByteArray() { final byte[] array = null; ArrayUtils.swap(array, 0, 2); assertNull(array); } - + @Test public void testSwapEmptyByteArray() { final byte[] array = new byte[0]; ArrayUtils.swap(array, 0, 2); assertEquals(0, array.length); } - + @Test public void testSwapByteRange() { byte[] array = new byte[] {1, 2, 3, 4}; @@ -2213,38 +2213,38 @@ public class ArrayUtilsTest { assertEquals(4, array[1]); assertEquals(1, array[2]); assertEquals(2, array[3]); - + array = new byte[] {1, 2, 3}; ArrayUtils.swap(array, 0, 3); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); - + array = new byte[] {1, 2, 3}; ArrayUtils.swap(array, 0, 2, 2); assertEquals(3, array[0]); assertEquals(2, array[1]); assertEquals(1, array[2]); - + array = new byte[] {1, 2, 3}; ArrayUtils.swap(array, -1, 2, 2); assertEquals(3, array[0]); assertEquals(2, array[1]); assertEquals(1, array[2]); - + array = new byte[] {1, 2, 3}; ArrayUtils.swap(array, 0, -1, 2); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); - + array = new byte[] {1, 2, 3}; ArrayUtils.swap(array, -1, -1, 2); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); } - + @Test public void testSwapFloat() { final float[] array = new float[] {1, 2, 3}; @@ -2253,14 +2253,14 @@ public class ArrayUtilsTest { assertEquals(2, array[1], 0); assertEquals(1, array[2], 0); } - + @Test public void testSwapNullFloatArray() { final float[] array = null; ArrayUtils.swap(array, 0, 2); assertNull(array); } - + @Test public void testSwapEmptyFloatArray() { final float[] array = new float[0]; @@ -2282,32 +2282,32 @@ public class ArrayUtilsTest { assertEquals(1, array[0], 0); assertEquals(2, array[1], 0); assertEquals(3, array[2], 0); - + array = new float[] {1, 2, 3}; ArrayUtils.swap(array, 0, 2, 2); assertEquals(3, array[0], 0); assertEquals(2, array[1], 0); assertEquals(1, array[2], 0); - + array = new float[] {1, 2, 3}; ArrayUtils.swap(array, -1, 2, 2); assertEquals(3, array[0], 0); assertEquals(2, array[1], 0); assertEquals(1, array[2], 0); - + array = new float[] {1, 2, 3}; ArrayUtils.swap(array, 0, -1, 2); assertEquals(1, array[0], 0); assertEquals(2, array[1], 0); assertEquals(3, array[2], 0); - + array = new float[] {1, 2, 3}; ArrayUtils.swap(array, -1, -1, 2); assertEquals(1, array[0], 0); assertEquals(2, array[1], 0); assertEquals(3, array[2], 0); } - + @Test public void testSwapDouble() { final double[] array = new double[] {1, 2, 3}; @@ -2316,14 +2316,14 @@ public class ArrayUtilsTest { assertEquals(2, array[1], 0); assertEquals(1, array[2], 0); } - + @Test public void testSwapNullDoubleArray() { final double[] array = null; ArrayUtils.swap(array, 0, 2); assertNull(array); } - + @Test public void testSwapEmptyDoubleArray() { final double[] array = new double[0]; @@ -2345,32 +2345,32 @@ public class ArrayUtilsTest { assertEquals(1, array[0], 0); assertEquals(2, array[1], 0); assertEquals(3, array[2], 0); - + array = new double[] {1, 2, 3}; ArrayUtils.swap(array, 0, 2, 2); assertEquals(3, array[0], 0); assertEquals(2, array[1], 0); assertEquals(1, array[2], 0); - + array = new double[] {1, 2, 3}; ArrayUtils.swap(array, -1, 2, 2); assertEquals(3, array[0], 0); assertEquals(2, array[1], 0); assertEquals(1, array[2], 0); - + array = new double[] {1, 2, 3}; ArrayUtils.swap(array, 0, -1, 2); assertEquals(1, array[0], 0); assertEquals(2, array[1], 0); assertEquals(3, array[2], 0); - + array = new double[] {1, 2, 3}; ArrayUtils.swap(array, -1, -1, 2); assertEquals(1, array[0], 0); assertEquals(2, array[1], 0); assertEquals(3, array[2], 0); } - + @Test public void testSwapInt() { final int[] array = new int[] {1, 2, 3}; @@ -2379,14 +2379,14 @@ public class ArrayUtilsTest { assertEquals(2, array[1]); assertEquals(1, array[2]); } - + @Test public void testSwapNullIntArray() { final int[] array = null; ArrayUtils.swap(array, 0, 2); assertNull(array); } - + @Test public void testSwapEmptyIntArray() { final int[] array = new int[0]; @@ -2402,50 +2402,50 @@ public class ArrayUtilsTest { assertEquals(4, array[1]); assertEquals(1, array[2]); assertEquals(2, array[3]); - + array = new int[] {1, 2, 3}; ArrayUtils.swap(array, 3, 0); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); - + array = new int[] {1, 2, 3}; ArrayUtils.swap(array, 0, 2, 2); assertEquals(3, array[0]); assertEquals(2, array[1]); assertEquals(1, array[2]); - + array = new int[] {1, 2, 3}; ArrayUtils.swap(array, -1, 2, 2); assertEquals(3, array[0]); assertEquals(2, array[1]); assertEquals(1, array[2]); - + array = new int[] {1, 2, 3}; ArrayUtils.swap(array, 0, -1, 2); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); - + array = new int[] {1, 2, 3}; ArrayUtils.swap(array, -1, -1, 2); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); } - + @Test public void testSwapIntExchangedOffsets() { int[] array; array = new int[] {1, 2, 3}; ArrayUtils.swap(array, 0, 1, 2); assertArrayEquals(new int[] {2, 3, 1}, array); - + array = new int[] {1, 2, 3}; ArrayUtils.swap(array, 1, 0, 2); assertArrayEquals(new int[] {2, 3, 1}, array); } - + @Test public void testSwapShort() { final short[] array = new short[] {1, 2, 3}; @@ -2454,21 +2454,21 @@ public class ArrayUtilsTest { assertEquals(2, array[1]); assertEquals(1, array[2]); } - + @Test public void testSwapNullShortArray() { final short[] array = null; ArrayUtils.swap(array, 0, 2); assertNull(array); } - + @Test public void testSwapEmptyShortArray() { final short[] array = new short[0]; ArrayUtils.swap(array, 0, 2); assertEquals(0, array.length); } - + @Test public void testSwapShortRange() { short[] array = new short[] {1, 2, 3, 4}; @@ -2477,45 +2477,45 @@ public class ArrayUtilsTest { assertEquals(4, array[1]); assertEquals(1, array[2]); assertEquals(2, array[3]); - + array = new short[] {1, 2, 3}; ArrayUtils.swap(array, 3, 0); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); - + array = new short[] {1, 2, 3}; ArrayUtils.swap(array, 0, 2, 2); assertEquals(3, array[0]); assertEquals(2, array[1]); assertEquals(1, array[2]); - + array = new short[] {1, 2, 3}; ArrayUtils.swap(array, -1, 2, 2); assertEquals(3, array[0]); assertEquals(2, array[1]); assertEquals(1, array[2]); - + array = new short[] {1, 2, 3}; ArrayUtils.swap(array, 0, -1, 2); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); - + array = new short[] {1, 2, 3}; ArrayUtils.swap(array, -1, -1, 2); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); } - + @Test public void testSwapNullCharArray() { final char[] array = null; ArrayUtils.swap(array, 0, 2); assertNull(array); } - + @Test public void testSwapEmptyCharArray() { final char[] array = new char[0]; @@ -2531,14 +2531,14 @@ public class ArrayUtilsTest { assertEquals(2, array[1]); assertEquals(1, array[2]); } - + @Test public void testSwapNullLongArray() { final long[] array = null; ArrayUtils.swap(array, 0, 2); assertNull(array); } - + @Test public void testSwapEmptyLongArray() { final long[] array = new long[0]; @@ -2554,38 +2554,38 @@ public class ArrayUtilsTest { assertEquals(4, array[1]); assertEquals(1, array[2]); assertEquals(2, array[3]); - + array = new long[] {1, 2, 3}; ArrayUtils.swap(array, 0, 3); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); - + array = new long[] {1, 2, 3}; ArrayUtils.swap(array, 0, 2, 2); assertEquals(3, array[0]); assertEquals(2, array[1]); assertEquals(1, array[2]); - + array = new long[] {1, 2, 3}; ArrayUtils.swap(array, -1, 2, 2); assertEquals(3, array[0]); assertEquals(2, array[1]); assertEquals(1, array[2]); - + array = new long[] {1, 2, 3}; ArrayUtils.swap(array, 0, -1, 2); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); - + array = new long[] {1, 2, 3}; ArrayUtils.swap(array, -1, -1, 2); assertEquals(1, array[0]); assertEquals(2, array[1]); assertEquals(3, array[2]); } - + @Test public void testSwapBoolean() { final boolean[] array = new boolean[] {true, false, false}; @@ -2594,21 +2594,21 @@ public class ArrayUtilsTest { assertFalse(array[1]); assertTrue(array[2]); } - + @Test public void testSwapNullBooleanArray() { final boolean[] array = null; ArrayUtils.swap(array, 0, 2); assertNull(array); } - + @Test public void testSwapEmptyBooleanArray() { final boolean[] array = new boolean[0]; ArrayUtils.swap(array, 0, 2); assertEquals(0, array.length); } - + @Test public void testSwapBooleanRange() { boolean[] array = new boolean[] {false, false, true, true}; @@ -2617,31 +2617,31 @@ public class ArrayUtilsTest { assertTrue(array[1]); assertFalse(array[2]); assertFalse(array[3]); - + array = new boolean[] {false, true, false}; ArrayUtils.swap(array, 0, 3); assertFalse(array[0]); assertTrue(array[1]); assertFalse(array[2]); - + array = new boolean[] {true, true, false}; ArrayUtils.swap(array, 0, 2, 2); assertFalse(array[0]); assertTrue(array[1]); assertTrue(array[2]); - + array = new boolean[] {true, true, false}; ArrayUtils.swap(array, -1, 2, 2); assertFalse(array[0]); assertTrue(array[1]); assertTrue(array[2]); - + array = new boolean[] {true, true, false}; ArrayUtils.swap(array, 0, -1, 2); assertTrue(array[0]); assertTrue(array[1]); assertFalse(array[2]); - + array = new boolean[] {true, true, false}; ArrayUtils.swap(array, -1, -1, 2); assertTrue(array[0]); @@ -2657,14 +2657,14 @@ public class ArrayUtilsTest { assertEquals("2", array[1]); assertEquals("1", array[2]); } - + @Test public void testSwapNullObjectArray() { final String[] array = null; ArrayUtils.swap(array, 0, 2); assertNull(array); } - + @Test public void testSwapEmptyObjectArray() { final String[] array = new String[0]; @@ -2695,7 +2695,7 @@ public class ArrayUtilsTest { assertEquals("5", array[2]); assertEquals("2", array[3]); assertEquals("1", array[4]); - + array = new String[] {"1", "2", "3", "4", "5"}; ArrayUtils.swap(array, 2, -2, 3); assertEquals("3", array[0]); @@ -2703,11 +2703,11 @@ public class ArrayUtilsTest { assertEquals("5", array[2]); assertEquals("2", array[3]); assertEquals("1", array[4]); - + array = new String[0]; ArrayUtils.swap(array, 0, 2, 2); assertEquals(0, array.length); - + array = null; ArrayUtils.swap(array, 0, 2, 2); assertNull(array); @@ -2765,18 +2765,18 @@ public class ArrayUtilsTest { assertEquals(3, array[2], 0); assertEquals(4, array[3], 0); } - + @Test public void testShiftRangeNullDouble() { final double[] array = null; ArrayUtils.shift(array, 1, 1, 1); assertNull(array); } - + @Test public void testShiftNullDouble() { final double[] array = null; - + ArrayUtils.shift(array, 1); assertNull(array); } @@ -2795,7 +2795,7 @@ public class ArrayUtilsTest { assertEquals(3, array[2], 0); assertEquals(4, array[3], 0); } - + @Test public void testShiftFloat() { final float[] array = new float[] {1, 2, 3, 4}; @@ -2847,18 +2847,18 @@ public class ArrayUtilsTest { assertEquals(3, array[2], 0); assertEquals(4, array[3], 0); } - + @Test public void testShiftRangeNullFloat() { final float[] array = null; ArrayUtils.shift(array, 1, 1, 1); assertNull(array); } - + @Test public void testShiftNullFloat() { final float[] array = null; - + ArrayUtils.shift(array, 1); assertNull(array); } @@ -2877,7 +2877,7 @@ public class ArrayUtilsTest { assertEquals(3, array[2], 0); assertEquals(4, array[3], 0); } - + @Test public void testShiftShort() { short[] array = new short[] {1, 2, 3, 4}; @@ -2909,11 +2909,11 @@ public class ArrayUtilsTest { assertEquals(2, array[3]); assertEquals(3, array[4]); } - + @Test public void testShiftNullShort() { final short[] array = null; - + ArrayUtils.shift(array, 1); assertNull(array); } @@ -2944,11 +2944,11 @@ public class ArrayUtilsTest { assertEquals(3, array[2]); assertEquals(4, array[3]); } - + @Test public void testShiftRangeNullShort() { final short[] array = null; - + ArrayUtils.shift(array, 1, 1, 1); assertNull(array); } @@ -2967,7 +2967,7 @@ public class ArrayUtilsTest { assertEquals(3, array[2]); assertEquals(4, array[3]); } - + @Test public void testShiftByte() { final byte[] array = new byte[] {1, 2, 3, 4}; @@ -3019,7 +3019,7 @@ public class ArrayUtilsTest { assertEquals(3, array[2]); assertEquals(4, array[3]); } - + @Test public void testShiftRangeNullByte() { final byte[] array = null; @@ -3041,7 +3041,7 @@ public class ArrayUtilsTest { assertEquals(3, array[2]); assertEquals(4, array[3]); } - + @Test public void testShiftChar() { final char[] array = new char[] {1, 2, 3, 4}; @@ -3093,7 +3093,7 @@ public class ArrayUtilsTest { assertEquals(3, array[2]); assertEquals(4, array[3]); } - + @Test public void testShiftRangeNullChar() { final char[] array = null; @@ -3115,7 +3115,7 @@ public class ArrayUtilsTest { assertEquals(3, array[2]); assertEquals(4, array[3]); } - + @Test public void testShiftLong() { final long[] array = new long[] {1, 2, 3, 4}; @@ -3167,18 +3167,18 @@ public class ArrayUtilsTest { assertEquals(3, array[2]); assertEquals(4, array[3]); } - + @Test public void testShiftRangeNullLong() { final long[] array = null; ArrayUtils.shift(array, 1, 1, 1); assertNull(array); } - + @Test public void testShiftNullLong() { final long[] array = null; - + ArrayUtils.shift(array, 1); assertNull(array); } @@ -3197,7 +3197,7 @@ public class ArrayUtilsTest { assertEquals(3, array[2]); assertEquals(4, array[3]); } - + @Test public void testShiftInt() { final int[] array = new int[] {1, 2, 3, 4}; @@ -3222,11 +3222,11 @@ public class ArrayUtilsTest { assertEquals(1, array[2]); assertEquals(2, array[3]); } - + @Test public void testShiftNullInt() { final int[] array = null; - + ArrayUtils.shift(array, 1); assertNull(array); } @@ -3257,7 +3257,7 @@ public class ArrayUtilsTest { assertEquals(3, array[2]); assertEquals(4, array[3]); } - + @Test public void testShiftRangeNullInt() { final int[] array = null; @@ -3304,11 +3304,11 @@ public class ArrayUtilsTest { assertEquals("1", array[2]); assertEquals("2", array[3]); } - + @Test public void testShiftNullObject() { final String[] array = null; - + ArrayUtils.shift(array, 1); assertNull(array); } @@ -3339,7 +3339,7 @@ public class ArrayUtilsTest { assertEquals("3", array[2]); assertEquals("4", array[3]); } - + @Test public void testShiftRangeNullObject() { final String[] array = null; @@ -3361,44 +3361,44 @@ public class ArrayUtilsTest { assertEquals("3", array[2]); assertEquals("4", array[3]); } - + @Test public void testShiftBoolean() { final boolean[] array = new boolean[] {true, true, false, false}; - + ArrayUtils.shift(array, 1); assertFalse(array[0]); assertTrue(array[1]); assertTrue(array[2]); assertFalse(array[3]); - + ArrayUtils.shift(array, -1); assertTrue(array[0]); assertTrue(array[1]); assertFalse(array[2]); assertFalse(array[3]); - + ArrayUtils.shift(array, 5); assertFalse(array[0]); assertTrue(array[1]); assertTrue(array[2]); assertFalse(array[3]); - + ArrayUtils.shift(array, -3); assertFalse(array[0]); assertFalse(array[1]); assertTrue(array[2]); assertTrue(array[3]); } - + @Test public void testShiftNullBoolean() { final boolean[] array = null; - + ArrayUtils.shift(array, 1); assertNull(array); } - + //----------------------------------------------------------------------- @Test public void testIndexOf() { @@ -3426,7 +3426,7 @@ public class ArrayUtilsTest { assertEquals(3, ArrayUtils.indexOf(array, "3", 2)); assertEquals(4, ArrayUtils.indexOf(array, null, 2)); assertEquals(-1, ArrayUtils.indexOf(array, "notInArray", 2)); - + assertEquals(4, ArrayUtils.indexOf(array, null, -1)); assertEquals(-1, ArrayUtils.indexOf(array, null, 8)); assertEquals(-1, ArrayUtils.indexOf(array, "0", 8)); @@ -3458,7 +3458,7 @@ public class ArrayUtilsTest { assertEquals(4, ArrayUtils.lastIndexOf(array, null, 5)); assertEquals(-1, ArrayUtils.lastIndexOf(array, null, 2)); assertEquals(-1, ArrayUtils.lastIndexOf(array, "notInArray", 5)); - + assertEquals(-1, ArrayUtils.lastIndexOf(array, null, -1)); assertEquals(5, ArrayUtils.lastIndexOf(array, "0", 88)); } @@ -3556,7 +3556,7 @@ public class ArrayUtilsTest { assertTrue(ArrayUtils.contains(array, 3)); assertFalse(ArrayUtils.contains(array, 99)); } - + //----------------------------------------------------------------------- @Test public void testIndexOfInt() { @@ -3621,7 +3621,7 @@ public class ArrayUtilsTest { assertTrue(ArrayUtils.contains(array, 3)); assertFalse(ArrayUtils.contains(array, 99)); } - + //----------------------------------------------------------------------- @Test public void testIndexOfShort() { @@ -3686,7 +3686,7 @@ public class ArrayUtilsTest { assertTrue(ArrayUtils.contains(array, (short) 3)); assertFalse(ArrayUtils.contains(array, (short) 99)); } - + //----------------------------------------------------------------------- @Test public void testIndexOfChar() { @@ -3751,7 +3751,7 @@ public class ArrayUtilsTest { assertTrue(ArrayUtils.contains(array, 'd')); assertFalse(ArrayUtils.contains(array, 'e')); } - + //----------------------------------------------------------------------- @Test public void testIndexOfByte() { @@ -3816,7 +3816,7 @@ public class ArrayUtilsTest { assertTrue(ArrayUtils.contains(array, (byte) 3)); assertFalse(ArrayUtils.contains(array, (byte) 99)); } - + //----------------------------------------------------------------------- @SuppressWarnings("cast") @Test @@ -3863,7 +3863,7 @@ public class ArrayUtilsTest { assertEquals(-1, ArrayUtils.indexOf(array, (double) 99, 0)); assertEquals(-1, ArrayUtils.indexOf(array, (double) 0, 6)); } - + @SuppressWarnings("cast") @Test public void testIndexOfDoubleWithStartIndexTolerance() { @@ -3970,7 +3970,7 @@ public class ArrayUtilsTest { assertTrue(ArrayUtils.contains(array, 2.5, 0.50)); assertTrue(ArrayUtils.contains(array, 2.5, 0.51)); } - + //----------------------------------------------------------------------- @SuppressWarnings("cast") @Test @@ -4048,7 +4048,7 @@ public class ArrayUtilsTest { assertTrue(ArrayUtils.contains(array, (float) 3)); assertFalse(ArrayUtils.contains(array, (float) 99)); } - + //----------------------------------------------------------------------- @Test public void testIndexOfBoolean() { @@ -4119,7 +4119,7 @@ public class ArrayUtilsTest { assertTrue(ArrayUtils.contains(array, true)); assertFalse(ArrayUtils.contains(array, false)); } - + // testToPrimitive/Object for boolean // ----------------------------------------------------------------------- @Test @@ -4173,12 +4173,12 @@ public class ArrayUtilsTest { public void testToPrimitive_char() { final Character[] b = null; assertEquals(null, ArrayUtils.toPrimitive(b)); - + assertSame(ArrayUtils.EMPTY_CHAR_ARRAY, ArrayUtils.toPrimitive(new Character[0])); - + assertTrue(Arrays.equals( new char[] {Character.MIN_VALUE, Character.MAX_VALUE, '0'}, - ArrayUtils.toPrimitive(new Character[] {new Character(Character.MIN_VALUE), + ArrayUtils.toPrimitive(new Character[] {new Character(Character.MIN_VALUE), new Character(Character.MAX_VALUE), new Character('0')})) ); @@ -4192,20 +4192,20 @@ public class ArrayUtilsTest { public void testToPrimitive_char_char() { final Character[] b = null; assertEquals(null, ArrayUtils.toPrimitive(b, Character.MIN_VALUE)); - - assertSame(ArrayUtils.EMPTY_CHAR_ARRAY, + + assertSame(ArrayUtils.EMPTY_CHAR_ARRAY, ArrayUtils.toPrimitive(new Character[0], (char)0)); - + assertTrue(Arrays.equals( new char[] {Character.MIN_VALUE, Character.MAX_VALUE, '0'}, - ArrayUtils.toPrimitive(new Character[] {new Character(Character.MIN_VALUE), - new Character(Character.MAX_VALUE), new Character('0')}, + ArrayUtils.toPrimitive(new Character[] {new Character(Character.MIN_VALUE), + new Character(Character.MAX_VALUE), new Character('0')}, Character.MIN_VALUE)) ); - + assertTrue(Arrays.equals( new char[] {Character.MIN_VALUE, Character.MAX_VALUE, '0'}, - ArrayUtils.toPrimitive(new Character[] {new Character(Character.MIN_VALUE), null, + ArrayUtils.toPrimitive(new Character[] {new Character(Character.MIN_VALUE), null, new Character('0')}, Character.MAX_VALUE)) ); } @@ -4214,30 +4214,30 @@ public class ArrayUtilsTest { public void testToObject_char() { final char[] b = null; assertArrayEquals(null, ArrayUtils.toObject(b)); - - assertSame(ArrayUtils.EMPTY_CHARACTER_OBJECT_ARRAY, + + assertSame(ArrayUtils.EMPTY_CHARACTER_OBJECT_ARRAY, ArrayUtils.toObject(new char[0])); - + assertTrue(Arrays.equals( - new Character[] {new Character(Character.MIN_VALUE), + new Character[] {new Character(Character.MIN_VALUE), new Character(Character.MAX_VALUE), new Character('0')}, - ArrayUtils.toObject(new char[] {Character.MIN_VALUE, Character.MAX_VALUE, + ArrayUtils.toObject(new char[] {Character.MIN_VALUE, Character.MAX_VALUE, '0'} )) ); } - + // testToPrimitive/Object for byte // ----------------------------------------------------------------------- @Test public void testToPrimitive_byte() { final Byte[] b = null; assertEquals(null, ArrayUtils.toPrimitive(b)); - + assertSame(ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.toPrimitive(new Byte[0])); - + assertTrue(Arrays.equals( new byte[] {Byte.MIN_VALUE, Byte.MAX_VALUE, (byte)9999999}, - ArrayUtils.toPrimitive(new Byte[] {Byte.valueOf(Byte.MIN_VALUE), + ArrayUtils.toPrimitive(new Byte[] {Byte.valueOf(Byte.MIN_VALUE), Byte.valueOf(Byte.MAX_VALUE), Byte.valueOf((byte)9999999)})) ); @@ -4251,20 +4251,20 @@ public class ArrayUtilsTest { public void testToPrimitive_byte_byte() { final Byte[] b = null; assertEquals(null, ArrayUtils.toPrimitive(b, Byte.MIN_VALUE)); - - assertSame(ArrayUtils.EMPTY_BYTE_ARRAY, + + assertSame(ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.toPrimitive(new Byte[0], (byte)1)); - + assertTrue(Arrays.equals( new byte[] {Byte.MIN_VALUE, Byte.MAX_VALUE, (byte)9999999}, - ArrayUtils.toPrimitive(new Byte[] {Byte.valueOf(Byte.MIN_VALUE), - Byte.valueOf(Byte.MAX_VALUE), Byte.valueOf((byte)9999999)}, + ArrayUtils.toPrimitive(new Byte[] {Byte.valueOf(Byte.MIN_VALUE), + Byte.valueOf(Byte.MAX_VALUE), Byte.valueOf((byte)9999999)}, Byte.MIN_VALUE)) ); - + assertTrue(Arrays.equals( new byte[] {Byte.MIN_VALUE, Byte.MAX_VALUE, (byte)9999999}, - ArrayUtils.toPrimitive(new Byte[] {Byte.valueOf(Byte.MIN_VALUE), null, + ArrayUtils.toPrimitive(new Byte[] {Byte.valueOf(Byte.MIN_VALUE), null, Byte.valueOf((byte)9999999)}, Byte.MAX_VALUE)) ); } @@ -4273,14 +4273,14 @@ public class ArrayUtilsTest { public void testToObject_byte() { final byte[] b = null; assertArrayEquals(null, ArrayUtils.toObject(b)); - - assertSame(ArrayUtils.EMPTY_BYTE_OBJECT_ARRAY, + + assertSame(ArrayUtils.EMPTY_BYTE_OBJECT_ARRAY, ArrayUtils.toObject(new byte[0])); - + assertTrue(Arrays.equals( - new Byte[] {Byte.valueOf(Byte.MIN_VALUE), + new Byte[] {Byte.valueOf(Byte.MIN_VALUE), Byte.valueOf(Byte.MAX_VALUE), Byte.valueOf((byte)9999999)}, - ArrayUtils.toObject(new byte[] {Byte.MIN_VALUE, Byte.MAX_VALUE, + ArrayUtils.toObject(new byte[] {Byte.MIN_VALUE, Byte.MAX_VALUE, (byte)9999999})) ); } @@ -4291,12 +4291,12 @@ public class ArrayUtilsTest { public void testToPrimitive_short() { final Short[] b = null; assertEquals(null, ArrayUtils.toPrimitive(b)); - + assertSame(ArrayUtils.EMPTY_SHORT_ARRAY, ArrayUtils.toPrimitive(new Short[0])); - + assertTrue(Arrays.equals( new short[] {Short.MIN_VALUE, Short.MAX_VALUE, (short)9999999}, - ArrayUtils.toPrimitive(new Short[] {Short.valueOf(Short.MIN_VALUE), + ArrayUtils.toPrimitive(new Short[] {Short.valueOf(Short.MIN_VALUE), Short.valueOf(Short.MAX_VALUE), Short.valueOf((short)9999999)})) ); @@ -4310,19 +4310,19 @@ public class ArrayUtilsTest { public void testToPrimitive_short_short() { final Short[] s = null; assertEquals(null, ArrayUtils.toPrimitive(s, Short.MIN_VALUE)); - - assertSame(ArrayUtils.EMPTY_SHORT_ARRAY, ArrayUtils.toPrimitive(new Short[0], + + assertSame(ArrayUtils.EMPTY_SHORT_ARRAY, ArrayUtils.toPrimitive(new Short[0], Short.MIN_VALUE)); - + assertTrue(Arrays.equals( new short[] {Short.MIN_VALUE, Short.MAX_VALUE, (short)9999999}, - ArrayUtils.toPrimitive(new Short[] {Short.valueOf(Short.MIN_VALUE), + ArrayUtils.toPrimitive(new Short[] {Short.valueOf(Short.MIN_VALUE), Short.valueOf(Short.MAX_VALUE), Short.valueOf((short)9999999)}, Short.MIN_VALUE)) ); - + assertTrue(Arrays.equals( new short[] {Short.MIN_VALUE, Short.MAX_VALUE, (short)9999999}, - ArrayUtils.toPrimitive(new Short[] {Short.valueOf(Short.MIN_VALUE), null, + ArrayUtils.toPrimitive(new Short[] {Short.valueOf(Short.MIN_VALUE), null, Short.valueOf((short)9999999)}, Short.MAX_VALUE)) ); } @@ -4331,14 +4331,14 @@ public class ArrayUtilsTest { public void testToObject_short() { final short[] b = null; assertArrayEquals(null, ArrayUtils.toObject(b)); - - assertSame(ArrayUtils.EMPTY_SHORT_OBJECT_ARRAY, + + assertSame(ArrayUtils.EMPTY_SHORT_OBJECT_ARRAY, ArrayUtils.toObject(new short[0])); - + assertTrue(Arrays.equals( - new Short[] {Short.valueOf(Short.MIN_VALUE), Short.valueOf(Short.MAX_VALUE), + new Short[] {Short.valueOf(Short.MIN_VALUE), Short.valueOf(Short.MAX_VALUE), Short.valueOf((short)9999999)}, - ArrayUtils.toObject(new short[] {Short.MIN_VALUE, Short.MAX_VALUE, + ArrayUtils.toObject(new short[] {Short.MIN_VALUE, Short.MAX_VALUE, (short)9999999})) ); } @@ -4352,7 +4352,7 @@ public class ArrayUtilsTest { assertSame(ArrayUtils.EMPTY_INT_ARRAY, ArrayUtils.toPrimitive(new Integer[0])); assertTrue(Arrays.equals( new int[] {Integer.MIN_VALUE, Integer.MAX_VALUE, 9999999}, - ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE), + ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE), Integer.valueOf(Integer.MAX_VALUE), Integer.valueOf(9999999)})) ); @@ -4366,19 +4366,19 @@ public class ArrayUtilsTest { public void testToPrimitive_int_int() { final Long[] l = null; assertEquals(null, ArrayUtils.toPrimitive(l, Integer.MIN_VALUE)); - assertSame(ArrayUtils.EMPTY_INT_ARRAY, + assertSame(ArrayUtils.EMPTY_INT_ARRAY, ArrayUtils.toPrimitive(new Integer[0], 1)); assertTrue(Arrays.equals( new int[] {Integer.MIN_VALUE, Integer.MAX_VALUE, 9999999}, - ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE), + ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE), Integer.valueOf(Integer.MAX_VALUE), Integer.valueOf(9999999)},1))); assertTrue(Arrays.equals( new int[] {Integer.MIN_VALUE, Integer.MAX_VALUE, 9999999}, - ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE), + ArrayUtils.toPrimitive(new Integer[] {Integer.valueOf(Integer.MIN_VALUE), null, Integer.valueOf(9999999)}, Integer.MAX_VALUE)) ); } - + @Test public void testToPrimitive_intNull() { final Integer[] iArray = null; @@ -4389,11 +4389,11 @@ public class ArrayUtilsTest { public void testToObject_int() { final int[] b = null; assertArrayEquals(null, ArrayUtils.toObject(b)); - + assertSame( ArrayUtils.EMPTY_INTEGER_OBJECT_ARRAY, ArrayUtils.toObject(new int[0])); - + assertTrue( Arrays.equals( new Integer[] { @@ -4410,13 +4410,13 @@ public class ArrayUtilsTest { public void testToPrimitive_long() { final Long[] b = null; assertEquals(null, ArrayUtils.toPrimitive(b)); - - assertSame(ArrayUtils.EMPTY_LONG_ARRAY, + + assertSame(ArrayUtils.EMPTY_LONG_ARRAY, ArrayUtils.toPrimitive(new Long[0])); - + assertTrue(Arrays.equals( new long[] {Long.MIN_VALUE, Long.MAX_VALUE, 9999999}, - ArrayUtils.toPrimitive(new Long[] {Long.valueOf(Long.MIN_VALUE), + ArrayUtils.toPrimitive(new Long[] {Long.valueOf(Long.MIN_VALUE), Long.valueOf(Long.MAX_VALUE), Long.valueOf(9999999)})) ); @@ -4430,31 +4430,31 @@ public class ArrayUtilsTest { public void testToPrimitive_long_long() { final Long[] l = null; assertEquals(null, ArrayUtils.toPrimitive(l, Long.MIN_VALUE)); - - assertSame(ArrayUtils.EMPTY_LONG_ARRAY, + + assertSame(ArrayUtils.EMPTY_LONG_ARRAY, ArrayUtils.toPrimitive(new Long[0], 1)); - + assertTrue(Arrays.equals( new long[] {Long.MIN_VALUE, Long.MAX_VALUE, 9999999}, - ArrayUtils.toPrimitive(new Long[] {Long.valueOf(Long.MIN_VALUE), + ArrayUtils.toPrimitive(new Long[] {Long.valueOf(Long.MIN_VALUE), Long.valueOf(Long.MAX_VALUE), Long.valueOf(9999999)},1))); - + assertTrue(Arrays.equals( new long[] {Long.MIN_VALUE, Long.MAX_VALUE, 9999999}, - ArrayUtils.toPrimitive(new Long[] {Long.valueOf(Long.MIN_VALUE), + ArrayUtils.toPrimitive(new Long[] {Long.valueOf(Long.MIN_VALUE), null, Long.valueOf(9999999)}, Long.MAX_VALUE)) ); } - + @Test public void testToObject_long() { final long[] b = null; assertArrayEquals(null, ArrayUtils.toObject(b)); - + assertSame( ArrayUtils.EMPTY_LONG_OBJECT_ARRAY, ArrayUtils.toObject(new long[0])); - + assertTrue( Arrays.equals( new Long[] { @@ -4471,13 +4471,13 @@ public class ArrayUtilsTest { public void testToPrimitive_float() { final Float[] b = null; assertEquals(null, ArrayUtils.toPrimitive(b)); - - assertSame(ArrayUtils.EMPTY_FLOAT_ARRAY, + + assertSame(ArrayUtils.EMPTY_FLOAT_ARRAY, ArrayUtils.toPrimitive(new Float[0])); - + assertTrue(Arrays.equals( new float[] {Float.MIN_VALUE, Float.MAX_VALUE, 9999999}, - ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), + ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), Float.valueOf(Float.MAX_VALUE), Float.valueOf(9999999)})) ); @@ -4491,31 +4491,31 @@ public class ArrayUtilsTest { public void testToPrimitive_float_float() { final Float[] l = null; assertEquals(null, ArrayUtils.toPrimitive(l, Float.MIN_VALUE)); - - assertSame(ArrayUtils.EMPTY_FLOAT_ARRAY, + + assertSame(ArrayUtils.EMPTY_FLOAT_ARRAY, ArrayUtils.toPrimitive(new Float[0], 1)); - + assertTrue(Arrays.equals( new float[] {Float.MIN_VALUE, Float.MAX_VALUE, 9999999}, - ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), + ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), Float.valueOf(Float.MAX_VALUE), Float.valueOf(9999999)},1))); - + assertTrue(Arrays.equals( new float[] {Float.MIN_VALUE, Float.MAX_VALUE, 9999999}, - ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), + ArrayUtils.toPrimitive(new Float[] {Float.valueOf(Float.MIN_VALUE), null, Float.valueOf(9999999)}, Float.MAX_VALUE)) ); } - + @Test public void testToObject_float() { final float[] b = null; assertArrayEquals(null, ArrayUtils.toObject(b)); - + assertSame( ArrayUtils.EMPTY_FLOAT_OBJECT_ARRAY, ArrayUtils.toObject(new float[0])); - + assertTrue( Arrays.equals( new Float[] { @@ -4532,13 +4532,13 @@ public class ArrayUtilsTest { public void testToPrimitive_double() { final Double[] b = null; assertEquals(null, ArrayUtils.toPrimitive(b)); - - assertSame(ArrayUtils.EMPTY_DOUBLE_ARRAY, + + assertSame(ArrayUtils.EMPTY_DOUBLE_ARRAY, ArrayUtils.toPrimitive(new Double[0])); - + assertTrue(Arrays.equals( new double[] {Double.MIN_VALUE, Double.MAX_VALUE, 9999999}, - ArrayUtils.toPrimitive(new Double[] {Double.valueOf(Double.MIN_VALUE), + ArrayUtils.toPrimitive(new Double[] {Double.valueOf(Double.MIN_VALUE), Double.valueOf(Double.MAX_VALUE), Double.valueOf(9999999)})) ); @@ -4552,31 +4552,31 @@ public class ArrayUtilsTest { public void testToPrimitive_double_double() { final Double[] l = null; assertEquals(null, ArrayUtils.toPrimitive(l, Double.MIN_VALUE)); - - assertSame(ArrayUtils.EMPTY_DOUBLE_ARRAY, + + assertSame(ArrayUtils.EMPTY_DOUBLE_ARRAY, ArrayUtils.toPrimitive(new Double[0], 1)); - + assertTrue(Arrays.equals( new double[] {Double.MIN_VALUE, Double.MAX_VALUE, 9999999}, - ArrayUtils.toPrimitive(new Double[] {Double.valueOf(Double.MIN_VALUE), + ArrayUtils.toPrimitive(new Double[] {Double.valueOf(Double.MIN_VALUE), Double.valueOf(Double.MAX_VALUE), Double.valueOf(9999999)},1))); - + assertTrue(Arrays.equals( new double[] {Double.MIN_VALUE, Double.MAX_VALUE, 9999999}, - ArrayUtils.toPrimitive(new Double[] {Double.valueOf(Double.MIN_VALUE), + ArrayUtils.toPrimitive(new Double[] {Double.valueOf(Double.MIN_VALUE), null, Double.valueOf(9999999)}, Double.MAX_VALUE)) ); } - + @Test public void testToObject_double() { final double[] b = null; assertArrayEquals(null, ArrayUtils.toObject(b)); - + assertSame( ArrayUtils.EMPTY_DOUBLE_OBJECT_ARRAY, ArrayUtils.toObject(new double[0])); - + assertTrue( Arrays.equals( new Double[] { @@ -4660,7 +4660,7 @@ public class ArrayUtilsTest { assertTrue(ArrayUtils.isEmpty(emptyBooleanArray)); assertFalse(ArrayUtils.isEmpty(notEmptyBooleanArray)); } - + /** * Test for {@link ArrayUtils#isNotEmpty(java.lang.Object[])}. */ @@ -4737,13 +4737,13 @@ public class ArrayUtilsTest { @Test public void testGetLength() { assertEquals(0, ArrayUtils.getLength(null)); - + final Object[] emptyObjectArray = new Object[0]; final Object[] notEmptyObjectArray = new Object[] {"aValue"}; assertEquals(0, ArrayUtils.getLength((Object[]) null)); assertEquals(0, ArrayUtils.getLength(emptyObjectArray)); assertEquals(1, ArrayUtils.getLength(notEmptyObjectArray)); - + final int[] emptyIntArray = new int[] {}; final int[] notEmptyIntArray = new int[] { 1 }; assertEquals(0, ArrayUtils.getLength((int[]) null)); @@ -4785,7 +4785,7 @@ public class ArrayUtilsTest { assertEquals(0, ArrayUtils.getLength((boolean[]) null)); assertEquals(0, ArrayUtils.getLength(emptyBooleanArray)); assertEquals(1, ArrayUtils.getLength(notEmptyBooleanArray)); - + try { ArrayUtils.getLength("notAnArray"); fail("IllegalArgumentException should have been thrown"); @@ -4828,7 +4828,7 @@ public class ArrayUtilsTest { array = new Integer[]{1,3,2}; assertFalse(ArrayUtils.isSorted(array, c)); } - + @Test(expected = IllegalArgumentException.class) public void testIsSortedNullComparator() throws Exception { ArrayUtils.isSorted(null, null); @@ -5006,7 +5006,7 @@ public class ArrayUtilsTest { public void testShuffleBoolean() { boolean[] array1 = new boolean[]{true, false, true, true, false, false, true, false, false, true}; boolean[] array2 = ArrayUtils.clone(array1); - + ArrayUtils.shuffle(array1); Assert.assertFalse(Arrays.equals(array1, array2)); Assert.assertEquals(5, ArrayUtils.removeAllOccurences(array1, true).length); @@ -5016,7 +5016,7 @@ public class ArrayUtilsTest { public void testShuffleByte() { byte[] array1 = new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; byte[] array2 = ArrayUtils.clone(array1); - + ArrayUtils.shuffle(array1); Assert.assertFalse(Arrays.equals(array1, array2)); for (byte element : array2) { @@ -5028,7 +5028,7 @@ public class ArrayUtilsTest { public void testShuffleChar() { char[] array1 = new char[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; char[] array2 = ArrayUtils.clone(array1); - + ArrayUtils.shuffle(array1); Assert.assertFalse(Arrays.equals(array1, array2)); for (char element : array2) { @@ -5040,7 +5040,7 @@ public class ArrayUtilsTest { public void testShuffleShort() { short[] array1 = new short[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; short[] array2 = ArrayUtils.clone(array1); - + ArrayUtils.shuffle(array1); Assert.assertFalse(Arrays.equals(array1, array2)); for (short element : array2) { @@ -5052,7 +5052,7 @@ public class ArrayUtilsTest { public void testShuffleInt() { int[] array1 = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; int[] array2 = ArrayUtils.clone(array1); - + ArrayUtils.shuffle(array1); Assert.assertFalse(Arrays.equals(array1, array2)); for (int element : array2) { @@ -5064,7 +5064,7 @@ public class ArrayUtilsTest { public void testShuffleLong() { long[] array1 = new long[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; long[] array2 = ArrayUtils.clone(array1); - + ArrayUtils.shuffle(array1); Assert.assertFalse(Arrays.equals(array1, array2)); for (long element : array2) { @@ -5076,7 +5076,7 @@ public class ArrayUtilsTest { public void testShuffleFloat() { float[] array1 = new float[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; float[] array2 = ArrayUtils.clone(array1); - + ArrayUtils.shuffle(array1); Assert.assertFalse(Arrays.equals(array1, array2)); for (float element : array2) { @@ -5088,7 +5088,7 @@ public class ArrayUtilsTest { public void testShuffleDouble() { double[] array1 = new double[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; double[] array2 = ArrayUtils.clone(array1); - + ArrayUtils.shuffle(array1); Assert.assertFalse(Arrays.equals(array1, array2)); for (double element : array2) { diff --git a/src/test/java/org/apache/commons/lang3/BitFieldTest.java b/src/test/java/org/apache/commons/lang3/BitFieldTest.java index 7d4ae9adf..b621c89c6 100644 --- a/src/test/java/org/apache/commons/lang3/BitFieldTest.java +++ b/src/test/java/org/apache/commons/lang3/BitFieldTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java b/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java index b16a2e0f4..5d22dad66 100644 --- a/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/BooleanUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -42,7 +42,7 @@ public class BooleanUtilsTest { assertTrue(Modifier.isPublic(BooleanUtils.class.getModifiers())); assertFalse(Modifier.isFinal(BooleanUtils.class.getModifiers())); } - + //----------------------------------------------------------------------- @Test public void test_negate_Boolean() { @@ -107,14 +107,14 @@ public class BooleanUtilsTest { assertTrue(BooleanUtils.toBoolean(-1)); assertFalse(BooleanUtils.toBoolean(0)); } - + @Test public void test_toBooleanObject_int() { assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(1)); assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(-1)); assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(0)); } - + @Test public void test_toBooleanObject_Integer() { assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(Integer.valueOf(1))); @@ -122,7 +122,7 @@ public class BooleanUtilsTest { assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(Integer.valueOf(0))); assertEquals(null, BooleanUtils.toBooleanObject((Integer) null)); } - + //----------------------------------------------------------------------- @Test public void test_toBoolean_int_int_int() { @@ -134,7 +134,7 @@ public class BooleanUtilsTest { public void test_toBoolean_int_int_int_noMatch() { BooleanUtils.toBoolean(8, 6, 7); } - + @Test public void test_toBoolean_Integer_Integer_Integer() { final Integer six = Integer.valueOf(6); @@ -156,7 +156,7 @@ public class BooleanUtilsTest { public void test_toBoolean_Integer_Integer_Integer_noMatch() { BooleanUtils.toBoolean(Integer.valueOf(8), Integer.valueOf(6), Integer.valueOf(7)); } - + //----------------------------------------------------------------------- @Test public void test_toBooleanObject_int_int_int() { @@ -169,7 +169,7 @@ public class BooleanUtilsTest { public void test_toBooleanObject_int_int_int_noMatch() { BooleanUtils.toBooleanObject(9, 6, 7, 8); } - + @Test public void test_toBooleanObject_Integer_Integer_Integer_Integer() { final Integer six = Integer.valueOf(6); @@ -201,34 +201,34 @@ public class BooleanUtilsTest { assertEquals(1, BooleanUtils.toInteger(true)); assertEquals(0, BooleanUtils.toInteger(false)); } - + @Test public void test_toIntegerObject_boolean() { assertEquals(Integer.valueOf(1), BooleanUtils.toIntegerObject(true)); assertEquals(Integer.valueOf(0), BooleanUtils.toIntegerObject(false)); } - + @Test public void test_toIntegerObject_Boolean() { assertEquals(Integer.valueOf(1), BooleanUtils.toIntegerObject(Boolean.TRUE)); assertEquals(Integer.valueOf(0), BooleanUtils.toIntegerObject(Boolean.FALSE)); assertEquals(null, BooleanUtils.toIntegerObject(null)); } - + //----------------------------------------------------------------------- @Test public void test_toInteger_boolean_int_int() { assertEquals(6, BooleanUtils.toInteger(true, 6, 7)); assertEquals(7, BooleanUtils.toInteger(false, 6, 7)); } - + @Test public void test_toInteger_Boolean_int_int_int() { assertEquals(6, BooleanUtils.toInteger(Boolean.TRUE, 6, 7, 8)); assertEquals(7, BooleanUtils.toInteger(Boolean.FALSE, 6, 7, 8)); assertEquals(8, BooleanUtils.toInteger(null, 6, 7, 8)); } - + @Test public void test_toIntegerObject_boolean_Integer_Integer() { final Integer six = Integer.valueOf(6); @@ -236,7 +236,7 @@ public class BooleanUtilsTest { assertEquals(six, BooleanUtils.toIntegerObject(true, six, seven)); assertEquals(seven, BooleanUtils.toIntegerObject(false, six, seven)); } - + @Test public void test_toIntegerObject_Boolean_Integer_Integer_Integer() { final Integer six = Integer.valueOf(6); @@ -247,7 +247,7 @@ public class BooleanUtilsTest { assertEquals(eight, BooleanUtils.toIntegerObject(null, six, seven, eight)); assertEquals(null, BooleanUtils.toIntegerObject(null, six, seven, null)); } - + //----------------------------------------------------------------------- //----------------------------------------------------------------------- @Test @@ -285,7 +285,7 @@ public class BooleanUtilsTest { assertEquals(null, BooleanUtils.toBooleanObject("true ")); assertEquals(null, BooleanUtils.toBooleanObject("ono")); } - + @Test public void test_toBooleanObject_String_String_String_String() { assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject(null, null, "N", "U")); @@ -385,53 +385,53 @@ public class BooleanUtilsTest { assertEquals("true", BooleanUtils.toStringTrueFalse(Boolean.TRUE)); assertEquals("false", BooleanUtils.toStringTrueFalse(Boolean.FALSE)); } - + @Test public void test_toStringOnOff_Boolean() { assertEquals(null, BooleanUtils.toStringOnOff(null)); assertEquals("on", BooleanUtils.toStringOnOff(Boolean.TRUE)); assertEquals("off", BooleanUtils.toStringOnOff(Boolean.FALSE)); } - + @Test public void test_toStringYesNo_Boolean() { assertEquals(null, BooleanUtils.toStringYesNo(null)); assertEquals("yes", BooleanUtils.toStringYesNo(Boolean.TRUE)); assertEquals("no", BooleanUtils.toStringYesNo(Boolean.FALSE)); } - + @Test public void test_toString_Boolean_String_String_String() { assertEquals("U", BooleanUtils.toString(null, "Y", "N", "U")); assertEquals("Y", BooleanUtils.toString(Boolean.TRUE, "Y", "N", "U")); assertEquals("N", BooleanUtils.toString(Boolean.FALSE, "Y", "N", "U")); } - + //----------------------------------------------------------------------- @Test public void test_toStringTrueFalse_boolean() { assertEquals("true", BooleanUtils.toStringTrueFalse(true)); assertEquals("false", BooleanUtils.toStringTrueFalse(false)); } - + @Test public void test_toStringOnOff_boolean() { assertEquals("on", BooleanUtils.toStringOnOff(true)); assertEquals("off", BooleanUtils.toStringOnOff(false)); } - + @Test public void test_toStringYesNo_boolean() { assertEquals("yes", BooleanUtils.toStringYesNo(true)); assertEquals("no", BooleanUtils.toStringYesNo(false)); } - + @Test public void test_toString_boolean_String_String_String() { assertEquals("Y", BooleanUtils.toString(true, "Y", "N")); assertEquals("N", BooleanUtils.toString(false, "Y", "N")); } - + // testXor // ----------------------------------------------------------------------- @Test(expected = IllegalArgumentException.class) @@ -519,7 +519,7 @@ public class BooleanUtilsTest { public void testXor_object_emptyInput() { BooleanUtils.xor(new Boolean[] {}); } - + @Test(expected = IllegalArgumentException.class) public void testXor_object_nullElementInput() { BooleanUtils.xor(new Boolean[] {null}); @@ -645,81 +645,81 @@ public class BooleanUtilsTest { public void testAnd_primitive_nullInput() { BooleanUtils.and((boolean[]) null); } - + @Test(expected = IllegalArgumentException.class) public void testAnd_primitive_emptyInput() { BooleanUtils.and(new boolean[] {}); } - + @Test public void testAnd_primitive_validInput_2items() { assertTrue( "False result for (true, true)", BooleanUtils.and(new boolean[] { true, true })); - + assertTrue( "True result for (false, false)", ! BooleanUtils.and(new boolean[] { false, false })); - + assertTrue( "True result for (true, false)", ! BooleanUtils.and(new boolean[] { true, false })); - + assertTrue( "True result for (false, true)", ! BooleanUtils.and(new boolean[] { false, true })); } - + @Test public void testAnd_primitive_validInput_3items() { assertTrue( "True result for (false, false, true)", ! BooleanUtils.and(new boolean[] { false, false, true })); - + assertTrue( "True result for (false, true, false)", ! BooleanUtils.and(new boolean[] { false, true, false })); - + assertTrue( "True result for (true, false, false)", ! BooleanUtils.and(new boolean[] { true, false, false })); - + assertTrue( "False result for (true, true, true)", BooleanUtils.and(new boolean[] { true, true, true })); - + assertTrue( "True result for (false, false)", ! BooleanUtils.and(new boolean[] { false, false, false })); - + assertTrue( "True result for (true, true, false)", ! BooleanUtils.and(new boolean[] { true, true, false })); - + assertTrue( "True result for (true, false, true)", ! BooleanUtils.and(new boolean[] { true, false, true })); - + assertTrue( "True result for (false, true, true)", ! BooleanUtils.and(new boolean[] { false, true, true })); } - + @Test(expected = IllegalArgumentException.class) public void testAnd_object_nullInput() { BooleanUtils.and((Boolean[]) null); } - + @Test(expected = IllegalArgumentException.class) public void testAnd_object_emptyInput() { BooleanUtils.and(new Boolean[] {}); } - + @Test(expected = IllegalArgumentException.class) public void testAnd_object_nullElementInput() { BooleanUtils.and(new Boolean[] {null}); } - + @Test public void testAnd_object_validInput_2items() { assertTrue( @@ -727,26 +727,26 @@ public class BooleanUtilsTest { BooleanUtils .and(new Boolean[] { Boolean.TRUE, Boolean.TRUE }) .booleanValue()); - + assertTrue( "True result for (false, false)", ! BooleanUtils .and(new Boolean[] { Boolean.FALSE, Boolean.FALSE }) .booleanValue()); - + assertTrue( "True result for (true, false)", ! BooleanUtils .and(new Boolean[] { Boolean.TRUE, Boolean.FALSE }) .booleanValue()); - + assertTrue( "True result for (false, true)", ! BooleanUtils .and(new Boolean[] { Boolean.FALSE, Boolean.TRUE }) .booleanValue()); } - + @Test public void testAnd_object_validInput_3items() { assertTrue( @@ -758,7 +758,7 @@ public class BooleanUtilsTest { Boolean.FALSE, Boolean.TRUE }) .booleanValue()); - + assertTrue( "True result for (false, true, false)", ! BooleanUtils @@ -768,7 +768,7 @@ public class BooleanUtilsTest { Boolean.TRUE, Boolean.FALSE }) .booleanValue()); - + assertTrue( "True result for (true, false, false)", ! BooleanUtils @@ -778,13 +778,13 @@ public class BooleanUtilsTest { Boolean.FALSE, Boolean.FALSE }) .booleanValue()); - + assertTrue( "False result for (true, true, true)", BooleanUtils .and(new Boolean[] { Boolean.TRUE, Boolean.TRUE, Boolean.TRUE }) .booleanValue()); - + assertTrue( "True result for (false, false)", ! BooleanUtils.and( @@ -793,7 +793,7 @@ public class BooleanUtilsTest { Boolean.FALSE, Boolean.FALSE }) .booleanValue()); - + assertTrue( "True result for (true, true, false)", ! BooleanUtils.and( @@ -802,7 +802,7 @@ public class BooleanUtilsTest { Boolean.TRUE, Boolean.FALSE }) .booleanValue()); - + assertTrue( "True result for (true, false, true)", ! BooleanUtils.and( @@ -811,7 +811,7 @@ public class BooleanUtilsTest { Boolean.FALSE, Boolean.TRUE }) .booleanValue()); - + assertTrue( "True result for (false, true, true)", ! BooleanUtils.and( @@ -821,88 +821,88 @@ public class BooleanUtilsTest { Boolean.TRUE }) .booleanValue()); } - + // testOr // ----------------------------------------------------------------------- @Test(expected = IllegalArgumentException.class) public void testOr_primitive_nullInput() { BooleanUtils.or((boolean[]) null); } - + @Test(expected = IllegalArgumentException.class) public void testOr_primitive_emptyInput() { BooleanUtils.or(new boolean[] {}); } - + @Test public void testOr_primitive_validInput_2items() { assertTrue( "False result for (true, true)", BooleanUtils.or(new boolean[] { true, true })); - + assertTrue( "True result for (false, false)", ! BooleanUtils.or(new boolean[] { false, false })); - + assertTrue( "False result for (true, false)", BooleanUtils.or(new boolean[] { true, false })); - + assertTrue( "False result for (false, true)", BooleanUtils.or(new boolean[] { false, true })); } - + @Test public void testOr_primitive_validInput_3items() { assertTrue( "False result for (false, false, true)", BooleanUtils.or(new boolean[] { false, false, true })); - + assertTrue( "False result for (false, true, false)", BooleanUtils.or(new boolean[] { false, true, false })); - + assertTrue( "False result for (true, false, false)", BooleanUtils.or(new boolean[] { true, false, false })); - + assertTrue( "False result for (true, true, true)", BooleanUtils.or(new boolean[] { true, true, true })); - + assertTrue( "True result for (false, false)", ! BooleanUtils.or(new boolean[] { false, false, false })); - + assertTrue( "False result for (true, true, false)", BooleanUtils.or(new boolean[] { true, true, false })); - + assertTrue( "False result for (true, false, true)", BooleanUtils.or(new boolean[] { true, false, true })); - + assertTrue( "False result for (false, true, true)", BooleanUtils.or(new boolean[] { false, true, true })); - + } @Test(expected = IllegalArgumentException.class) public void testOr_object_nullInput() { BooleanUtils.or((Boolean[]) null); } - + @Test(expected = IllegalArgumentException.class) public void testOr_object_emptyInput() { BooleanUtils.or(new Boolean[] {}); } - + @Test(expected = IllegalArgumentException.class) public void testOr_object_nullElementInput() { BooleanUtils.or(new Boolean[] {null}); } - + @Test public void testOr_object_validInput_2items() { assertTrue( @@ -910,26 +910,26 @@ public class BooleanUtilsTest { BooleanUtils .or(new Boolean[] { Boolean.TRUE, Boolean.TRUE }) .booleanValue()); - + assertTrue( "True result for (false, false)", ! BooleanUtils .or(new Boolean[] { Boolean.FALSE, Boolean.FALSE }) .booleanValue()); - + assertTrue( "False result for (true, false)", BooleanUtils .or(new Boolean[] { Boolean.TRUE, Boolean.FALSE }) .booleanValue()); - + assertTrue( "False result for (false, true)", BooleanUtils .or(new Boolean[] { Boolean.FALSE, Boolean.TRUE }) .booleanValue()); } - + @Test public void testOr_object_validInput_3items() { assertTrue( @@ -941,7 +941,7 @@ public class BooleanUtilsTest { Boolean.FALSE, Boolean.TRUE }) .booleanValue()); - + assertTrue( "False result for (false, true, false)", BooleanUtils @@ -951,7 +951,7 @@ public class BooleanUtilsTest { Boolean.TRUE, Boolean.FALSE }) .booleanValue()); - + assertTrue( "False result for (true, false, false)", BooleanUtils @@ -961,13 +961,13 @@ public class BooleanUtilsTest { Boolean.FALSE, Boolean.FALSE }) .booleanValue()); - + assertTrue( "False result for (true, true, true)", BooleanUtils .or(new Boolean[] { Boolean.TRUE, Boolean.TRUE, Boolean.TRUE }) .booleanValue()); - + assertTrue( "True result for (false, false)", ! BooleanUtils.or( @@ -976,7 +976,7 @@ public class BooleanUtilsTest { Boolean.FALSE, Boolean.FALSE }) .booleanValue()); - + assertTrue( "False result for (true, true, false)", BooleanUtils.or( @@ -985,7 +985,7 @@ public class BooleanUtilsTest { Boolean.TRUE, Boolean.FALSE }) .booleanValue()); - + assertTrue( "False result for (true, false, true)", BooleanUtils.or( @@ -994,7 +994,7 @@ public class BooleanUtilsTest { Boolean.FALSE, Boolean.TRUE }) .booleanValue()); - + assertTrue( "False result for (false, true, true)", BooleanUtils.or( @@ -1012,5 +1012,5 @@ public class BooleanUtilsTest { assertTrue(BooleanUtils.compare(false, false) == 0); assertTrue(BooleanUtils.compare(false, true) < 0); } - + } diff --git a/src/test/java/org/apache/commons/lang3/CharEncodingTest.java b/src/test/java/org/apache/commons/lang3/CharEncodingTest.java index 9e8e5402e..7999457f7 100644 --- a/src/test/java/org/apache/commons/lang3/CharEncodingTest.java +++ b/src/test/java/org/apache/commons/lang3/CharEncodingTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,7 +24,7 @@ import org.junit.Test; /** * Tests CharEncoding. - * + * * @see CharEncoding */ @SuppressWarnings("deprecation") diff --git a/src/test/java/org/apache/commons/lang3/CharRangeTest.java b/src/test/java/org/apache/commons/lang3/CharRangeTest.java index b36e43e7a..83a1008df 100644 --- a/src/test/java/org/apache/commons/lang3/CharRangeTest.java +++ b/src/test/java/org/apache/commons/lang3/CharRangeTest.java @@ -390,11 +390,11 @@ public class CharRangeTest { @Test public void testSerialization() { CharRange range = CharRange.is('a'); - assertEquals(range, SerializationUtils.clone(range)); + assertEquals(range, SerializationUtils.clone(range)); range = CharRange.isIn('a', 'e'); - assertEquals(range, SerializationUtils.clone(range)); + assertEquals(range, SerializationUtils.clone(range)); range = CharRange.isNotIn('a', 'e'); - assertEquals(range, SerializationUtils.clone(range)); + assertEquals(range, SerializationUtils.clone(range)); } //----------------------------------------------------------------------- diff --git a/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java b/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java index 591bf3886..824061973 100644 --- a/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/CharSequenceUtilsTest.java @@ -43,7 +43,7 @@ public class CharSequenceUtilsTest { assertTrue(Modifier.isPublic(CharSequenceUtils.class.getModifiers())); assertFalse(Modifier.isFinal(CharSequenceUtils.class.getModifiers())); } - + //----------------------------------------------------------------------- @Test public void testSubSequence() { @@ -138,9 +138,9 @@ public class CharSequenceUtilsTest { }; private static abstract class RunTest { - + abstract boolean invoke(); - + void run(final TestData data, final String id) { if (data.throwable != null) { try { @@ -156,7 +156,7 @@ public class CharSequenceUtilsTest { assertEquals(id + " Failed test " + data, data.expected, stringCheck); } } - + } @Test @@ -165,25 +165,25 @@ public class CharSequenceUtilsTest { new RunTest() { @Override boolean invoke() { - return data.source.regionMatches(data.ignoreCase, data.toffset, data.other, data.ooffset, data.len); + return data.source.regionMatches(data.ignoreCase, data.toffset, data.other, data.ooffset, data.len); } }.run(data, "String"); new RunTest() { @Override boolean invoke() { - return CharSequenceUtils.regionMatches(data.source, data.ignoreCase, data.toffset, data.other, data.ooffset, data.len); + return CharSequenceUtils.regionMatches(data.source, data.ignoreCase, data.toffset, data.other, data.ooffset, data.len); } }.run(data, "CSString"); new RunTest() { @Override boolean invoke() { - return CharSequenceUtils.regionMatches(new StringBuilder(data.source), data.ignoreCase, data.toffset, data.other, data.ooffset, data.len); + return CharSequenceUtils.regionMatches(new StringBuilder(data.source), data.ignoreCase, data.toffset, data.other, data.ooffset, data.len); } }.run(data, "CSNonString"); } } - - + + @Test public void testToCharArray() throws Exception { final StringBuilder builder = new StringBuilder("abcdefg"); diff --git a/src/test/java/org/apache/commons/lang3/CharSetTest.java b/src/test/java/org/apache/commons/lang3/CharSetTest.java index 2c05e9845..035dc4b74 100644 --- a/src/test/java/org/apache/commons/lang3/CharSetTest.java +++ b/src/test/java/org/apache/commons/lang3/CharSetTest.java @@ -38,7 +38,7 @@ public class CharSetTest { assertTrue(Modifier.isPublic(CharSet.class.getModifiers())); assertFalse(Modifier.isFinal(CharSet.class.getModifiers())); } - + //----------------------------------------------------------------------- @Test public void testGetInstance() { @@ -59,78 +59,78 @@ public class CharSetTest { assertEquals("[]", CharSet.getInstance(new String[] {null}).toString()); assertEquals("[a-e]", CharSet.getInstance(new String[] {"a-e"}).toString()); } - + //----------------------------------------------------------------------- @Test public void testConstructor_String_simple() { CharSet set; CharRange[] array; - + set = CharSet.getInstance((String) null); array = set.getCharRanges(); assertEquals("[]", set.toString()); assertEquals(0, array.length); - + set = CharSet.getInstance(""); array = set.getCharRanges(); assertEquals("[]", set.toString()); assertEquals(0, array.length); - + set = CharSet.getInstance("a"); array = set.getCharRanges(); assertEquals("[a]", set.toString()); assertEquals(1, array.length); assertEquals("a", array[0].toString()); - + set = CharSet.getInstance("^a"); array = set.getCharRanges(); assertEquals("[^a]", set.toString()); assertEquals(1, array.length); assertEquals("^a", array[0].toString()); - + set = CharSet.getInstance("a-e"); array = set.getCharRanges(); assertEquals("[a-e]", set.toString()); assertEquals(1, array.length); assertEquals("a-e", array[0].toString()); - + set = CharSet.getInstance("^a-e"); array = set.getCharRanges(); assertEquals("[^a-e]", set.toString()); assertEquals(1, array.length); assertEquals("^a-e", array[0].toString()); } - + @Test public void testConstructor_String_combo() { CharSet set; CharRange[] array; - + set = CharSet.getInstance("abc"); array = set.getCharRanges(); assertEquals(3, array.length); assertTrue(ArrayUtils.contains(array, CharRange.is('a'))); assertTrue(ArrayUtils.contains(array, CharRange.is('b'))); assertTrue(ArrayUtils.contains(array, CharRange.is('c'))); - + set = CharSet.getInstance("a-ce-f"); array = set.getCharRanges(); assertEquals(2, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isIn('a', 'c'))); assertTrue(ArrayUtils.contains(array, CharRange.isIn('e', 'f'))); - + set = CharSet.getInstance("ae-f"); array = set.getCharRanges(); assertEquals(2, array.length); assertTrue(ArrayUtils.contains(array, CharRange.is('a'))); assertTrue(ArrayUtils.contains(array, CharRange.isIn('e', 'f'))); - + set = CharSet.getInstance("e-fa"); array = set.getCharRanges(); assertEquals(2, array.length); assertTrue(ArrayUtils.contains(array, CharRange.is('a'))); assertTrue(ArrayUtils.contains(array, CharRange.isIn('e', 'f'))); - + set = CharSet.getInstance("ae-fm-pz"); array = set.getCharRanges(); assertEquals(4, array.length); @@ -139,26 +139,26 @@ public class CharSetTest { assertTrue(ArrayUtils.contains(array, CharRange.isIn('m', 'p'))); assertTrue(ArrayUtils.contains(array, CharRange.is('z'))); } - + @Test public void testConstructor_String_comboNegated() { CharSet set; CharRange[] array; - + set = CharSet.getInstance("^abc"); array = set.getCharRanges(); assertEquals(3, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isNot('a'))); assertTrue(ArrayUtils.contains(array, CharRange.is('b'))); assertTrue(ArrayUtils.contains(array, CharRange.is('c'))); - + set = CharSet.getInstance("b^ac"); array = set.getCharRanges(); assertEquals(3, array.length); assertTrue(ArrayUtils.contains(array, CharRange.is('b'))); assertTrue(ArrayUtils.contains(array, CharRange.isNot('a'))); assertTrue(ArrayUtils.contains(array, CharRange.is('c'))); - + set = CharSet.getInstance("db^ac"); array = set.getCharRanges(); assertEquals(4, array.length); @@ -166,13 +166,13 @@ public class CharSetTest { assertTrue(ArrayUtils.contains(array, CharRange.is('b'))); assertTrue(ArrayUtils.contains(array, CharRange.isNot('a'))); assertTrue(ArrayUtils.contains(array, CharRange.is('c'))); - + set = CharSet.getInstance("^b^a"); array = set.getCharRanges(); assertEquals(2, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isNot('b'))); assertTrue(ArrayUtils.contains(array, CharRange.isNot('a'))); - + set = CharSet.getInstance("b^a-c^z"); array = set.getCharRanges(); assertEquals(3, array.length); @@ -185,50 +185,50 @@ public class CharSetTest { public void testConstructor_String_oddDash() { CharSet set; CharRange[] array; - + set = CharSet.getInstance("-"); array = set.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.is('-'))); - + set = CharSet.getInstance("--"); array = set.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.is('-'))); - + set = CharSet.getInstance("---"); array = set.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.is('-'))); - + set = CharSet.getInstance("----"); array = set.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.is('-'))); - + set = CharSet.getInstance("-a"); array = set.getCharRanges(); assertEquals(2, array.length); assertTrue(ArrayUtils.contains(array, CharRange.is('-'))); assertTrue(ArrayUtils.contains(array, CharRange.is('a'))); - + set = CharSet.getInstance("a-"); array = set.getCharRanges(); assertEquals(2, array.length); assertTrue(ArrayUtils.contains(array, CharRange.is('a'))); assertTrue(ArrayUtils.contains(array, CharRange.is('-'))); - + set = CharSet.getInstance("a--"); array = set.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isIn('a', '-'))); - + set = CharSet.getInstance("--a"); array = set.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isIn('-', 'a'))); } - + @Test public void testConstructor_String_oddNegate() { CharSet set; @@ -237,80 +237,80 @@ public class CharSetTest { array = set.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.is('^'))); // "^" - + set = CharSet.getInstance("^^"); array = set.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isNot('^'))); // "^^" - + set = CharSet.getInstance("^^^"); array = set.getCharRanges(); assertEquals(2, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isNot('^'))); // "^^" assertTrue(ArrayUtils.contains(array, CharRange.is('^'))); // "^" - + set = CharSet.getInstance("^^^^"); array = set.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isNot('^'))); // "^^" x2 - + set = CharSet.getInstance("a^"); array = set.getCharRanges(); assertEquals(2, array.length); assertTrue(ArrayUtils.contains(array, CharRange.is('a'))); // "a" assertTrue(ArrayUtils.contains(array, CharRange.is('^'))); // "^" - + set = CharSet.getInstance("^a-"); array = set.getCharRanges(); assertEquals(2, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isNot('a'))); // "^a" assertTrue(ArrayUtils.contains(array, CharRange.is('-'))); // "-" - + set = CharSet.getInstance("^^-c"); array = set.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isNotIn('^', 'c'))); // "^^-c" - + set = CharSet.getInstance("^c-^"); array = set.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isNotIn('c', '^'))); // "^c-^" - + set = CharSet.getInstance("^c-^d"); array = set.getCharRanges(); assertEquals(2, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isNotIn('c', '^'))); // "^c-^" assertTrue(ArrayUtils.contains(array, CharRange.is('d'))); // "d" - + set = CharSet.getInstance("^^-"); array = set.getCharRanges(); assertEquals(2, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isNot('^'))); // "^^" assertTrue(ArrayUtils.contains(array, CharRange.is('-'))); // "-" } - + @Test public void testConstructor_String_oddCombinations() { CharSet set; CharRange[] array = null; - + set = CharSet.getInstance("a-^c"); array = set.getCharRanges(); assertTrue(ArrayUtils.contains(array, CharRange.isIn('a', '^'))); // "a-^" assertTrue(ArrayUtils.contains(array, CharRange.is('c'))); // "c" assertFalse(set.contains('b')); - assertTrue(set.contains('^')); + assertTrue(set.contains('^')); assertTrue(set.contains('_')); // between ^ and a - assertTrue(set.contains('c')); - + assertTrue(set.contains('c')); + set = CharSet.getInstance("^a-^c"); array = set.getCharRanges(); assertTrue(ArrayUtils.contains(array, CharRange.isNotIn('a', '^'))); // "^a-^" assertTrue(ArrayUtils.contains(array, CharRange.is('c'))); // "c" assertTrue(set.contains('b')); - assertFalse(set.contains('^')); + assertFalse(set.contains('^')); assertFalse(set.contains('_')); // between ^ and a - + set = CharSet.getInstance("a- ^-- "); //contains everything array = set.getCharRanges(); assertTrue(ArrayUtils.contains(array, CharRange.isIn('a', ' '))); // "a- " @@ -320,25 +320,25 @@ public class CharSetTest { assertTrue(set.contains('a')); assertTrue(set.contains('*')); assertTrue(set.contains('A')); - + set = CharSet.getInstance("^-b"); array = set.getCharRanges(); assertTrue(ArrayUtils.contains(array, CharRange.isIn('^','b'))); // "^-b" assertTrue(set.contains('b')); assertTrue(set.contains('_')); // between ^ and a assertFalse(set.contains('A')); - assertTrue(set.contains('^')); - + assertTrue(set.contains('^')); + set = CharSet.getInstance("b-^"); array = set.getCharRanges(); assertTrue(ArrayUtils.contains(array, CharRange.isIn('^','b'))); // "b-^" assertTrue(set.contains('b')); assertTrue(set.contains('^')); assertTrue(set.contains('a')); // between ^ and b - assertFalse(set.contains('c')); + assertFalse(set.contains('c')); } - - //----------------------------------------------------------------------- + + //----------------------------------------------------------------------- @Test public void testEquals_Object() { final CharSet abc = CharSet.getInstance("abc"); @@ -347,25 +347,25 @@ public class CharSetTest { final CharSet atoc2 = CharSet.getInstance("a-c"); final CharSet notatoc = CharSet.getInstance("^a-c"); final CharSet notatoc2 = CharSet.getInstance("^a-c"); - + assertFalse(abc.equals(null)); - + assertTrue(abc.equals(abc)); assertTrue(abc.equals(abc2)); assertFalse(abc.equals(atoc)); assertFalse(abc.equals(notatoc)); - + assertFalse(atoc.equals(abc)); assertTrue(atoc.equals(atoc)); assertTrue(atoc.equals(atoc2)); assertFalse(atoc.equals(notatoc)); - + assertFalse(notatoc.equals(abc)); assertFalse(notatoc.equals(atoc)); assertTrue(notatoc.equals(notatoc)); assertTrue(notatoc.equals(notatoc2)); } - + @Test public void testHashCode() { final CharSet abc = CharSet.getInstance("abc"); @@ -374,7 +374,7 @@ public class CharSetTest { final CharSet atoc2 = CharSet.getInstance("a-c"); final CharSet notatoc = CharSet.getInstance("^a-c"); final CharSet notatoc2 = CharSet.getInstance("^a-c"); - + assertEquals(abc.hashCode(), abc.hashCode()); assertEquals(abc.hashCode(), abc2.hashCode()); assertEquals(atoc.hashCode(), atoc.hashCode()); @@ -382,8 +382,8 @@ public class CharSetTest { assertEquals(notatoc.hashCode(), notatoc.hashCode()); assertEquals(notatoc.hashCode(), notatoc2.hashCode()); } - - //----------------------------------------------------------------------- + + //----------------------------------------------------------------------- @Test public void testContains_Char() { final CharSet btod = CharSet.getInstance("b-d"); @@ -391,79 +391,79 @@ public class CharSetTest { final CharSet bcd = CharSet.getInstance("bcd"); final CharSet bd = CharSet.getInstance("bd"); final CharSet notbtod = CharSet.getInstance("^b-d"); - + assertFalse(btod.contains('a')); assertTrue(btod.contains('b')); assertTrue(btod.contains('c')); assertTrue(btod.contains('d')); assertFalse(btod.contains('e')); - + assertFalse(bcd.contains('a')); assertTrue(bcd.contains('b')); assertTrue(bcd.contains('c')); assertTrue(bcd.contains('d')); assertFalse(bcd.contains('e')); - + assertFalse(bd.contains('a')); assertTrue(bd.contains('b')); assertFalse(bd.contains('c')); assertTrue(bd.contains('d')); assertFalse(bd.contains('e')); - + assertTrue(notbtod.contains('a')); assertFalse(notbtod.contains('b')); assertFalse(notbtod.contains('c')); assertFalse(notbtod.contains('d')); assertTrue(notbtod.contains('e')); - + assertFalse(dtob.contains('a')); assertTrue(dtob.contains('b')); assertTrue(dtob.contains('c')); assertTrue(dtob.contains('d')); assertFalse(dtob.contains('e')); - + final CharRange[] array = dtob.getCharRanges(); assertEquals("[b-d]", dtob.toString()); assertEquals(1, array.length); } - - //----------------------------------------------------------------------- + + //----------------------------------------------------------------------- @Test public void testSerialization() { CharSet set = CharSet.getInstance("a"); - assertEquals(set, SerializationUtils.clone(set)); + assertEquals(set, SerializationUtils.clone(set)); set = CharSet.getInstance("a-e"); - assertEquals(set, SerializationUtils.clone(set)); + assertEquals(set, SerializationUtils.clone(set)); set = CharSet.getInstance("be-f^a-z"); - assertEquals(set, SerializationUtils.clone(set)); + assertEquals(set, SerializationUtils.clone(set)); } - - //----------------------------------------------------------------------- + + //----------------------------------------------------------------------- @Test public void testStatics() { CharRange[] array; - + array = CharSet.EMPTY.getCharRanges(); assertEquals(0, array.length); - + array = CharSet.ASCII_ALPHA.getCharRanges(); assertEquals(2, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isIn('a', 'z'))); assertTrue(ArrayUtils.contains(array, CharRange.isIn('A', 'Z'))); - + array = CharSet.ASCII_ALPHA_LOWER.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isIn('a', 'z'))); - + array = CharSet.ASCII_ALPHA_UPPER.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isIn('A', 'Z'))); - + array = CharSet.ASCII_NUMERIC.getCharRanges(); assertEquals(1, array.length); assertTrue(ArrayUtils.contains(array, CharRange.isIn('0', '9'))); } - + @Test public void testJavadocExamples() throws Exception { assertFalse(CharSet.getInstance("^a-c").contains('a')); @@ -472,6 +472,6 @@ public class CharSetTest { assertFalse(CharSet.getInstance("^^a-c").contains('^')); assertTrue(CharSet.getInstance("^a-cd-f").contains('d')); assertTrue(CharSet.getInstance("a-c^").contains('^')); - assertTrue(CharSet.getInstance("^", "a-c").contains('^')); + assertTrue(CharSet.getInstance("^", "a-c").contains('^')); } } diff --git a/src/test/java/org/apache/commons/lang3/CharSetUtilsTest.java b/src/test/java/org/apache/commons/lang3/CharSetUtilsTest.java index 9b74d3597..829ff6c16 100644 --- a/src/test/java/org/apache/commons/lang3/CharSetUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/CharSetUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -41,17 +41,17 @@ public class CharSetUtilsTest { assertTrue(Modifier.isPublic(CharSetUtils.class.getModifiers())); assertFalse(Modifier.isFinal(CharSetUtils.class.getModifiers())); } - + //----------------------------------------------------------------------- @Test public void testSqueeze_StringString() { assertEquals(null, CharSetUtils.squeeze(null, (String) null)); assertEquals(null, CharSetUtils.squeeze(null, "")); - + assertEquals("", CharSetUtils.squeeze("", (String) null)); assertEquals("", CharSetUtils.squeeze("", "")); assertEquals("", CharSetUtils.squeeze("", "a-e")); - + assertEquals("hello", CharSetUtils.squeeze("hello", (String) null)); assertEquals("hello", CharSetUtils.squeeze("hello", "")); assertEquals("hello", CharSetUtils.squeeze("hello", "a-e")); @@ -59,24 +59,24 @@ public class CharSetUtilsTest { assertEquals("heloo", CharSetUtils.squeeze("helloo", "l")); assertEquals("hello", CharSetUtils.squeeze("helloo", "^l")); } - + @Test public void testSqueeze_StringStringarray() { assertEquals(null, CharSetUtils.squeeze(null, (String[]) null)); assertEquals(null, CharSetUtils.squeeze(null, new String[0])); assertEquals(null, CharSetUtils.squeeze(null, new String[] {null})); assertEquals(null, CharSetUtils.squeeze(null, new String[] {"el"})); - + assertEquals("", CharSetUtils.squeeze("", (String[]) null)); assertEquals("", CharSetUtils.squeeze("", new String[0])); assertEquals("", CharSetUtils.squeeze("", new String[] {null})); assertEquals("", CharSetUtils.squeeze("", new String[] {"a-e"})); - + assertEquals("hello", CharSetUtils.squeeze("hello", (String[]) null)); assertEquals("hello", CharSetUtils.squeeze("hello", new String[0])); assertEquals("hello", CharSetUtils.squeeze("hello", new String[] {null})); assertEquals("hello", CharSetUtils.squeeze("hello", new String[] {"a-e"})); - + assertEquals("helo", CharSetUtils.squeeze("hello", new String[] { "el" })); assertEquals("hello", CharSetUtils.squeeze("hello", new String[] { "e" })); assertEquals("fofof", CharSetUtils.squeeze("fooffooff", new String[] { "of" })); @@ -88,34 +88,34 @@ public class CharSetUtilsTest { public void testContainsAny_StringString() { assertFalse(CharSetUtils.containsAny(null, (String) null)); assertFalse(CharSetUtils.containsAny(null, "")); - + assertFalse(CharSetUtils.containsAny("", (String) null)); assertFalse(CharSetUtils.containsAny("", "")); assertFalse(CharSetUtils.containsAny("", "a-e")); - + assertFalse(CharSetUtils.containsAny("hello", (String) null)); assertFalse(CharSetUtils.containsAny("hello", "")); assertTrue(CharSetUtils.containsAny("hello", "a-e")); assertTrue(CharSetUtils.containsAny("hello", "l-p")); } - + @Test public void testContainsAny_StringStringarray() { assertFalse(CharSetUtils.containsAny(null, (String[]) null)); assertFalse(CharSetUtils.containsAny(null, new String[0])); assertFalse(CharSetUtils.containsAny(null, new String[] {null})); assertFalse(CharSetUtils.containsAny(null, new String[] {"a-e"})); - + assertFalse(CharSetUtils.containsAny("", (String[]) null)); assertFalse(CharSetUtils.containsAny("", new String[0])); assertFalse(CharSetUtils.containsAny("", new String[] {null})); assertFalse(CharSetUtils.containsAny("", new String[] {"a-e"})); - + assertFalse(CharSetUtils.containsAny("hello", (String[]) null)); assertFalse(CharSetUtils.containsAny("hello", new String[0])); assertFalse(CharSetUtils.containsAny("hello", new String[] {null})); assertTrue(CharSetUtils.containsAny("hello", new String[] {"a-e"})); - + assertTrue(CharSetUtils.containsAny("hello", new String[] { "el" })); assertFalse(CharSetUtils.containsAny("hello", new String[] { "x" })); assertTrue(CharSetUtils.containsAny("hello", new String[] { "e-i" })); @@ -128,34 +128,34 @@ public class CharSetUtilsTest { public void testCount_StringString() { assertEquals(0, CharSetUtils.count(null, (String) null)); assertEquals(0, CharSetUtils.count(null, "")); - + assertEquals(0, CharSetUtils.count("", (String) null)); assertEquals(0, CharSetUtils.count("", "")); assertEquals(0, CharSetUtils.count("", "a-e")); - + assertEquals(0, CharSetUtils.count("hello", (String) null)); assertEquals(0, CharSetUtils.count("hello", "")); assertEquals(1, CharSetUtils.count("hello", "a-e")); assertEquals(3, CharSetUtils.count("hello", "l-p")); } - + @Test public void testCount_StringStringarray() { assertEquals(0, CharSetUtils.count(null, (String[]) null)); assertEquals(0, CharSetUtils.count(null, new String[0])); assertEquals(0, CharSetUtils.count(null, new String[] {null})); assertEquals(0, CharSetUtils.count(null, new String[] {"a-e"})); - + assertEquals(0, CharSetUtils.count("", (String[]) null)); assertEquals(0, CharSetUtils.count("", new String[0])); assertEquals(0, CharSetUtils.count("", new String[] {null})); assertEquals(0, CharSetUtils.count("", new String[] {"a-e"})); - + assertEquals(0, CharSetUtils.count("hello", (String[]) null)); assertEquals(0, CharSetUtils.count("hello", new String[0])); assertEquals(0, CharSetUtils.count("hello", new String[] {null})); assertEquals(1, CharSetUtils.count("hello", new String[] {"a-e"})); - + assertEquals(3, CharSetUtils.count("hello", new String[] { "el" })); assertEquals(0, CharSetUtils.count("hello", new String[] { "x" })); assertEquals(2, CharSetUtils.count("hello", new String[] { "e-i" })); @@ -168,11 +168,11 @@ public class CharSetUtilsTest { public void testKeep_StringString() { assertEquals(null, CharSetUtils.keep(null, (String) null)); assertEquals(null, CharSetUtils.keep(null, "")); - + assertEquals("", CharSetUtils.keep("", (String) null)); assertEquals("", CharSetUtils.keep("", "")); assertEquals("", CharSetUtils.keep("", "a-e")); - + assertEquals("", CharSetUtils.keep("hello", (String) null)); assertEquals("", CharSetUtils.keep("hello", "")); assertEquals("", CharSetUtils.keep("hello", "xyz")); @@ -180,24 +180,24 @@ public class CharSetUtilsTest { assertEquals("hello", CharSetUtils.keep("hello", "oleh")); assertEquals("ell", CharSetUtils.keep("hello", "el")); } - + @Test public void testKeep_StringStringarray() { assertEquals(null, CharSetUtils.keep(null, (String[]) null)); assertEquals(null, CharSetUtils.keep(null, new String[0])); assertEquals(null, CharSetUtils.keep(null, new String[] {null})); assertEquals(null, CharSetUtils.keep(null, new String[] {"a-e"})); - + assertEquals("", CharSetUtils.keep("", (String[]) null)); assertEquals("", CharSetUtils.keep("", new String[0])); assertEquals("", CharSetUtils.keep("", new String[] {null})); assertEquals("", CharSetUtils.keep("", new String[] {"a-e"})); - + assertEquals("", CharSetUtils.keep("hello", (String[]) null)); assertEquals("", CharSetUtils.keep("hello", new String[0])); assertEquals("", CharSetUtils.keep("hello", new String[] {null})); assertEquals("e", CharSetUtils.keep("hello", new String[] {"a-e"})); - + assertEquals("e", CharSetUtils.keep("hello", new String[] { "a-e" })); assertEquals("ell", CharSetUtils.keep("hello", new String[] { "el" })); assertEquals("hello", CharSetUtils.keep("hello", new String[] { "elho" })); @@ -211,30 +211,30 @@ public class CharSetUtilsTest { public void testDelete_StringString() { assertEquals(null, CharSetUtils.delete(null, (String) null)); assertEquals(null, CharSetUtils.delete(null, "")); - + assertEquals("", CharSetUtils.delete("", (String) null)); assertEquals("", CharSetUtils.delete("", "")); assertEquals("", CharSetUtils.delete("", "a-e")); - + assertEquals("hello", CharSetUtils.delete("hello", (String) null)); assertEquals("hello", CharSetUtils.delete("hello", "")); assertEquals("hllo", CharSetUtils.delete("hello", "a-e")); assertEquals("he", CharSetUtils.delete("hello", "l-p")); assertEquals("hello", CharSetUtils.delete("hello", "z")); } - + @Test public void testDelete_StringStringarray() { assertEquals(null, CharSetUtils.delete(null, (String[]) null)); assertEquals(null, CharSetUtils.delete(null, new String[0])); assertEquals(null, CharSetUtils.delete(null, new String[] {null})); assertEquals(null, CharSetUtils.delete(null, new String[] {"el"})); - + assertEquals("", CharSetUtils.delete("", (String[]) null)); assertEquals("", CharSetUtils.delete("", new String[0])); assertEquals("", CharSetUtils.delete("", new String[] {null})); assertEquals("", CharSetUtils.delete("", new String[] {"a-e"})); - + assertEquals("hello", CharSetUtils.delete("hello", (String[]) null)); assertEquals("hello", CharSetUtils.delete("hello", new String[0])); assertEquals("hello", CharSetUtils.delete("hello", new String[] {null})); @@ -248,5 +248,5 @@ public class CharSetUtilsTest { assertEquals("", CharSetUtils.delete("----", new String[] { "-" })); assertEquals("heo", CharSetUtils.delete("hello", new String[] { "l" })); } - + } diff --git a/src/test/java/org/apache/commons/lang3/CharUtilsPerfRun.java b/src/test/java/org/apache/commons/lang3/CharUtilsPerfRun.java index 5cc4e2fac..7ab88b2ba 100644 --- a/src/test/java/org/apache/commons/lang3/CharUtilsPerfRun.java +++ b/src/test/java/org/apache/commons/lang3/CharUtilsPerfRun.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,7 +22,7 @@ import java.util.Calendar; /** * Tests the difference in performance between CharUtils and CharSet. - * + * * Sample runs: Now: Thu Mar 18 14:29:48 PST 2004 diff --git a/src/test/java/org/apache/commons/lang3/CharUtilsTest.java b/src/test/java/org/apache/commons/lang3/CharUtilsTest.java index ea68ada86..bd92c3355 100644 --- a/src/test/java/org/apache/commons/lang3/CharUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/CharUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -35,7 +35,7 @@ public class CharUtilsTest { private static final Character CHARACTER_A = new Character('A'); private static final Character CHARACTER_B = new Character('B'); private static final char CHAR_COPY = '\u00a9'; - + @Test public void testConstructor() { assertNotNull(new CharUtils()); @@ -45,13 +45,13 @@ public class CharUtilsTest { assertTrue(Modifier.isPublic(BooleanUtils.class.getModifiers())); assertFalse(Modifier.isFinal(BooleanUtils.class.getModifiers())); } - + @SuppressWarnings("deprecation") // intentional test of deprecated method @Test public void testToCharacterObject_char() { assertEquals(new Character('a'), CharUtils.toCharacterObject('a')); assertSame(CharUtils.toCharacterObject('a'), CharUtils.toCharacterObject('a')); - + for (int i = 0; i < 128; i++) { final Character ch = CharUtils.toCharacterObject((char) i); final Character ch2 = CharUtils.toCharacterObject((char) i); @@ -68,7 +68,7 @@ public class CharUtilsTest { } assertSame(CharUtils.toCharacterObject("a"), CharUtils.toCharacterObject('a')); } - + @Test public void testToCharacterObject_String() { assertEquals(null, CharUtils.toCharacterObject(null)); @@ -77,7 +77,7 @@ public class CharUtilsTest { assertEquals(new Character('a'), CharUtils.toCharacterObject("abc")); assertSame(CharUtils.toCharacterObject("a"), CharUtils.toCharacterObject("a")); } - + @Test public void testToChar_Character() { assertEquals('A', CharUtils.toChar(CHARACTER_A)); @@ -86,14 +86,14 @@ public class CharUtilsTest { CharUtils.toChar((Character) null); } catch (final IllegalArgumentException ex) {} } - + @Test public void testToChar_Character_char() { assertEquals('A', CharUtils.toChar(CHARACTER_A, 'X')); assertEquals('B', CharUtils.toChar(CHARACTER_B, 'X')); assertEquals('X', CharUtils.toChar((Character) null, 'X')); } - + @Test public void testToChar_String() { assertEquals('A', CharUtils.toChar("A")); @@ -105,7 +105,7 @@ public class CharUtilsTest { CharUtils.toChar(""); } catch (final IllegalArgumentException ex) {} } - + @Test public void testToChar_String_char() { assertEquals('A', CharUtils.toChar("A", 'X')); @@ -113,7 +113,7 @@ public class CharUtilsTest { assertEquals('X', CharUtils.toChar("", 'X')); assertEquals('X', CharUtils.toChar((String) null, 'X')); } - + @Test public void testToIntValue_char() { assertEquals(0, CharUtils.toIntValue('0')); @@ -130,14 +130,14 @@ public class CharUtilsTest { CharUtils.toIntValue('a'); } catch (final IllegalArgumentException ex) {} } - + @Test public void testToIntValue_char_int() { assertEquals(0, CharUtils.toIntValue('0', -1)); assertEquals(3, CharUtils.toIntValue('3', -1)); assertEquals(-1, CharUtils.toIntValue('a', -1)); } - + @Test public void testToIntValue_Character() { assertEquals(0, CharUtils.toIntValue(new Character('0'))); @@ -149,7 +149,7 @@ public class CharUtilsTest { CharUtils.toIntValue(CHARACTER_A); } catch (final IllegalArgumentException ex) {} } - + @Test public void testToIntValue_Character_int() { assertEquals(0, CharUtils.toIntValue(new Character('0'), -1)); @@ -157,12 +157,12 @@ public class CharUtilsTest { assertEquals(-1, CharUtils.toIntValue(new Character('A'), -1)); assertEquals(-1, CharUtils.toIntValue(null, -1)); } - + @Test public void testToString_char() { assertEquals("a", CharUtils.toString('a')); assertSame(CharUtils.toString('a'), CharUtils.toString('a')); - + for (int i = 0; i < 128; i++) { final String str = CharUtils.toString((char) i); final String str2 = CharUtils.toString((char) i); @@ -181,19 +181,19 @@ public class CharUtilsTest { assertEquals(i, str2.charAt(0)); } } - + @Test public void testToString_Character() { assertEquals(null, CharUtils.toString(null)); assertEquals("A", CharUtils.toString(CHARACTER_A)); assertSame(CharUtils.toString(CHARACTER_A), CharUtils.toString(CHARACTER_A)); } - + @Test public void testToUnicodeEscaped_char() { assertEquals("\\u0041", CharUtils.unicodeEscaped('A')); assertEquals("\\u004c", CharUtils.unicodeEscaped('L')); - + for (int i = 0; i < 196; i++) { final String str = CharUtils.unicodeEscaped((char) i); assertEquals(6, str.length()); @@ -203,13 +203,13 @@ public class CharUtilsTest { assertEquals("\\u0999", CharUtils.unicodeEscaped((char) 0x999)); assertEquals("\\u1001", CharUtils.unicodeEscaped((char) 0x1001)); } - + @Test public void testToUnicodeEscaped_Character() { assertEquals(null, CharUtils.unicodeEscaped(null)); assertEquals("\\u0041", CharUtils.unicodeEscaped(CHARACTER_A)); } - + @Test public void testIsAscii_char() { assertTrue(CharUtils.isAscii('a')); @@ -218,7 +218,7 @@ public class CharUtilsTest { assertTrue(CharUtils.isAscii('-')); assertTrue(CharUtils.isAscii('\n')); assertFalse(CharUtils.isAscii(CHAR_COPY)); - + for (int i = 0; i < 128; i++) { if (i < 128) { assertTrue(CharUtils.isAscii((char) i)); @@ -227,7 +227,7 @@ public class CharUtilsTest { } } } - + @Test public void testIsAsciiPrintable_char() { assertTrue(CharUtils.isAsciiPrintable('a')); @@ -236,7 +236,7 @@ public class CharUtilsTest { assertTrue(CharUtils.isAsciiPrintable('-')); assertFalse(CharUtils.isAsciiPrintable('\n')); assertFalse(CharUtils.isAsciiPrintable(CHAR_COPY)); - + for (int i = 0; i < 196; i++) { if (i >= 32 && i <= 126) { assertTrue(CharUtils.isAsciiPrintable((char) i)); @@ -245,7 +245,7 @@ public class CharUtilsTest { } } } - + @Test public void testIsAsciiControl_char() { assertFalse(CharUtils.isAsciiControl('a')); @@ -254,7 +254,7 @@ public class CharUtilsTest { assertFalse(CharUtils.isAsciiControl('-')); assertTrue(CharUtils.isAsciiControl('\n')); assertFalse(CharUtils.isAsciiControl(CHAR_COPY)); - + for (int i = 0; i < 196; i++) { if (i < 32 || i == 127) { assertTrue(CharUtils.isAsciiControl((char) i)); @@ -263,7 +263,7 @@ public class CharUtilsTest { } } } - + @Test public void testIsAsciiAlpha_char() { assertTrue(CharUtils.isAsciiAlpha('a')); @@ -272,7 +272,7 @@ public class CharUtilsTest { assertFalse(CharUtils.isAsciiAlpha('-')); assertFalse(CharUtils.isAsciiAlpha('\n')); assertFalse(CharUtils.isAsciiAlpha(CHAR_COPY)); - + for (int i = 0; i < 196; i++) { if ((i >= 'A' && i <= 'Z') || (i >= 'a' && i <= 'z')) { assertTrue(CharUtils.isAsciiAlpha((char) i)); @@ -281,7 +281,7 @@ public class CharUtilsTest { } } } - + @Test public void testIsAsciiAlphaUpper_char() { assertFalse(CharUtils.isAsciiAlphaUpper('a')); @@ -290,7 +290,7 @@ public class CharUtilsTest { assertFalse(CharUtils.isAsciiAlphaUpper('-')); assertFalse(CharUtils.isAsciiAlphaUpper('\n')); assertFalse(CharUtils.isAsciiAlphaUpper(CHAR_COPY)); - + for (int i = 0; i < 196; i++) { if (i >= 'A' && i <= 'Z') { assertTrue(CharUtils.isAsciiAlphaUpper((char) i)); @@ -299,7 +299,7 @@ public class CharUtilsTest { } } } - + @Test public void testIsAsciiAlphaLower_char() { assertTrue(CharUtils.isAsciiAlphaLower('a')); @@ -308,7 +308,7 @@ public class CharUtilsTest { assertFalse(CharUtils.isAsciiAlphaLower('-')); assertFalse(CharUtils.isAsciiAlphaLower('\n')); assertFalse(CharUtils.isAsciiAlphaLower(CHAR_COPY)); - + for (int i = 0; i < 196; i++) { if (i >= 'a' && i <= 'z') { assertTrue(CharUtils.isAsciiAlphaLower((char) i)); @@ -317,7 +317,7 @@ public class CharUtilsTest { } } } - + @Test public void testIsAsciiNumeric_char() { assertFalse(CharUtils.isAsciiNumeric('a')); @@ -326,7 +326,7 @@ public class CharUtilsTest { assertFalse(CharUtils.isAsciiNumeric('-')); assertFalse(CharUtils.isAsciiNumeric('\n')); assertFalse(CharUtils.isAsciiNumeric(CHAR_COPY)); - + for (int i = 0; i < 196; i++) { if (i >= '0' && i <= '9') { assertTrue(CharUtils.isAsciiNumeric((char) i)); @@ -335,7 +335,7 @@ public class CharUtilsTest { } } } - + @Test public void testIsAsciiAlphanumeric_char() { assertTrue(CharUtils.isAsciiAlphanumeric('a')); @@ -344,7 +344,7 @@ public class CharUtilsTest { assertFalse(CharUtils.isAsciiAlphanumeric('-')); assertFalse(CharUtils.isAsciiAlphanumeric('\n')); assertFalse(CharUtils.isAsciiAlphanumeric(CHAR_COPY)); - + for (int i = 0; i < 196; i++) { if ((i >= 'A' && i <= 'Z') || (i >= 'a' && i <= 'z') || (i >= '0' && i <= '9')) { assertTrue(CharUtils.isAsciiAlphanumeric((char) i)); diff --git a/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java b/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java index 744aaa837..a31c78ce2 100644 --- a/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/ClassUtilsTest.java @@ -114,7 +114,7 @@ public class ClassUtilsTest { assertEquals("String[][]", ClassUtils.getShortClassName(String[][].class)); assertEquals("String[][][]", ClassUtils.getShortClassName(String[][][].class)); assertEquals("String[][][][]", ClassUtils.getShortClassName(String[][][][].class)); - + // Inner types class Named {} assertEquals("ClassUtilsTest.2", ClassUtils.getShortClassName(new Object(){}.getClass())); @@ -166,7 +166,7 @@ public class ClassUtilsTest { assertEquals("String[][]", ClassUtils.getSimpleName(String[][].class)); assertEquals("String[][][]", ClassUtils.getSimpleName(String[][][].class)); assertEquals("String[][][][]", ClassUtils.getSimpleName(String[][][][].class)); - + // On-the-fly types class Named {} assertEquals("", ClassUtils.getSimpleName(new Object(){}.getClass())); @@ -212,7 +212,7 @@ public class ClassUtilsTest { assertEquals("java.lang", ClassUtils.getPackageName(String[][].class)); assertEquals("java.lang", ClassUtils.getPackageName(String[][][].class)); assertEquals("java.lang", ClassUtils.getPackageName(String[][][][].class)); - + // On-the-fly types class Named {} assertEquals("org.apache.commons.lang3", ClassUtils.getPackageName(new Object() { @@ -783,7 +783,7 @@ public class ClassUtilsTest { assertTrue("Long.class", ClassUtils.isPrimitiveOrWrapper(Long.class)); assertTrue("Double.class", ClassUtils.isPrimitiveOrWrapper(Double.class)); assertTrue("Float.class", ClassUtils.isPrimitiveOrWrapper(Float.class)); - + // test primitive classes assertTrue("boolean", ClassUtils.isPrimitiveOrWrapper(Boolean.TYPE)); assertTrue("byte", ClassUtils.isPrimitiveOrWrapper(Byte.TYPE)); @@ -794,14 +794,14 @@ public class ClassUtilsTest { assertTrue("double", ClassUtils.isPrimitiveOrWrapper(Double.TYPE)); assertTrue("float", ClassUtils.isPrimitiveOrWrapper(Float.TYPE)); assertTrue("Void.TYPE", ClassUtils.isPrimitiveOrWrapper(Void.TYPE)); - + // others assertFalse("null", ClassUtils.isPrimitiveOrWrapper(null)); assertFalse("Void.class", ClassUtils.isPrimitiveOrWrapper(Void.class)); assertFalse("String.class", ClassUtils.isPrimitiveOrWrapper(String.class)); assertFalse("this.getClass()", ClassUtils.isPrimitiveOrWrapper(this.getClass())); } - + @Test public void testIsPrimitiveWrapper() { @@ -814,7 +814,7 @@ public class ClassUtilsTest { assertTrue("Long.class", ClassUtils.isPrimitiveWrapper(Long.class)); assertTrue("Double.class", ClassUtils.isPrimitiveWrapper(Double.class)); assertTrue("Float.class", ClassUtils.isPrimitiveWrapper(Float.class)); - + // test primitive classes assertFalse("boolean", ClassUtils.isPrimitiveWrapper(Boolean.TYPE)); assertFalse("byte", ClassUtils.isPrimitiveWrapper(Byte.TYPE)); @@ -824,7 +824,7 @@ public class ClassUtilsTest { assertFalse("long", ClassUtils.isPrimitiveWrapper(Long.TYPE)); assertFalse("double", ClassUtils.isPrimitiveWrapper(Double.TYPE)); assertFalse("float", ClassUtils.isPrimitiveWrapper(Float.TYPE)); - + // others assertFalse("null", ClassUtils.isPrimitiveWrapper(null)); assertFalse("Void.class", ClassUtils.isPrimitiveWrapper(Void.class)); @@ -832,7 +832,7 @@ public class ClassUtilsTest { assertFalse("String.class", ClassUtils.isPrimitiveWrapper(String.class)); assertFalse("this.getClass()", ClassUtils.isPrimitiveWrapper(this.getClass())); } - + @Test public void testPrimitiveToWrapper() { @@ -1127,7 +1127,7 @@ public class ClassUtilsTest { public void testToClass_object() { // assertNull(ClassUtils.toClass(null)); // generates warning assertNull(ClassUtils.toClass((Object[]) null)); // equivalent explicit cast - + // Additional varargs tests assertTrue("empty -> empty", Arrays.equals(ArrayUtils.EMPTY_CLASS_ARRAY, ClassUtils.toClass())); final Class<?>[] castNull = ClassUtils.toClass((Object) null); // == new Object[]{null} @@ -1165,7 +1165,7 @@ public class ClassUtilsTest { assertEquals("ClassUtils[][]", ClassUtils.getShortCanonicalName(ClassUtils[][].class)); assertEquals("int[]", ClassUtils.getShortCanonicalName(int[].class)); assertEquals("int[][]", ClassUtils.getShortCanonicalName(int[][].class)); - + // Inner types class Named {} assertEquals("ClassUtilsTest.7", ClassUtils.getShortCanonicalName(new Object(){}.getClass())); @@ -1184,7 +1184,7 @@ public class ClassUtilsTest { assertEquals("int[][]", ClassUtils.getShortCanonicalName("[[I")); assertEquals("int[]", ClassUtils.getShortCanonicalName("int[]")); assertEquals("int[][]", ClassUtils.getShortCanonicalName("int[][]")); - + // Inner types assertEquals("ClassUtilsTest.6", ClassUtils.getShortCanonicalName("org.apache.commons.lang3.ClassUtilsTest$6")); assertEquals("ClassUtilsTest.5Named", ClassUtils.getShortCanonicalName("org.apache.commons.lang3.ClassUtilsTest$5Named")); @@ -1199,7 +1199,7 @@ public class ClassUtilsTest { assertEquals("org.apache.commons.lang3", ClassUtils.getPackageCanonicalName(new ClassUtils[0][0], "<null>")); assertEquals("", ClassUtils.getPackageCanonicalName(new int[0], "<null>")); assertEquals("", ClassUtils.getPackageCanonicalName(new int[0][0], "<null>")); - + // Inner types class Named {} assertEquals("org.apache.commons.lang3", ClassUtils.getPackageCanonicalName(new Object(){}, "<null>")); @@ -1214,7 +1214,7 @@ public class ClassUtilsTest { assertEquals("org.apache.commons.lang3", ClassUtils.getPackageCanonicalName(ClassUtils[][].class)); assertEquals("", ClassUtils.getPackageCanonicalName(int[].class)); assertEquals("", ClassUtils.getPackageCanonicalName(int[][].class)); - + // Inner types class Named {} assertEquals("org.apache.commons.lang3", ClassUtils.getPackageCanonicalName(new Object(){}.getClass())); @@ -1238,7 +1238,7 @@ public class ClassUtilsTest { assertEquals("", ClassUtils.getPackageCanonicalName("[[I")); assertEquals("", ClassUtils.getPackageCanonicalName("int[]")); assertEquals("", ClassUtils.getPackageCanonicalName("int[][]")); - + // Inner types assertEquals("org.apache.commons.lang3", ClassUtils.getPackageCanonicalName("org.apache.commons.lang3.ClassUtilsTest$6")); assertEquals("org.apache.commons.lang3", ClassUtils.getPackageCanonicalName("org.apache.commons.lang3.ClassUtilsTest$5Named")); diff --git a/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java b/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java index 5845ef6d5..bb425d492 100644 --- a/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/EnumUtilsTest.java @@ -32,7 +32,7 @@ import org.junit.Assert; import org.junit.Test; /** - * + * */ public class EnumUtilsTest { @@ -102,7 +102,7 @@ public class EnumUtilsTest { public void test_generateBitVectors_nullClass() { EnumUtils.generateBitVectors(null, EnumSet.of(Traffic.RED)); } - + @Test(expected=NullPointerException.class) public void test_generateBitVector_nullIterable() { EnumUtils.generateBitVector(Traffic.class, (Iterable<Traffic>) null); @@ -112,27 +112,27 @@ public class EnumUtilsTest { public void test_generateBitVectors_nullIterable() { EnumUtils.generateBitVectors(null, (Iterable<Traffic>) null); } - + @Test(expected=IllegalArgumentException.class) public void test_generateBitVector_nullElement() { EnumUtils.generateBitVector(Traffic.class, Arrays.asList(Traffic.RED, null)); } - + @Test(expected=IllegalArgumentException.class) public void test_generateBitVectors_nullElement() { EnumUtils.generateBitVectors(Traffic.class, Arrays.asList(Traffic.RED, null)); } - + @Test(expected=NullPointerException.class) public void test_generateBitVector_nullClassWithArray() { EnumUtils.generateBitVector(null, Traffic.RED); } - + @Test(expected=NullPointerException.class) public void test_generateBitVectors_nullClassWithArray() { EnumUtils.generateBitVectors(null, Traffic.RED); } - + @Test(expected=NullPointerException.class) public void test_generateBitVector_nullArray() { EnumUtils.generateBitVector(Traffic.class, (Traffic[]) null); @@ -142,17 +142,17 @@ public class EnumUtilsTest { public void test_generateBitVectors_nullArray() { EnumUtils.generateBitVectors(Traffic.class, (Traffic[]) null); } - + @Test(expected=IllegalArgumentException.class) public void test_generateBitVector_nullArrayElement() { EnumUtils.generateBitVector(Traffic.class, Traffic.RED, null); } - + @Test(expected=IllegalArgumentException.class) public void test_generateBitVectors_nullArrayElement() { EnumUtils.generateBitVectors(Traffic.class, Traffic.RED, null); } - + @Test(expected=IllegalArgumentException.class) public void test_generateBitVector_longClass() { EnumUtils.generateBitVector(TooMany.class, EnumSet.of(TooMany.A1)); @@ -174,7 +174,7 @@ public class EnumUtilsTest { List rawList = new ArrayList(); EnumUtils.generateBitVector(rawType, rawList); } - + @SuppressWarnings("unchecked") @Test(expected=IllegalArgumentException.class) public void test_generateBitVectors_nonEnumClass() { @@ -186,7 +186,7 @@ public class EnumUtilsTest { List rawList = new ArrayList(); EnumUtils.generateBitVectors(rawType, rawList); } - + @SuppressWarnings("unchecked") @Test(expected=IllegalArgumentException.class) public void test_generateBitVector_nonEnumClassWithArray() { @@ -204,7 +204,7 @@ public class EnumUtilsTest { Class rawType = Object.class; EnumUtils.generateBitVectors(rawType); } - + @Test public void test_generateBitVector() { assertEquals(0L, EnumUtils.generateBitVector(Traffic.class, EnumSet.noneOf(Traffic.class))); @@ -264,7 +264,7 @@ public class EnumUtilsTest { assertEquals((1L << 63), EnumUtils.generateBitVector(Enum64.class, Enum64.A63)); assertEquals(Long.MIN_VALUE, EnumUtils.generateBitVector(Enum64.class, Enum64.A63)); } - + @Test public void test_generateBitVectorsFromArray() { assertArrayEquals(EnumUtils.generateBitVectors(Traffic.class), 0L); @@ -365,7 +365,7 @@ public class EnumUtilsTest { public void test_processBitVector_longClass() { EnumUtils.processBitVector(TooMany.class, 0L); } - + public void test_processBitVectors_longClass() { assertEquals(EnumSet.noneOf(TooMany.class), EnumUtils.processBitVectors(TooMany.class, 0L)); assertEquals(EnumSet.of(TooMany.A), EnumUtils.processBitVectors(TooMany.class, 1L)); diff --git a/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java b/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java index 97fe71492..5c04cd6ee 100644 --- a/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java +++ b/src/test/java/org/apache/commons/lang3/HashSetvBitSetTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -64,7 +64,7 @@ public class HashSetvBitSetTest { toRemove.set(10, 20); return (int[]) ArrayUtils.removeAll(array, toRemove); } - + @Benchmark public int[] timeExtractRemoveAll() { final BitSet toRemove = new BitSet(); @@ -89,7 +89,7 @@ public class HashSetvBitSetTest { int i = 0; int j=0; while((j=coll.nextSetBit(j)) != -1) { - result[i++] = j++; + result[i++] = j++; } return result; } diff --git a/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java b/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java index bbb93de28..1c39a7731 100644 --- a/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/LocaleUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -49,7 +49,7 @@ public class LocaleUtilsTest { private static final Locale LOCALE_FR = new Locale("fr", ""); private static final Locale LOCALE_FR_CA = new Locale("fr", "CA"); private static final Locale LOCALE_QQ = new Locale("qq", ""); - private static final Locale LOCALE_QQ_ZZ = new Locale("qq", "ZZ"); + private static final Locale LOCALE_QQ_ZZ = new Locale("qq", "ZZ"); @Before public void setUp() throws Exception { @@ -111,7 +111,7 @@ public class LocaleUtilsTest { * @param variant of the resulting Locale */ private static void assertValidToLocale( - final String localeString, final String language, + final String localeString, final String language, final String country, final String variant) { final Locale locale = LocaleUtils.toLocale(localeString); assertNotNull("valid locale", locale); @@ -126,7 +126,7 @@ public class LocaleUtilsTest { @Test public void testToLocale_1Part() { assertNull(LocaleUtils.toLocale(null)); - + assertValidToLocale("us"); assertValidToLocale("fr"); assertValidToLocale("de"); @@ -152,7 +152,7 @@ public class LocaleUtilsTest { LocaleUtils.toLocale("u#"); fail("Should fail if not lowercase"); } catch (final IllegalArgumentException iae) {} - + try { LocaleUtils.toLocale("u"); fail("Must be 2 chars if less than 5"); @@ -162,7 +162,7 @@ public class LocaleUtilsTest { LocaleUtils.toLocale("uu_U"); fail("Must be 2 chars if less than 5"); } catch (final IllegalArgumentException iae) {} - } + } /** * Test toLocale() method. @@ -172,7 +172,7 @@ public class LocaleUtilsTest { assertValidToLocale("us_EN", "us", "EN"); //valid though doesn't exist assertValidToLocale("us_ZH", "us", "ZH"); - + try { LocaleUtils.toLocale("us-EN"); fail("Should fail as not underscore"); @@ -197,7 +197,7 @@ public class LocaleUtilsTest { LocaleUtils.toLocale("us_E3"); fail("Should fail second part not uppercase"); } catch (final IllegalArgumentException iae) {} - } + } /** * Test toLocale() method. @@ -214,7 +214,7 @@ public class LocaleUtilsTest { assertValidToLocale("us_EN_a", "us", "EN", "A"); assertValidToLocale("us_EN_SFsafdFDsdfF", "us", "EN", "SFSAFDFDSDFF"); } - + try { LocaleUtils.toLocale("us_EN-a"); fail("Should fail as not underscore"); @@ -237,7 +237,7 @@ public class LocaleUtilsTest { final List<Locale> localeList = defaultLocale == null ? LocaleUtils.localeLookupList(locale) : LocaleUtils.localeLookupList(locale, defaultLocale); - + assertEquals(expected.length, localeList.size()); assertEquals(Arrays.asList(expected), localeList); assertUnmodifiableCollection(localeList); @@ -262,19 +262,19 @@ public class LocaleUtilsTest { LOCALE_EN_US_ZZZZ, LOCALE_EN_US, LOCALE_EN}); - } + } /** * Test localeLookupList() method. */ @Test public void testLocaleLookupList_LocaleLocale() { - assertLocaleLookupList(LOCALE_QQ, LOCALE_QQ, + assertLocaleLookupList(LOCALE_QQ, LOCALE_QQ, new Locale[]{LOCALE_QQ}); - assertLocaleLookupList(LOCALE_EN, LOCALE_EN, + assertLocaleLookupList(LOCALE_EN, LOCALE_EN, new Locale[]{LOCALE_EN}); - - assertLocaleLookupList(LOCALE_EN_US, LOCALE_EN_US, + + assertLocaleLookupList(LOCALE_EN_US, LOCALE_EN_US, new Locale[]{ LOCALE_EN_US, LOCALE_EN}); @@ -288,7 +288,7 @@ public class LocaleUtilsTest { LOCALE_EN_US, LOCALE_EN, LOCALE_QQ_ZZ}); - + assertLocaleLookupList(LOCALE_EN_US_ZZZZ, null, new Locale[] { LOCALE_EN_US_ZZZZ, @@ -329,7 +329,7 @@ public class LocaleUtilsTest { assertNotNull(list); assertSame(list, list2); assertUnmodifiableCollection(list); - + final Locale[] jdkLocaleArray = Locale.getAvailableLocales(); final List<Locale> jdkLocaleList = Arrays.asList(jdkLocaleArray); assertEquals(jdkLocaleList, list); @@ -346,7 +346,7 @@ public class LocaleUtilsTest { assertNotNull(set); assertSame(set, set2); assertUnmodifiableCollection(set); - + final Locale[] jdkLocaleArray = Locale.getAvailableLocales(); final List<Locale> jdkLocaleList = Arrays.asList(jdkLocaleArray); final Set<Locale> jdkLocaleSet = new HashSet<>(jdkLocaleList); @@ -369,10 +369,10 @@ public class LocaleUtilsTest { assertEquals(set.contains(LOCALE_QQ), LocaleUtils.isAvailableLocale(LOCALE_QQ)); assertEquals(set.contains(LOCALE_QQ_ZZ), LocaleUtils.isAvailableLocale(LOCALE_QQ_ZZ)); } - + /** * Test for 3-chars locale, further details at LANG-915 - * + * */ @Test public void testThreeCharsLocale() { @@ -387,9 +387,9 @@ public class LocaleUtilsTest { //----------------------------------------------------------------------- /** - * Make sure the language by country is correct. It checks that - * the LocaleUtils.languagesByCountry(country) call contains the - * array of languages passed in. It may contain more due to JVM + * Make sure the language by country is correct. It checks that + * the LocaleUtils.languagesByCountry(country) call contains the + * array of languages passed in. It may contain more due to JVM * variations. * * @param country @@ -437,9 +437,9 @@ public class LocaleUtilsTest { //----------------------------------------------------------------------- /** - * Make sure the country by language is correct. It checks that - * the LocaleUtils.countryByLanguage(language) call contains the - * array of countries passed in. It may contain more due to JVM + * Make sure the country by language is correct. It checks that + * the LocaleUtils.countryByLanguage(language) call contains the + * array of countries passed in. It may contain more due to JVM * variations. * * diff --git a/src/test/java/org/apache/commons/lang3/NotImplementedExceptionTest.java b/src/test/java/org/apache/commons/lang3/NotImplementedExceptionTest.java index ff422ae61..86f4fab8d 100644 --- a/src/test/java/org/apache/commons/lang3/NotImplementedExceptionTest.java +++ b/src/test/java/org/apache/commons/lang3/NotImplementedExceptionTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java b/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java index a5f7e1a8c..c1d6dcc0e 100644 --- a/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -75,13 +75,13 @@ public class ObjectUtilsTest { assertEquals("123", firstNonNullGenerics); assertEquals("123", ObjectUtils.firstNonNull("123", null, "456", null)); assertSame(Boolean.TRUE, ObjectUtils.firstNonNull(Boolean.TRUE)); - + // Explicitly pass in an empty array of Object type to ensure compiler doesn't complain of unchecked generic array creation assertNull(ObjectUtils.firstNonNull(new Object[0])); - + // Cast to Object in line below ensures compiler doesn't complain of unchecked generic array creation assertNull(ObjectUtils.firstNonNull(null, null)); - + assertNull(ObjectUtils.firstNonNull((Object) null)); assertNull(ObjectUtils.firstNonNull((Object[]) null)); } @@ -159,13 +159,13 @@ public class ObjectUtilsTest { public void testHashCodeMulti_multiple_likeList() { final List<Object> list0 = new ArrayList<>(Arrays.asList(new Object[0])); assertEquals(list0.hashCode(), ObjectUtils.hashCodeMulti()); - + final List<Object> list1 = new ArrayList<Object>(Arrays.asList("a")); assertEquals(list1.hashCode(), ObjectUtils.hashCodeMulti("a")); - + final List<Object> list2 = new ArrayList<Object>(Arrays.asList("a", "b")); assertEquals(list2.hashCode(), ObjectUtils.hashCodeMulti("a", "b")); - + final List<Object> list3 = new ArrayList<Object>(Arrays.asList("a", "b", "c")); assertEquals(list3.hashCode(), ObjectUtils.hashCodeMulti("a", "b", "c")); } @@ -190,7 +190,7 @@ public class ObjectUtilsTest { } catch(final NullPointerException npe) { } } - + @Test public void testIdentityToStringStringBuilder() { assertEquals(null, ObjectUtils.identityToString(null)); @@ -199,9 +199,9 @@ public class ObjectUtilsTest { ObjectUtils.identityToString(FOO)); final Integer i = Integer.valueOf(90); final String expected = "java.lang.Integer@" + Integer.toHexString(System.identityHashCode(i)); - + assertEquals(expected, ObjectUtils.identityToString(i)); - + final StringBuilder builder = new StringBuilder(); ObjectUtils.identityToString(builder, i); assertEquals(expected, builder.toString()); @@ -211,14 +211,14 @@ public class ObjectUtilsTest { fail("NullPointerException expected"); } catch(final NullPointerException npe) { } - + try { ObjectUtils.identityToString(new StringBuilder(), null); fail("NullPointerException expected"); } catch(final NullPointerException npe) { } } - + @Test public void testIdentityToStringStrBuilder() { final Integer i = Integer.valueOf(102); @@ -233,14 +233,14 @@ public class ObjectUtilsTest { fail("NullPointerException expected"); } catch(final NullPointerException npe) { } - + try { ObjectUtils.identityToString(new StrBuilder(), null); fail("NullPointerException expected"); } catch(final NullPointerException npe) { } } - + @Test public void testIdentityToStringAppendable() { final Integer i = Integer.valueOf(121); @@ -253,7 +253,7 @@ public class ObjectUtilsTest { } catch(final IOException ex) { fail("IOException unexpected"); } - + try { ObjectUtils.identityToString((Appendable)null, "tmp"); fail("NullPointerException expected"); @@ -298,12 +298,12 @@ public class ObjectUtilsTest { final Date nonNullComparable1 = calendar.getTime(); final Date nonNullComparable2 = calendar.getTime(); final String[] nullArray = null; - + calendar.set( Calendar.YEAR, calendar.get( Calendar.YEAR ) -1 ); final Date minComparable = calendar.getTime(); - + assertNotSame( nonNullComparable1, nonNullComparable2 ); - + assertNull(ObjectUtils.max( (String) null ) ); assertNull(ObjectUtils.max( nullArray ) ); assertSame( nonNullComparable1, ObjectUtils.max( null, nonNullComparable1 ) ); @@ -324,12 +324,12 @@ public class ObjectUtilsTest { final Date nonNullComparable1 = calendar.getTime(); final Date nonNullComparable2 = calendar.getTime(); final String[] nullArray = null; - + calendar.set( Calendar.YEAR, calendar.get( Calendar.YEAR ) -1 ); final Date minComparable = calendar.getTime(); - + assertNotSame( nonNullComparable1, nonNullComparable2 ); - + assertNull(ObjectUtils.min( (String) null ) ); assertNull(ObjectUtils.min( nullArray ) ); assertSame( nonNullComparable1, ObjectUtils.min( null, nonNullComparable1 ) ); @@ -358,7 +358,7 @@ public class ObjectUtilsTest { assertEquals("Null one false", -1, ObjectUtils.compare(nullValue, one)); assertEquals("Null one true", 1, ObjectUtils.compare(nullValue, one, true)); - + assertEquals("one Null false", 1, ObjectUtils.compare(one, nullValue)); assertEquals("one Null true", -1, ObjectUtils.compare(one, nullValue, true)); diff --git a/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java b/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java index 68d10d2b0..d3ed6312d 100644 --- a/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/RandomStringUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -50,7 +50,7 @@ public class RandomStringUtilsTest { assertTrue(Modifier.isPublic(RandomStringUtils.class.getModifiers())); assertFalse(Modifier.isFinal(RandomStringUtils.class.getModifiers())); } - + //----------------------------------------------------------------------- /** * Test the implementation @@ -62,12 +62,12 @@ public class RandomStringUtilsTest { String r2 = RandomStringUtils.random(50); assertEquals("random(50) length", 50, r2.length()); assertTrue("!r1.equals(r2)", !r1.equals(r2)); - + r1 = RandomStringUtils.randomAscii(50); assertEquals("randomAscii(50) length", 50, r1.length()); for(int i = 0; i < r1.length(); i++) { assertTrue("char between 32 and 127", r1.charAt(i) >= 32 && r1.charAt(i) <= 127); - } + } r2 = RandomStringUtils.randomAscii(50); assertTrue("!r1.equals(r2)", !r1.equals(r2)); @@ -78,7 +78,7 @@ public class RandomStringUtilsTest { } r2 = RandomStringUtils.randomAlphabetic(50); assertTrue("!r1.equals(r2)", !r1.equals(r2)); - + r1 = RandomStringUtils.randomAlphanumeric(50); assertEquals("randomAlphanumeric(50)", 50, r1.length()); for(int i = 0; i < r1.length(); i++) { @@ -86,7 +86,7 @@ public class RandomStringUtilsTest { } r2 = RandomStringUtils.randomAlphabetic(50); assertTrue("!r1.equals(r2)", !r1.equals(r2)); - + r1 = RandomStringUtils.randomGraph(50); assertEquals("randomGraph(50) length", 50, r1.length()); for(int i = 0; i < r1.length(); i++) { @@ -94,7 +94,7 @@ public class RandomStringUtilsTest { } r2 = RandomStringUtils.randomGraph(50); assertTrue("!r1.equals(r2)", !r1.equals(r2)); - + r1 = RandomStringUtils.randomNumeric(50); assertEquals("randomNumeric(50)", 50, r1.length()); for(int i = 0; i < r1.length(); i++) { @@ -102,7 +102,7 @@ public class RandomStringUtilsTest { } r2 = RandomStringUtils.randomNumeric(50); assertTrue("!r1.equals(r2)", !r1.equals(r2)); - + r1 = RandomStringUtils.randomPrint(50); assertEquals("randomPrint(50) length", 50, r1.length()); for(int i = 0; i < r1.length(); i++) { @@ -110,7 +110,7 @@ public class RandomStringUtilsTest { } r2 = RandomStringUtils.randomPrint(50); assertTrue("!r1.equals(r2)", !r1.equals(r2)); - + String set = "abcdefg"; r1 = RandomStringUtils.random(50, set); assertEquals("random(50, \"abcdefg\")", 50, r1.length()); @@ -119,13 +119,13 @@ public class RandomStringUtilsTest { } r2 = RandomStringUtils.random(50, set); assertTrue("!r1.equals(r2)", !r1.equals(r2)); - + r1 = RandomStringUtils.random(50, (String) null); assertEquals("random(50) length", 50, r1.length()); r2 = RandomStringUtils.random(50, (String) null); assertEquals("random(50) length", 50, r2.length()); assertTrue("!r1.equals(r2)", !r1.equals(r2)); - + set = "stuvwxyz"; r1 = RandomStringUtils.random(50, set.toCharArray()); assertEquals("random(50, \"stuvwxyz\")", 50, r1.length()); @@ -134,7 +134,7 @@ public class RandomStringUtilsTest { } r2 = RandomStringUtils.random(50, set); assertTrue("!r1.equals(r2)", !r1.equals(r2)); - + r1 = RandomStringUtils.random(50, (char[]) null); assertEquals("random(50) length", 50, r1.length()); r2 = RandomStringUtils.random(50, (char[]) null); @@ -216,11 +216,11 @@ public class RandomStringUtilsTest { fail(); } catch (final IllegalArgumentException ex) {} } - + /** * Make sure boundary alphanumeric characters are generated by randomAlphaNumeric * This test will fail randomly with probability = 6 * (61/62)**1000 ~ 5.2E-7 - */ + */ @Test public void testRandomAlphaNumeric() { final char[] testChars = {'a', 'z', 'A', 'Z', '0', '9'}; @@ -235,16 +235,16 @@ public class RandomStringUtilsTest { } for (int i = 0; i < testChars.length; i++) { if (!found[i]) { - fail("alphanumeric character not generated in 1000 attempts: " + fail("alphanumeric character not generated in 1000 attempts: " + testChars[i] +" -- repeated failures indicate a problem "); } } } - + /** * Make sure '0' and '9' are generated by randomNumeric * This test will fail randomly with probability = 2 * (9/10)**1000 ~ 3.5E-46 - */ + */ @Test public void testRandomNumeric() { final char[] testChars = {'0','9'}; @@ -259,16 +259,16 @@ public class RandomStringUtilsTest { } for (int i = 0; i < testChars.length; i++) { if (!found[i]) { - fail("digit not generated in 1000 attempts: " + fail("digit not generated in 1000 attempts: " + testChars[i] +" -- repeated failures indicate a problem "); } - } + } } - + /** * Make sure boundary alpha characters are generated by randomAlphabetic * This test will fail randomly with probability = 4 * (51/52)**1000 ~ 1.58E-8 - */ + */ @Test public void testRandomAlphabetic() { final char[] testChars = {'a', 'z', 'A', 'Z'}; @@ -283,16 +283,16 @@ public class RandomStringUtilsTest { } for (int i = 0; i < testChars.length; i++) { if (!found[i]) { - fail("alphanumeric character not generated in 1000 attempts: " + fail("alphanumeric character not generated in 1000 attempts: " + testChars[i] +" -- repeated failures indicate a problem "); } } } - + /** * Make sure 32 and 127 are generated by randomNumeric * This test will fail randomly with probability = 2*(95/96)**1000 ~ 5.7E-5 - */ + */ @Test public void testRandomAscii() { final char[] testChars = {(char) 32, (char) 126}; @@ -307,11 +307,11 @@ public class RandomStringUtilsTest { } for (int i = 0; i < testChars.length; i++) { if (!found[i]) { - fail("ascii character not generated in 1000 attempts: " - + (int) testChars[i] + + fail("ascii character not generated in 1000 attempts: " + + (int) testChars[i] + " -- repeated failures indicate a problem"); } - } + } } @Test @@ -463,8 +463,8 @@ public class RandomStringUtilsTest { assertThat("min generated, may fail randomly rarely", minCreatedLength, is(expectedMinLengthInclusive)); assertThat("max generated, may fail randomly rarely", maxCreatedLength, is(expectedMaxLengthExclusive - 1)); } - - /** + + /** * Test homogeneity of random strings generated -- * i.e., test that characters show up with expected frequencies * in generated strings. Will fail randomly about 1 in 1000 times. @@ -487,12 +487,12 @@ public class RandomStringUtilsTest { default: {fail("generated character not in set");} } } - } + } // Perform chi-square test with df = 3-1 = 2, testing at .001 level assertTrue("test homogeneity -- will fail about 1 in 1000 times", - chiSquare(expected,counts) < 13.82); + chiSquare(expected,counts) < 13.82); } - + /** * Computes Chi-Square statistic given observed and expected counts * @param observed array of observed frequency counts @@ -506,7 +506,7 @@ public class RandomStringUtilsTest { sumSq += dev * dev / expected[i]; } return sumSq; - } + } /** * Checks if the string got by {@link RandomStringUtils#random(int)} @@ -534,20 +534,20 @@ public class RandomStringUtilsTest { // just to be complete assertEquals(orig, copy); } - - + + /** * Test for LANG-1286. Creates situation where old code would * overflow a char and result in a code point outside the specified * range. - * + * * @throws Exception */ @Test public void testCharOverflow() throws Exception { int start = Character.MAX_VALUE; int end = Integer.MAX_VALUE; - + @SuppressWarnings("serial") Random fixedRandom = new Random() { @Override @@ -556,7 +556,7 @@ public class RandomStringUtilsTest { return super.nextInt(n - 1) + 1; } }; - + String result = RandomStringUtils.random(2, start, end, false, false, null, fixedRandom); int c = result.codePointAt(0); assertTrue(String.format("Character '%d' not in range [%d,%d).", c, start, end), c >= start && c < end); diff --git a/src/test/java/org/apache/commons/lang3/RandomUtilsTest.java b/src/test/java/org/apache/commons/lang3/RandomUtilsTest.java index ddbaab186..3f9604f9b 100644 --- a/src/test/java/org/apache/commons/lang3/RandomUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/RandomUtilsTest.java @@ -125,7 +125,7 @@ public class RandomUtilsTest { public void testNextIntMinimalRange() { assertEquals(42, RandomUtils.nextInt(42, 42)); } - + /** * Tests next int range. */ @@ -144,23 +144,23 @@ public class RandomUtilsTest { assertTrue(randomResult > 0); assertTrue(randomResult < Integer.MAX_VALUE); } - + /** * Test next double range with minimal range. */ @Test public void testNextDoubleMinimalRange() { assertEquals(42.1, RandomUtils.nextDouble(42.1, 42.1), DELTA); - } - + } + /** * Test next float range with minimal range. */ @Test public void testNextFloatMinimalRange() { assertEquals(42.1f, RandomUtils.nextFloat(42.1f, 42.1f), DELTA); - } - + } + /** * Tests next double range. */ @@ -179,7 +179,7 @@ public class RandomUtilsTest { assertTrue(randomResult > 0); assertTrue(randomResult < Double.MAX_VALUE); } - + /** * Tests next float range. */ @@ -206,7 +206,7 @@ public class RandomUtilsTest { public void testNextLongMinimalRange() { assertEquals(42L, RandomUtils.nextLong(42L, 42L)); } - + /** * Tests next long range. */ @@ -225,7 +225,7 @@ public class RandomUtilsTest { assertTrue(randomResult > 0); assertTrue(randomResult < Long.MAX_VALUE); } - + /** * Tests extreme range. */ @@ -234,7 +234,7 @@ public class RandomUtilsTest { final int result = RandomUtils.nextInt(0, Integer.MAX_VALUE); assertTrue(result >= 0 && result < Integer.MAX_VALUE); } - + /** * Tests extreme range. */ @@ -242,8 +242,8 @@ public class RandomUtilsTest { public void testExtremeRangeLong() { final long result = RandomUtils.nextLong(0, Long.MAX_VALUE); assertTrue(result >= 0 && result < Long.MAX_VALUE); - } - + } + /** * Tests extreme range. */ @@ -251,8 +251,8 @@ public class RandomUtilsTest { public void testExtremeRangeFloat() { final float result = RandomUtils.nextFloat(0, Float.MAX_VALUE); assertTrue(result >= 0f && result <= Float.MAX_VALUE); - } - + } + /** * Tests extreme range. */ @@ -260,5 +260,5 @@ public class RandomUtilsTest { public void testExtremeRangeDouble() { final double result = RandomUtils.nextDouble(0, Double.MAX_VALUE); assertTrue(result >= 0 && result <= Double.MAX_VALUE); - } + } } diff --git a/src/test/java/org/apache/commons/lang3/RangeTest.java b/src/test/java/org/apache/commons/lang3/RangeTest.java index 03ed509ac..a8d7e1b2b 100644 --- a/src/test/java/org/apache/commons/lang3/RangeTest.java +++ b/src/test/java/org/apache/commons/lang3/RangeTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java b/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java index caa648b41..d9a5bde86 100644 --- a/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/SerializationUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -47,7 +47,7 @@ public class SerializationUtilsTest { static final String CLASS_NOT_FOUND_MESSAGE = "ClassNotFoundSerialization.readObject fake exception"; protected static final String SERIALIZE_IO_EXCEPTION_MESSAGE = "Anonymous OutputStream I/O exception"; - + private String iString; private Integer iInteger; private HashMap<Object, Object> iMap; @@ -72,29 +72,29 @@ public class SerializationUtilsTest { assertTrue(Modifier.isPublic(SerializationUtils.class.getModifiers())); assertFalse(Modifier.isFinal(SerializationUtils.class.getModifiers())); } - + @Test public void testException() { SerializationException serEx; final Exception ex = new Exception(); - + serEx = new SerializationException(); assertSame(null, serEx.getMessage()); assertSame(null, serEx.getCause()); - + serEx = new SerializationException("Message"); assertSame("Message", serEx.getMessage()); assertSame(null, serEx.getCause()); - + serEx = new SerializationException(ex); assertEquals("java.lang.Exception", serEx.getMessage()); assertSame(ex, serEx.getCause()); - + serEx = new SerializationException("Message", ex); assertSame("Message", serEx.getMessage()); assertSame(ex, serEx.getCause()); } - + //----------------------------------------------------------------------- @Test @@ -166,7 +166,7 @@ public class SerializationUtilsTest { } fail(); } - + @Test public void testSerializeIOException() throws Exception { // forces an IOException when the ObjectOutputStream is created, to test not closing the stream @@ -268,13 +268,13 @@ public class SerializationUtilsTest { assertEquals("java.lang.ClassNotFoundException: " + CLASS_NOT_FOUND_MESSAGE, se.getMessage()); } } - - @Test + + @Test public void testRoundtrip() { final HashMap<Object, Object> newMap = SerializationUtils.roundtrip(iMap); assertEquals(iMap, newMap); } - + //----------------------------------------------------------------------- @Test @@ -408,7 +408,7 @@ public class SerializationUtilsTest { } fail(); } - + @Test public void testPrimitiveTypeClassSerialization() { final Class<?>[] primitiveTypes = { byte.class, short.class, int.class, long.class, float.class, double.class, diff --git a/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java b/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java index df188a697..47e4fce3e 100644 --- a/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/StringEscapeUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -51,7 +51,7 @@ public class StringEscapeUtilsTest { assertTrue(Modifier.isPublic(StringEscapeUtils.class.getModifiers())); assertFalse(Modifier.isFinal(StringEscapeUtils.class.getModifiers())); } - + @Test public void testEscapeJava() throws IOException { assertEquals(null, StringEscapeUtils.escapeJava(null)); @@ -69,7 +69,7 @@ public class StringEscapeUtilsTest { fail(); } catch (final IllegalArgumentException ex) { } - + assertEscapeJava("empty string", "", ""); assertEscapeJava(FOO, FOO); assertEscapeJava("tab", "\\t", "\t"); @@ -106,7 +106,7 @@ public class StringEscapeUtilsTest { */ assertEquals(expected, actual); } - + private void assertEscapeJava(final String escaped, final String original) throws IOException { assertEscapeJava(null, escaped, original); } @@ -143,7 +143,7 @@ public class StringEscapeUtilsTest { fail(); } catch (final RuntimeException ex) { } - + assertUnescapeJava("", ""); assertUnescapeJava("test", "test"); assertUnescapeJava("\ntest\b", "\\ntest\\b"); @@ -194,9 +194,9 @@ public class StringEscapeUtilsTest { fail(); } catch (final IllegalArgumentException ex) { } - + assertEquals("He didn\\'t say, \\\"stop!\\\"", StringEscapeUtils.escapeEcmaScript("He didn't say, \"stop!\"")); - assertEquals("document.getElementById(\\\"test\\\").value = \\'<script>alert(\\'aaa\\');<\\/script>\\';", + assertEquals("document.getElementById(\\\"test\\\").value = \\'<script>alert(\\'aaa\\');<\\/script>\\';", StringEscapeUtils.escapeEcmaScript("document.getElementById(\"test\").value = '<script>alert('aaa');</script>';")); } @@ -265,7 +265,7 @@ public class StringEscapeUtilsTest { final String expected = element[2]; final String original = element[1]; assertEquals(message, expected, StringEscapeUtils.unescapeHtml4(original)); - + final StringWriter sw = new StringWriter(); try { StringEscapeUtils.UNESCAPE_HTML4.translate(original, sw); @@ -276,9 +276,9 @@ public class StringEscapeUtilsTest { } // \u00E7 is a cedilla (c with wiggle under) // note that the test string must be 7-bit-clean (Unicode escaped) or else it will compile incorrectly - // on some locales + // on some locales assertEquals("funny chars pass through OK", "Fran\u00E7ais", StringEscapeUtils.unescapeHtml4("Fran\u00E7ais")); - + assertEquals("Hello&;World", StringEscapeUtils.unescapeHtml4("Hello&;World")); assertEquals("Hello&#;World", StringEscapeUtils.unescapeHtml4("Hello&#;World")); assertEquals("Hello&# ;World", StringEscapeUtils.unescapeHtml4("Hello&# ;World")); @@ -287,7 +287,7 @@ public class StringEscapeUtilsTest { @Test public void testUnescapeHexCharsHtml() { - // Simple easy to grok test + // Simple easy to grok test assertEquals("hex number unescape", "\u0080\u009F", StringEscapeUtils.unescapeHtml4("€Ÿ")); assertEquals("hex number unescape", "\u0080\u009F", StringEscapeUtils.unescapeHtml4("€Ÿ")); // Test all Character values: @@ -350,7 +350,7 @@ public class StringEscapeUtilsTest { } assertEquals("XML was unescaped incorrectly", "<abc>", sw.toString() ); } - + @Test public void testEscapeXml10() throws Exception { assertEquals("a<b>c"d'e&f", StringEscapeUtils.escapeXml10("a<b>c\"d'e&f")); @@ -365,7 +365,7 @@ public class StringEscapeUtilsTest { assertEquals("XML 1.0 should escape #x7f-#x84 | #x86 - #x9f, for XML 1.1 compatibility", "a\u007e„\u0085†Ÿ\u00a0b", StringEscapeUtils.escapeXml10("a\u007e\u007f\u0084\u0085\u0086\u009f\u00a0b")); } - + @Test public void testEscapeXml11() throws Exception { assertEquals("a<b>c"d'e&f", StringEscapeUtils.escapeXml11("a<b>c\"d'e&f")); @@ -384,7 +384,7 @@ public class StringEscapeUtilsTest { } /** - * Tests Supplementary characters. + * Tests Supplementary characters. * <p> * From http://www.w3.org/International/questions/qa-escapes * </p> @@ -400,7 +400,7 @@ public class StringEscapeUtilsTest { */ @Test public void testEscapeXmlSupplementaryCharacters() { - final CharSequenceTranslator escapeXml = + final CharSequenceTranslator escapeXml = StringEscapeUtils.ESCAPE_XML.with( NumericEntityEscaper.between(0x7f, Integer.MAX_VALUE) ); assertEquals("Supplementary character must be represented using a single escape", "𣎴", @@ -409,7 +409,7 @@ public class StringEscapeUtilsTest { assertEquals("Supplementary characters mixed with basic characters should be encoded correctly", "a b c 𣎴", escapeXml.translate("a b c \uD84C\uDFB4")); } - + @Test public void testEscapeXmlAllCharacters() { // http://www.w3.org/TR/xml/#charsets says: @@ -427,7 +427,7 @@ public class StringEscapeUtilsTest { assertEquals("Hello World! Ain't this great?", escapeXml.translate("Hello World! Ain't this great?")); assertEquals("", escapeXml.translate("\u000E\u000F\u0018\u0019")); } - + /** * Reverse of the above. * @@ -441,7 +441,7 @@ public class StringEscapeUtilsTest { assertEquals("Supplementary characters mixed with basic characters should be decoded correctly", "a b c \uD84C\uDFB4", StringEscapeUtils.unescapeXml("a b c 𣎴") ); } - + // Tests issue #38569 // http://issues.apache.org/bugzilla/show_bug.cgi?id=38569 @Test @@ -583,7 +583,7 @@ public class StringEscapeUtilsTest { /** * Tests https://issues.apache.org/jira/browse/LANG-708 - * + * * @throws IOException * if an I/O error occurs */ diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsContainsTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsContainsTest.java index 6fedb92ca..5cc635fe9 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsContainsTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsContainsTest.java @@ -211,7 +211,7 @@ public class StringUtilsContainsTest { assertFalse(StringUtils.containsAny(CharU20000, CharU20001)); assertFalse(StringUtils.containsAny(CharU20001, CharU20000)); } - + @Test public void testContainsAny_StringStringArray() { assertFalse(StringUtils.containsAny(null, (String[]) null)); diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsEmptyBlankTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsEmptyBlankTest.java index 8e88f6ea3..8e872c3e7 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsEmptyBlankTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsEmptyBlankTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java index 91c0451fe..22cf9aabb 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsEqualsIndexOfTest.java @@ -294,7 +294,7 @@ public class StringUtilsEqualsIndexOfTest { assertEquals(2, StringUtils.indexOf("aabaabaa", 'b', -1)); assertEquals(5, StringUtils.indexOf(new StringBuilder("aabaabaa"), 'b', 3)); - + //LANG-1300 tests go here final int CODE_POINT = 0x2070E; StringBuilder builder = new StringBuilder(); @@ -545,7 +545,7 @@ public class StringUtilsEqualsIndexOfTest { assertEquals(0, StringUtils.lastIndexOf("aabaabaa", 'a', 0)); assertEquals(2, StringUtils.lastIndexOf(new StringBuilder("aabaabaa"), 'b', 2)); - + //LANG-1300 addition test final int CODE_POINT = 0x2070E; StringBuilder builder = new StringBuilder(); @@ -784,7 +784,7 @@ public class StringUtilsEqualsIndexOfTest { @Test public void testLANG1193() { - assertEquals(0, StringUtils.ordinalIndexOf("abc", "ab", 1)); + assertEquals(0, StringUtils.ordinalIndexOf("abc", "ab", 1)); } @Test diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsIsTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsIsTest.java index 6932afb46..4160f1a5d 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsIsTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsIsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -127,7 +127,7 @@ public class StringUtilsIsTest { assertTrue(StringUtils.isAsciiPrintable("=?iso-8859-1?Q?G=FClc=FC?=")); assertFalse(StringUtils.isAsciiPrintable("G\u00fclc\u00fc")); } - + @Test public void testIsNumeric() { assertFalse(StringUtils.isNumeric(null)); diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsStartsEndsWithTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsStartsEndsWithTest.java index ec72c0db9..2eb5ddb58 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsStartsEndsWithTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsStartsEndsWithTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -99,7 +99,7 @@ public class StringUtilsStartsEndsWithTest { assertTrue("StringUtils.startsWithAny(abcxyz, StringBuilder(xyz), StringBuffer(abc))", StringUtils.startsWithAny("abcxyz", new StringBuilder("xyz"), new StringBuffer("abc"))); assertTrue("StringUtils.startsWithAny(StringBuffer(abcxyz), StringBuilder(xyz), StringBuffer(abc))", StringUtils.startsWithAny(new StringBuffer("abcxyz"), new StringBuilder("xyz"), new StringBuffer("abc"))); } - + /** * Test StringUtils.endsWith() @@ -183,7 +183,7 @@ public class StringUtilsStartsEndsWithTest { /* * Type null of the last argument to method endsWithAny(CharSequence, CharSequence...) - * doesn't exactly match the vararg parameter type. + * doesn't exactly match the vararg parameter type. * Cast to CharSequence[] to confirm the non-varargs invocation, * or pass individual arguments of type CharSequence for a varargs invocation. * diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsSubstringTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsSubstringTest.java index f6986eedb..66d03f3db 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsSubstringTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsSubstringTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -39,7 +39,7 @@ public class StringUtilsSubstringTest { assertEquals(null, StringUtils.substring(null, 0)); assertEquals("", StringUtils.substring("", 0)); assertEquals("", StringUtils.substring("", 2)); - + assertEquals("", StringUtils.substring(SENTENCE, 80)); assertEquals(BAZ, StringUtils.substring(SENTENCE, 8)); assertEquals(BAZ, StringUtils.substring(SENTENCE, -3)); @@ -54,7 +54,7 @@ public class StringUtilsSubstringTest { assertEquals("", StringUtils.substring("abc", 3)); assertEquals("", StringUtils.substring("abc", 4)); } - + @Test public void testSubstring_StringIntInt() { assertEquals(null, StringUtils.substring(null, 0, 0)); @@ -62,7 +62,7 @@ public class StringUtilsSubstringTest { assertEquals("", StringUtils.substring("", 0, 0)); assertEquals("", StringUtils.substring("", 1, 2)); assertEquals("", StringUtils.substring("", -2, -1)); - + assertEquals("", StringUtils.substring(SENTENCE, 8, 6)); assertEquals(FOO, StringUtils.substring(SENTENCE, 0, 3)); assertEquals("o", StringUtils.substring(SENTENCE, -9, 3)); @@ -72,50 +72,50 @@ public class StringUtilsSubstringTest { assertEquals("", StringUtils.substring(SENTENCE, 2, 2)); assertEquals("b",StringUtils.substring("abc", -2, -1)); } - + @Test public void testLeft_String() { assertSame(null, StringUtils.left(null, -1)); assertSame(null, StringUtils.left(null, 0)); assertSame(null, StringUtils.left(null, 2)); - + assertEquals("", StringUtils.left("", -1)); assertEquals("", StringUtils.left("", 0)); assertEquals("", StringUtils.left("", 2)); - + assertEquals("", StringUtils.left(FOOBAR, -1)); assertEquals("", StringUtils.left(FOOBAR, 0)); assertEquals(FOO, StringUtils.left(FOOBAR, 3)); assertSame(FOOBAR, StringUtils.left(FOOBAR, 80)); } - + @Test public void testRight_String() { assertSame(null, StringUtils.right(null, -1)); assertSame(null, StringUtils.right(null, 0)); assertSame(null, StringUtils.right(null, 2)); - + assertEquals("", StringUtils.right("", -1)); assertEquals("", StringUtils.right("", 0)); assertEquals("", StringUtils.right("", 2)); - + assertEquals("", StringUtils.right(FOOBAR, -1)); assertEquals("", StringUtils.right(FOOBAR, 0)); assertEquals(BAR, StringUtils.right(FOOBAR, 3)); assertSame(FOOBAR, StringUtils.right(FOOBAR, 80)); } - + @Test public void testMid_String() { assertSame(null, StringUtils.mid(null, -1, 0)); assertSame(null, StringUtils.mid(null, 0, -1)); assertSame(null, StringUtils.mid(null, 3, 0)); assertSame(null, StringUtils.mid(null, 3, 2)); - + assertEquals("", StringUtils.mid("", 0, -1)); assertEquals("", StringUtils.mid("", 0, 0)); assertEquals("", StringUtils.mid("", 0, 2)); - + assertEquals("", StringUtils.mid(FOOBAR, 3, -1)); assertEquals("", StringUtils.mid(FOOBAR, 3, 0)); assertEquals("b", StringUtils.mid(FOOBAR, 3, 1)); @@ -126,7 +126,7 @@ public class StringUtilsSubstringTest { assertEquals("", StringUtils.mid(FOOBAR, 9, 3)); assertEquals(FOO, StringUtils.mid(FOOBAR, -1, 3)); } - + //----------------------------------------------------------------------- @Test public void testSubstringBefore_StringString() { @@ -138,7 +138,7 @@ public class StringUtilsSubstringTest { assertEquals("", StringUtils.substringBefore("", null)); assertEquals("", StringUtils.substringBefore("", "")); assertEquals("", StringUtils.substringBefore("", "XX")); - + assertEquals("foo", StringUtils.substringBefore("foo", null)); assertEquals("foo", StringUtils.substringBefore("foo", "b")); assertEquals("f", StringUtils.substringBefore("foot", "o")); @@ -147,18 +147,18 @@ public class StringUtilsSubstringTest { assertEquals("ab", StringUtils.substringBefore("abc", "c")); assertEquals("", StringUtils.substringBefore("abc", "")); } - + @Test public void testSubstringAfter_StringString() { assertEquals("barXXbaz", StringUtils.substringAfter("fooXXbarXXbaz", "XX")); - + assertEquals(null, StringUtils.substringAfter(null, null)); assertEquals(null, StringUtils.substringAfter(null, "")); assertEquals(null, StringUtils.substringAfter(null, "XX")); assertEquals("", StringUtils.substringAfter("", null)); assertEquals("", StringUtils.substringAfter("", "")); assertEquals("", StringUtils.substringAfter("", "XX")); - + assertEquals("", StringUtils.substringAfter("foo", null)); assertEquals("ot", StringUtils.substringAfter("foot", "o")); assertEquals("bc", StringUtils.substringAfter("abc", "a")); @@ -191,7 +191,7 @@ public class StringUtilsSubstringTest { assertEquals("a", StringUtils.substringBeforeLast("a", "")); assertEquals("", StringUtils.substringBeforeLast("a", "a")); } - + @Test public void testSubstringAfterLast_StringString() { assertEquals("baz", StringUtils.substringAfterLast("fooXXbarXXbaz", "XX")); @@ -211,8 +211,8 @@ public class StringUtilsSubstringTest { assertEquals("", StringUtils.substringAfterLast("abc", "c")); assertEquals("", StringUtils.substringAfterLast("", "d")); assertEquals("", StringUtils.substringAfterLast("abc", "")); - } - + } + //----------------------------------------------------------------------- @Test public void testSubstringBetween_StringString() { @@ -227,7 +227,7 @@ public class StringUtilsSubstringTest { assertEquals("bc", StringUtils.substringBetween("abcabca", "a")); assertEquals("bar", StringUtils.substringBetween("\nbar\n", "\n")); } - + @Test public void testSubstringBetween_StringStringString() { assertEquals(null, StringUtils.substringBetween(null, "", "")); @@ -312,11 +312,11 @@ public class StringUtilsSubstringTest { assertEquals(0, StringUtils.countMatches("x", "")); assertEquals(0, StringUtils.countMatches("", "")); - assertEquals(3, + assertEquals(3, StringUtils.countMatches("one long someone sentence of one", "one")); - assertEquals(0, + assertEquals(0, StringUtils.countMatches("one long someone sentence of one", "two")); - assertEquals(4, + assertEquals(4, StringUtils.countMatches("oooooooooooo", "ooo")); } diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java index 2b49669f4..5cda0aff9 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -3204,7 +3204,7 @@ public class StringUtilsTest { assertNull(StringUtils.unwrap(null, null)); assertNull(StringUtils.unwrap(null, '\0')); assertNull(StringUtils.unwrap(null, '1')); - + assertEquals("abc", StringUtils.unwrap("abc", null)); assertEquals("abc", StringUtils.unwrap("\'abc\'", '\'')); assertEquals("abc", StringUtils.unwrap("AabcA", 'A')); @@ -3214,18 +3214,18 @@ public class StringUtilsTest { assertEquals("A#", StringUtils.unwrap("A#", '#')); assertEquals("ABA", StringUtils.unwrap("AABAA", 'A')); } - + @Test public void testToCodePoints() throws Exception { final int orphanedHighSurrogate = 0xD801; 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)); - + assertNull(StringUtils.toCodePoints(null)); assertArrayEquals(ArrayUtils.EMPTY_INT_ARRAY, StringUtils.toCodePoints("")); } diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsTrimStripTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsTrimStripTest.java index 1a558f584..d9fdb7487 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsTrimStripTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsTrimStripTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -74,10 +74,10 @@ public class StringUtilsTrimStripTest { assertEquals("", StringUtils.strip("")); assertEquals("", StringUtils.strip(" ")); assertEquals("abc", StringUtils.strip(" abc ")); - assertEquals(StringUtilsTest.NON_WHITESPACE, + assertEquals(StringUtilsTest.NON_WHITESPACE, StringUtils.strip(StringUtilsTest.WHITESPACE + StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE)); } - + @Test public void testStripToNull_String() { assertEquals(null, StringUtils.stripToNull(null)); @@ -85,10 +85,10 @@ public class StringUtilsTrimStripTest { assertEquals(null, StringUtils.stripToNull(" ")); assertEquals(null, StringUtils.stripToNull(StringUtilsTest.WHITESPACE)); assertEquals("ab c", StringUtils.stripToNull(" ab c ")); - assertEquals(StringUtilsTest.NON_WHITESPACE, + assertEquals(StringUtilsTest.NON_WHITESPACE, StringUtils.stripToNull(StringUtilsTest.WHITESPACE + StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE)); } - + @Test public void testStripToEmpty_String() { assertEquals("", StringUtils.stripToEmpty(null)); @@ -96,10 +96,10 @@ public class StringUtilsTrimStripTest { assertEquals("", StringUtils.stripToEmpty(" ")); assertEquals("", StringUtils.stripToEmpty(StringUtilsTest.WHITESPACE)); assertEquals("ab c", StringUtils.stripToEmpty(" ab c ")); - assertEquals(StringUtilsTest.NON_WHITESPACE, + assertEquals(StringUtilsTest.NON_WHITESPACE, StringUtils.stripToEmpty(StringUtilsTest.WHITESPACE + StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE)); } - + @Test public void testStrip_StringString() { // null strip @@ -107,7 +107,7 @@ public class StringUtilsTrimStripTest { assertEquals("", StringUtils.strip("", null)); assertEquals("", StringUtils.strip(" ", null)); assertEquals("abc", StringUtils.strip(" abc ", null)); - assertEquals(StringUtilsTest.NON_WHITESPACE, + assertEquals(StringUtilsTest.NON_WHITESPACE, StringUtils.strip(StringUtilsTest.WHITESPACE + StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE, null)); // "" strip @@ -116,13 +116,13 @@ public class StringUtilsTrimStripTest { assertEquals(" ", StringUtils.strip(" ", "")); assertEquals(" abc ", StringUtils.strip(" abc ", "")); assertEquals(StringUtilsTest.WHITESPACE, StringUtils.strip(StringUtilsTest.WHITESPACE, "")); - + // " " strip assertEquals(null, StringUtils.strip(null, " ")); assertEquals("", StringUtils.strip("", " ")); assertEquals("", StringUtils.strip(" ", " ")); assertEquals("abc", StringUtils.strip(" abc ", " ")); - + // "ab" strip assertEquals(null, StringUtils.strip(null, "ab")); assertEquals("", StringUtils.strip("", "ab")); @@ -131,7 +131,7 @@ public class StringUtilsTrimStripTest { assertEquals("c", StringUtils.strip("abcabab", "ab")); assertEquals(StringUtilsTest.WHITESPACE, StringUtils.strip(StringUtilsTest.WHITESPACE, "")); } - + @Test public void testStripStart_StringString() { // null stripStart @@ -139,7 +139,7 @@ public class StringUtilsTrimStripTest { assertEquals("", StringUtils.stripStart("", null)); assertEquals("", StringUtils.stripStart(" ", null)); assertEquals("abc ", StringUtils.stripStart(" abc ", null)); - assertEquals(StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE, + assertEquals(StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE, StringUtils.stripStart(StringUtilsTest.WHITESPACE + StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE, null)); // "" stripStart @@ -148,13 +148,13 @@ public class StringUtilsTrimStripTest { assertEquals(" ", StringUtils.stripStart(" ", "")); assertEquals(" abc ", StringUtils.stripStart(" abc ", "")); assertEquals(StringUtilsTest.WHITESPACE, StringUtils.stripStart(StringUtilsTest.WHITESPACE, "")); - + // " " stripStart assertEquals(null, StringUtils.stripStart(null, " ")); assertEquals("", StringUtils.stripStart("", " ")); assertEquals("", StringUtils.stripStart(" ", " ")); assertEquals("abc ", StringUtils.stripStart(" abc ", " ")); - + // "ab" stripStart assertEquals(null, StringUtils.stripStart(null, "ab")); assertEquals("", StringUtils.stripStart("", "ab")); @@ -163,7 +163,7 @@ public class StringUtilsTrimStripTest { assertEquals("cabab", StringUtils.stripStart("abcabab", "ab")); assertEquals(StringUtilsTest.WHITESPACE, StringUtils.stripStart(StringUtilsTest.WHITESPACE, "")); } - + @Test public void testStripEnd_StringString() { // null stripEnd @@ -171,7 +171,7 @@ public class StringUtilsTrimStripTest { assertEquals("", StringUtils.stripEnd("", null)); assertEquals("", StringUtils.stripEnd(" ", null)); assertEquals(" abc", StringUtils.stripEnd(" abc ", null)); - assertEquals(StringUtilsTest.WHITESPACE + StringUtilsTest.NON_WHITESPACE, + assertEquals(StringUtilsTest.WHITESPACE + StringUtilsTest.NON_WHITESPACE, StringUtils.stripEnd(StringUtilsTest.WHITESPACE + StringUtilsTest.NON_WHITESPACE + StringUtilsTest.WHITESPACE, null)); // "" stripEnd @@ -180,13 +180,13 @@ public class StringUtilsTrimStripTest { assertEquals(" ", StringUtils.stripEnd(" ", "")); assertEquals(" abc ", StringUtils.stripEnd(" abc ", "")); assertEquals(StringUtilsTest.WHITESPACE, StringUtils.stripEnd(StringUtilsTest.WHITESPACE, "")); - + // " " stripEnd assertEquals(null, StringUtils.stripEnd(null, " ")); assertEquals("", StringUtils.stripEnd("", " ")); assertEquals("", StringUtils.stripEnd(" ", " ")); assertEquals(" abc", StringUtils.stripEnd(" abc ", " ")); - + // "ab" stripEnd assertEquals(null, StringUtils.stripEnd(null, "ab")); assertEquals("", StringUtils.stripEnd("", "ab")); @@ -211,7 +211,7 @@ public class StringUtilsTrimStripTest { assertArrayEquals(empty, StringUtils.stripAll(empty)); assertArrayEquals(foo, StringUtils.stripAll(fooSpace)); - + assertNull(StringUtils.stripAll(null, null)); assertArrayEquals(foo, StringUtils.stripAll(fooSpace, null)); assertArrayEquals(foo, StringUtils.stripAll(fooDots, ".")); @@ -222,11 +222,11 @@ public class StringUtilsTrimStripTest { final String cue = "\u00C7\u00FA\u00EA"; assertEquals( "Failed to strip accents from " + cue, "Cue", StringUtils.stripAccents(cue)); - final String lots = "\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C7\u00C8\u00C9" + - "\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u00D1\u00D2\u00D3" + + final String lots = "\u00C0\u00C1\u00C2\u00C3\u00C4\u00C5\u00C7\u00C8\u00C9" + + "\u00CA\u00CB\u00CC\u00CD\u00CE\u00CF\u00D1\u00D2\u00D3" + "\u00D4\u00D5\u00D6\u00D9\u00DA\u00DB\u00DC\u00DD"; - assertEquals( "Failed to strip accents from " + lots, - "AAAAAACEEEEIIIINOOOOOUUUUY", + assertEquals( "Failed to strip accents from " + lots, + "AAAAAACEEEEIIIINOOOOOUUUUY", StringUtils.stripAccents(lots)); assertNull( "Failed null safety", StringUtils.stripAccents(null) ); diff --git a/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java b/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java index cc1d49286..3d9d024fe 100644 --- a/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/SystemUtilsTest.java @@ -43,7 +43,7 @@ import org.junit.Test; /** * Unit tests {@link org.apache.commons.lang3.SystemUtils}. - * + * * Only limited testing can be performed. */ public class SystemUtilsTest { diff --git a/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java index 4ce0a1fa4..33deaa877 100644 --- a/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/CompareToBuilderTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -95,7 +95,7 @@ public class CompareToBuilderTest { this.t = t; } } - + @Test public void testReflectionCompare() { final TestObject o1 = new TestObject(4); @@ -124,16 +124,16 @@ public class CompareToBuilderTest { public void testReflectionHierarchyCompare() { testReflectionHierarchyCompare(false, null); } - + @Test public void testReflectionHierarchyCompareExcludeFields() { final String[] excludeFields = new String[] { "b" }; testReflectionHierarchyCompare(true, excludeFields); - + TestSubObject x; TestSubObject y; TestSubObject z; - + x = new TestSubObject(1, 1); y = new TestSubObject(2, 1); z = new TestSubObject(3, 1); @@ -144,7 +144,7 @@ public class CompareToBuilderTest { z = new TestSubObject(3, 1); assertXYZCompareOrder(x, y, z, true, excludeFields); } - + @Test public void testReflectionHierarchyCompareTransients() { testReflectionHierarchyCompare(true, null); @@ -157,27 +157,27 @@ public class CompareToBuilderTest { y = new TestTransientSubObject(2, 2); z = new TestTransientSubObject(3, 3); assertXYZCompareOrder(x, y, z, true, null); - + x = new TestTransientSubObject(1, 1); y = new TestTransientSubObject(1, 2); z = new TestTransientSubObject(1, 3); - assertXYZCompareOrder(x, y, z, true, null); + assertXYZCompareOrder(x, y, z, true, null); } - + private void assertXYZCompareOrder(final Object x, final Object y, final Object z, final boolean testTransients, final String[] excludeFields) { assertTrue(0 == CompareToBuilder.reflectionCompare(x, x, testTransients, null, excludeFields)); assertTrue(0 == CompareToBuilder.reflectionCompare(y, y, testTransients, null, excludeFields)); assertTrue(0 == CompareToBuilder.reflectionCompare(z, z, testTransients, null, excludeFields)); - + assertTrue(0 > CompareToBuilder.reflectionCompare(x, y, testTransients, null, excludeFields)); assertTrue(0 > CompareToBuilder.reflectionCompare(x, z, testTransients, null, excludeFields)); assertTrue(0 > CompareToBuilder.reflectionCompare(y, z, testTransients, null, excludeFields)); - + assertTrue(0 < CompareToBuilder.reflectionCompare(y, x, testTransients, null, excludeFields)); assertTrue(0 < CompareToBuilder.reflectionCompare(z, x, testTransients, null, excludeFields)); assertTrue(0 < CompareToBuilder.reflectionCompare(z, y, testTransients, null, excludeFields)); } - + private void testReflectionHierarchyCompare(final boolean testTransients, final String[] excludeFields) { final TestObject to1 = new TestObject(1); final TestObject to2 = new TestObject(2); @@ -185,26 +185,26 @@ public class CompareToBuilderTest { final TestSubObject tso1 = new TestSubObject(1, 1); final TestSubObject tso2 = new TestSubObject(2, 2); final TestSubObject tso3 = new TestSubObject(3, 3); - + assertReflectionCompareContract(to1, to1, to1, false, excludeFields); assertReflectionCompareContract(to1, to2, to3, false, excludeFields); assertReflectionCompareContract(tso1, tso1, tso1, false, excludeFields); assertReflectionCompareContract(tso1, tso2, tso3, false, excludeFields); assertReflectionCompareContract("1", "2", "3", false, excludeFields); - + assertTrue(0 != CompareToBuilder.reflectionCompare(tso1, new TestSubObject(1, 0), testTransients)); assertTrue(0 != CompareToBuilder.reflectionCompare(tso1, new TestSubObject(0, 1), testTransients)); // root class assertXYZCompareOrder(to1, to2, to3, true, null); - // subclass - assertXYZCompareOrder(tso1, tso2, tso3, true, null); + // subclass + assertXYZCompareOrder(tso1, tso2, tso3, true, null); } /** * See "Effective Java" under "Consider Implementing Comparable". - * - * @param x an object to compare + * + * @param x an object to compare * @param y an object to compare * @param z an object to compare * @param testTransients Whether to include transients in the comparison @@ -214,26 +214,26 @@ public class CompareToBuilderTest { // signum assertTrue(reflectionCompareSignum(x, y, testTransients, excludeFields) == -reflectionCompareSignum(y, x, testTransients, excludeFields)); - + // transitive - if (CompareToBuilder.reflectionCompare(x, y, testTransients, null, excludeFields) > 0 + if (CompareToBuilder.reflectionCompare(x, y, testTransients, null, excludeFields) > 0 && CompareToBuilder.reflectionCompare(y, z, testTransients, null, excludeFields) > 0){ assertTrue(CompareToBuilder.reflectionCompare(x, z, testTransients, null, excludeFields) > 0); } - + // un-named if (CompareToBuilder.reflectionCompare(x, y, testTransients, null, excludeFields) == 0) { assertTrue(reflectionCompareSignum(x, z, testTransients, excludeFields) == -reflectionCompareSignum(y, z, testTransients, excludeFields)); } - + // strongly recommended but not strictly required assertTrue(CompareToBuilder.reflectionCompare(x, y, testTransients) ==0 == EqualsBuilder.reflectionEquals(x, y, testTransients)); } - + /** * Returns the signum of the result of comparing x and y with * <code>CompareToBuilder.reflectionCompare</code> - * + * * @param lhs The "left-hand-side" of the comparison. * @param rhs The "right-hand-side" of the comparison. * @param testTransients Whether to include transients in the comparison @@ -243,7 +243,7 @@ public class CompareToBuilderTest { private int reflectionCompareSignum(final Object lhs, final Object rhs, final boolean testTransients, final String[] excludeFields) { return BigInteger.valueOf(CompareToBuilder.reflectionCompare(lhs, rhs, testTransients)).signum(); } - + @Test public void testAppendSuper() { final TestObject o1 = new TestObject(4); @@ -251,14 +251,14 @@ public class CompareToBuilderTest { assertTrue(new CompareToBuilder().appendSuper(0).append(o1, o1).toComparison() == 0); assertTrue(new CompareToBuilder().appendSuper(0).append(o1, o2).toComparison() < 0); assertTrue(new CompareToBuilder().appendSuper(0).append(o2, o1).toComparison() > 0); - + assertTrue(new CompareToBuilder().appendSuper(-1).append(o1, o1).toComparison() < 0); assertTrue(new CompareToBuilder().appendSuper(-1).append(o1, o2).toComparison() < 0); - + assertTrue(new CompareToBuilder().appendSuper(1).append(o1, o1).toComparison() > 0); assertTrue(new CompareToBuilder().appendSuper(1).append(o1, o2).toComparison() > 0); } - + @Test public void testObject() { final TestObject o1 = new TestObject(4); @@ -268,12 +268,12 @@ public class CompareToBuilderTest { o2.setA(5); assertTrue(new CompareToBuilder().append(o1, o2).toComparison() < 0); assertTrue(new CompareToBuilder().append(o2, o1).toComparison() > 0); - + assertTrue(new CompareToBuilder().append(o1, null).toComparison() > 0); assertTrue(new CompareToBuilder().append((Object) null, null).toComparison() == 0); assertTrue(new CompareToBuilder().append(null, o1).toComparison() < 0); } - + @Test public void testObjectBuild() { final TestObject o1 = new TestObject(4); @@ -283,7 +283,7 @@ public class CompareToBuilderTest { o2.setA(5); assertTrue(new CompareToBuilder().append(o1, o2).build().intValue() < 0); assertTrue(new CompareToBuilder().append(o2, o1).build().intValue() > 0); - + assertTrue(new CompareToBuilder().append(o1, null).build().intValue() > 0); assertEquals(Integer.valueOf(0), new CompareToBuilder().append((Object) null, null).build()); assertTrue(new CompareToBuilder().append(null, o1).build().intValue() < 0); @@ -308,12 +308,12 @@ public class CompareToBuilderTest { o2 = "FREDA"; assertTrue(new CompareToBuilder().append(o1, o2, String.CASE_INSENSITIVE_ORDER).toComparison() < 0); assertTrue(new CompareToBuilder().append(o2, o1, String.CASE_INSENSITIVE_ORDER).toComparison() > 0); - + assertTrue(new CompareToBuilder().append(o1, null, String.CASE_INSENSITIVE_ORDER).toComparison() > 0); assertTrue(new CompareToBuilder().append(null, null, String.CASE_INSENSITIVE_ORDER).toComparison() == 0); assertTrue(new CompareToBuilder().append(null, o1, String.CASE_INSENSITIVE_ORDER).toComparison() < 0); } - + @Test public void testObjectComparatorNull() { final String o1 = "Fred"; @@ -323,7 +323,7 @@ public class CompareToBuilderTest { o2 = "Zebra"; assertTrue(new CompareToBuilder().append(o1, o2, null).toComparison() < 0); assertTrue(new CompareToBuilder().append(o2, o1, null).toComparison() > 0); - + assertTrue(new CompareToBuilder().append(o1, null, null).toComparison() > 0); assertTrue(new CompareToBuilder().append(null, null, null).toComparison() == 0); assertTrue(new CompareToBuilder().append(null, o1, null).toComparison() < 0); @@ -458,12 +458,12 @@ public class CompareToBuilderTest { obj3[0] = new TestObject(4); obj3[1] = new TestObject(5); obj3[2] = new TestObject(6); - + assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0); assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0); assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0); assertTrue(new CompareToBuilder().append(obj3, obj1).toComparison() > 0); - + obj1[1] = new TestObject(7); assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() > 0); assertTrue(new CompareToBuilder().append(obj2, obj1).toComparison() < 0); @@ -485,7 +485,7 @@ public class CompareToBuilderTest { obj3[0] = 5L; obj3[1] = 6L; obj3[2] = 7L; - + assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0); assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0); assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0); @@ -703,7 +703,7 @@ public class CompareToBuilderTest { } array3[1][2] = 100; array3[1][2] = 100; - + assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); @@ -727,7 +727,7 @@ public class CompareToBuilderTest { } array3[1][2] = 100; array3[1][2] = 100; - + assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); @@ -751,7 +751,7 @@ public class CompareToBuilderTest { } array3[1][2] = 100; array3[1][2] = 100; - + assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); @@ -775,7 +775,7 @@ public class CompareToBuilderTest { } array3[1][2] = 100; array3[1][2] = 100; - + assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); @@ -799,7 +799,7 @@ public class CompareToBuilderTest { } array3[1][2] = 100; array3[1][2] = 100; - + assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); @@ -808,7 +808,7 @@ public class CompareToBuilderTest { assertTrue(new CompareToBuilder().append(array1, array2).toComparison() > 0); assertTrue(new CompareToBuilder().append(array2, array1).toComparison() < 0); } - + @Test public void testMultiFloatArray() { final float[][] array1 = new float[2][2]; @@ -823,7 +823,7 @@ public class CompareToBuilderTest { } array3[1][2] = 100; array3[1][2] = 100; - + assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); @@ -847,7 +847,7 @@ public class CompareToBuilderTest { } array3[1][2] = 100; array3[1][2] = 100; - + assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); @@ -871,7 +871,7 @@ public class CompareToBuilderTest { } array3[1][2] = false; array3[1][2] = false; - + assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); @@ -898,8 +898,8 @@ public class CompareToBuilderTest { } array3[1][2] = 100; array3[1][2] = 100; - - + + assertTrue(new CompareToBuilder().append(array1, array1).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array2).toComparison() == 0); assertTrue(new CompareToBuilder().append(array1, array3).toComparison() < 0); @@ -947,11 +947,11 @@ public class CompareToBuilderTest { array3[0] = new TestObject(4); array3[1] = new TestObject(5); array3[2] = new TestObject(6); - + final Object obj1 = array1; final Object obj2 = array2; final Object obj3 = array3; - + assertTrue(new CompareToBuilder().append(obj1, obj1).toComparison() == 0); assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() == 0); assertTrue(new CompareToBuilder().append(obj1, obj3).toComparison() < 0); @@ -1161,5 +1161,5 @@ public class CompareToBuilderTest { assertTrue(new CompareToBuilder().append(obj1, obj2).toComparison() > 0); assertTrue(new CompareToBuilder().append(obj2, obj1).toComparison() < 0); } - + } diff --git a/src/test/java/org/apache/commons/lang3/builder/DefaultToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/DefaultToStringStyleTest.java index b8fd1f1a2..6bc92239e 100644 --- a/src/test/java/org/apache/commons/lang3/builder/DefaultToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/DefaultToStringStyleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,7 +33,7 @@ public class DefaultToStringStyleTest { private final Integer base = Integer.valueOf(5); private final String baseStr = base.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(base)); - + @Before public void setUp() throws Exception { ToStringBuilder.setDefaultStyle(ToStringStyle.DEFAULT_STYLE); @@ -45,7 +45,7 @@ public class DefaultToStringStyleTest { } //---------------------------------------------------------------- - + @Test public void testBlank() { assertEquals(baseStr + "[]", new ToStringBuilder(base).toString()); @@ -55,12 +55,12 @@ public class DefaultToStringStyleTest { public void testAppendSuper() { assertEquals(baseStr + "[]", new ToStringBuilder(base).appendSuper("Integer@8888[]").toString()); assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).appendSuper("Integer@8888[<null>]").toString()); - + assertEquals(baseStr + "[a=hello]", new ToStringBuilder(base).appendSuper("Integer@8888[]").append("a", "hello").toString()); assertEquals(baseStr + "[<null>,a=hello]", new ToStringBuilder(base).appendSuper("Integer@8888[<null>]").append("a", "hello").toString()); assertEquals(baseStr + "[a=hello]", new ToStringBuilder(base).appendSuper(null).append("a", "hello").toString()); } - + @Test public void testObject() { final Integer i3 = Integer.valueOf(3); diff --git a/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java index 75bd48a5e..b2453a471 100644 --- a/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/DiffBuilderTest.java @@ -32,7 +32,7 @@ import org.junit.Test; * Unit tests {@link DiffBuilder}. */ public class DiffBuilderTest { - + private static final ToStringStyle SHORT_STYLE = ToStringStyle.SHORT_PREFIX_STYLE; private static class TypeTestClass implements Diffable<TypeTestClass> { @@ -78,20 +78,20 @@ public class DiffBuilderTest { .append("objectField", objectField, obj.objectField) .append("objectArrayField", objectArrayField, obj.objectArrayField) .build(); - } + } @Override public int hashCode() { return HashCodeBuilder.reflectionHashCode(this, false); } - + @Override public boolean equals(final Object obj) { return EqualsBuilder.reflectionEquals(this, obj, false); } } - - + + @Test public void testBoolean() { final TypeTestClass class1 = new TypeTestClass(); @@ -102,7 +102,7 @@ public class DiffBuilderTest { final Diff<?> diff = list.getDiffs().get(0); assertEquals(Boolean.class, diff.getType()); assertEquals(Boolean.TRUE, diff.getLeft()); - assertEquals(Boolean.FALSE, diff.getRight()); + assertEquals(Boolean.FALSE, diff.getRight()); } @Test @@ -113,13 +113,13 @@ public class DiffBuilderTest { final DiffResult list = class1.diff(class2); assertEquals(1, list.getNumberOfDiffs()); final Diff<?> diff = list.getDiffs().get(0); - assertArrayEquals(ArrayUtils.toObject(class1.booleanArrayField), + assertArrayEquals(ArrayUtils.toObject(class1.booleanArrayField), (Object[]) diff.getLeft()); - assertArrayEquals(ArrayUtils.toObject(class2.booleanArrayField), + assertArrayEquals(ArrayUtils.toObject(class2.booleanArrayField), (Object[]) diff.getRight()); } - + @Test public void testByte() { final TypeTestClass class1 = new TypeTestClass(); @@ -129,9 +129,9 @@ public class DiffBuilderTest { assertEquals(1, list.getNumberOfDiffs()); final Diff<?> diff = list.getDiffs().get(0); assertEquals(Byte.valueOf(class1.byteField), diff.getLeft()); - assertEquals(Byte.valueOf(class2.byteField), diff.getRight()); + assertEquals(Byte.valueOf(class2.byteField), diff.getRight()); } - + @Test public void testByteArray() throws Exception { final TypeTestClass class1 = new TypeTestClass(); @@ -140,9 +140,9 @@ public class DiffBuilderTest { final DiffResult list = class1.diff(class2); assertEquals(1, list.getNumberOfDiffs()); final Diff<?> diff = list.getDiffs().get(0); - assertArrayEquals(ArrayUtils.toObject(class1.byteArrayField), + assertArrayEquals(ArrayUtils.toObject(class1.byteArrayField), (Object[]) diff.getLeft()); - assertArrayEquals(ArrayUtils.toObject(class2.byteArrayField), + assertArrayEquals(ArrayUtils.toObject(class2.byteArrayField), (Object[]) diff.getRight()); } @@ -157,8 +157,8 @@ public class DiffBuilderTest { assertEquals(Character.valueOf(class1.charField), diff.getLeft()); assertEquals(Character.valueOf(class2.charField), diff.getRight()); } - - + + @Test public void testCharArray() throws Exception { final TypeTestClass class1 = new TypeTestClass(); @@ -167,13 +167,13 @@ public class DiffBuilderTest { final DiffResult list = class1.diff(class2); assertEquals(1, list.getNumberOfDiffs()); final Diff<?> diff = list.getDiffs().get(0); - assertArrayEquals(ArrayUtils.toObject(class1.charArrayField), + assertArrayEquals(ArrayUtils.toObject(class1.charArrayField), (Object[]) diff.getLeft()); - assertArrayEquals(ArrayUtils.toObject(class2.charArrayField), + assertArrayEquals(ArrayUtils.toObject(class2.charArrayField), (Object[]) diff.getRight()); } - - + + @Test public void testDouble() { final TypeTestClass class1 = new TypeTestClass(); @@ -184,9 +184,9 @@ public class DiffBuilderTest { final Diff<?> diff = list.getDiffs().get(0); assertEquals(Double.valueOf(class1.doubleField), diff.getLeft()); assertEquals(Double.valueOf(class2.doubleField), diff.getRight()); - } + } + - @Test public void testDoubleArray() throws Exception { final TypeTestClass class1 = new TypeTestClass(); @@ -195,12 +195,12 @@ public class DiffBuilderTest { final DiffResult list = class1.diff(class2); assertEquals(1, list.getNumberOfDiffs()); final Diff<?> diff = list.getDiffs().get(0); - assertArrayEquals(ArrayUtils.toObject(class1.doubleArrayField), + assertArrayEquals(ArrayUtils.toObject(class1.doubleArrayField), (Object[]) diff.getLeft()); - assertArrayEquals(ArrayUtils.toObject(class2.doubleArrayField), + assertArrayEquals(ArrayUtils.toObject(class2.doubleArrayField), (Object[]) diff.getRight()); } - + @Test public void testFloat() { final TypeTestClass class1 = new TypeTestClass(); @@ -211,9 +211,9 @@ public class DiffBuilderTest { final Diff<?> diff = list.getDiffs().get(0); assertEquals(Float.valueOf(class1.floatField), diff.getLeft()); assertEquals(Float.valueOf(class2.floatField), diff.getRight()); - } + } + - @Test public void testFloatArray() throws Exception { final TypeTestClass class1 = new TypeTestClass(); @@ -222,13 +222,13 @@ public class DiffBuilderTest { final DiffResult list = class1.diff(class2); assertEquals(1, list.getNumberOfDiffs()); final Diff<?> diff = list.getDiffs().get(0); - assertArrayEquals(ArrayUtils.toObject(class1.floatArrayField), + assertArrayEquals(ArrayUtils.toObject(class1.floatArrayField), (Object[]) diff.getLeft()); - assertArrayEquals(ArrayUtils.toObject(class2.floatArrayField), + assertArrayEquals(ArrayUtils.toObject(class2.floatArrayField), (Object[]) diff.getRight()); - } - - + } + + @Test public void testInt() { final TypeTestClass class1 = new TypeTestClass(); @@ -239,9 +239,9 @@ public class DiffBuilderTest { final Diff<?> diff = list.getDiffs().get(0); assertEquals(Integer.valueOf(class1.intField), diff.getLeft()); assertEquals(Integer.valueOf(class2.intField), diff.getRight()); - } + } + - @Test public void testIntArray() throws Exception { final TypeTestClass class1 = new TypeTestClass(); @@ -250,12 +250,12 @@ public class DiffBuilderTest { final DiffResult list = class1.diff(class2); assertEquals(1, list.getNumberOfDiffs()); final Diff<?> diff = list.getDiffs().get(0); - assertArrayEquals(ArrayUtils.toObject(class1.intArrayField), + assertArrayEquals(ArrayUtils.toObject(class1.intArrayField), (Object[]) diff.getLeft()); - assertArrayEquals(ArrayUtils.toObject(class2.intArrayField), + assertArrayEquals(ArrayUtils.toObject(class2.intArrayField), (Object[]) diff.getRight()); } - + @Test public void testLong() { final TypeTestClass class1 = new TypeTestClass(); @@ -266,9 +266,9 @@ public class DiffBuilderTest { final Diff<?> diff = list.getDiffs().get(0); assertEquals(Long.valueOf(class1.longField), diff.getLeft()); assertEquals(Long.valueOf(class2.longField), diff.getRight()); - } + } + - @Test public void testLongArray() throws Exception { final TypeTestClass class1 = new TypeTestClass(); @@ -277,12 +277,12 @@ public class DiffBuilderTest { final DiffResult list = class1.diff(class2); assertEquals(1, list.getNumberOfDiffs()); final Diff<?> diff = list.getDiffs().get(0); - assertArrayEquals(ArrayUtils.toObject(class1.longArrayField), + assertArrayEquals(ArrayUtils.toObject(class1.longArrayField), (Object[]) diff.getLeft()); - assertArrayEquals(ArrayUtils.toObject(class2.longArrayField), + assertArrayEquals(ArrayUtils.toObject(class2.longArrayField), (Object[]) diff.getRight()); } - + @Test public void testShort() { final TypeTestClass class1 = new TypeTestClass(); @@ -293,9 +293,9 @@ public class DiffBuilderTest { final Diff<?> diff = list.getDiffs().get(0); assertEquals(Short.valueOf(class1.shortField), diff.getLeft()); assertEquals(Short.valueOf(class2.shortField), diff.getRight()); - } + } + - @Test public void testShortArray() throws Exception { final TypeTestClass class1 = new TypeTestClass(); @@ -304,14 +304,14 @@ public class DiffBuilderTest { final DiffResult list = class1.diff(class2); assertEquals(1, list.getNumberOfDiffs()); final Diff<?> diff = list.getDiffs().get(0); - assertArrayEquals(ArrayUtils.toObject(class1.shortArrayField), + assertArrayEquals(ArrayUtils.toObject(class1.shortArrayField), (Object[]) diff.getLeft()); - assertArrayEquals(ArrayUtils.toObject(class2.shortArrayField), + assertArrayEquals(ArrayUtils.toObject(class2.shortArrayField), (Object[]) diff.getRight()); } - + @Test - public void testObject() throws Exception { + public void testObject() throws Exception { final TypeTestClass class1 = new TypeTestClass(); final TypeTestClass class2 = new TypeTestClass(); class2.objectField = "Some string"; @@ -319,11 +319,11 @@ public class DiffBuilderTest { assertEquals(1, list.getNumberOfDiffs()); final Diff<?> diff = list.getDiffs().get(0); assertEquals(class1.objectField, diff.getLeft()); - assertEquals(class2.objectField, diff.getRight()); + assertEquals(class2.objectField, diff.getRight()); } - /** - * Test that "left" and "right" are the same instance and are equal. + /** + * Test that "left" and "right" are the same instance and are equal. */ @Test public void testObjectsSameAndEqual() throws Exception { @@ -339,8 +339,8 @@ public class DiffBuilderTest { assertEquals(0, list.getNumberOfDiffs()); } - /** - * Test that "left" and "right" are the same instance but are equal. + /** + * Test that "left" and "right" are the same instance but are equal. */ @Test public void testObjectsNotSameButEqual() throws Exception { @@ -355,8 +355,8 @@ public class DiffBuilderTest { assertEquals(0, list.getNumberOfDiffs()); } - /** - * Test that "left" and "right" are not the same instance and are not equal. + /** + * Test that "left" and "right" are not the same instance and are not equal. */ @Test public void testObjectsNotSameNorEqual() throws Exception { @@ -381,8 +381,8 @@ public class DiffBuilderTest { final Diff<?> diff = list.getDiffs().get(0); assertArrayEquals(class1.objectArrayField, (Object[]) diff.getLeft()); assertArrayEquals(class2.objectArrayField, (Object[]) diff.getRight()); - } - + } + @Test public void testObjectArrayEqual() throws Exception { final TypeTestClass class1 = new TypeTestClass(); @@ -391,9 +391,9 @@ public class DiffBuilderTest { class2.objectArrayField = new Object[] {"string", 1, 2}; final DiffResult list = class1.diff(class2); assertEquals(0, list.getNumberOfDiffs()); - } - - + } + + @Test public void testByteArrayEqualAsObject() throws Exception { final DiffResult list = new DiffBuilder("String1", "String2", SHORT_STYLE) @@ -410,7 +410,7 @@ public class DiffBuilderTest { assertEquals(0, list.getNumberOfDiffs()); } - + @Test public void testDiffResult() { final TypeTestClass class1 = new TypeTestClass(); @@ -425,25 +425,25 @@ public class DiffBuilderTest { } @Test(expected=IllegalArgumentException.class) - public void testNullLhs() { + public void testNullLhs() { new DiffBuilder(null, this, ToStringStyle.DEFAULT_STYLE); } - + @Test(expected=IllegalArgumentException.class) - public void testNullRhs() { + public void testNullRhs() { new DiffBuilder(this, null, ToStringStyle.DEFAULT_STYLE); - } - + } + @Test public void testSameObjectIgnoresAppends() { - final TypeTestClass testClass = new TypeTestClass(); + final TypeTestClass testClass = new TypeTestClass(); final DiffResult list = new DiffBuilder(testClass, testClass, SHORT_STYLE) .append("ignored", false, true) .build(); assertEquals(0, list.getNumberOfDiffs()); } - + @Test public void testSimilarObjectIgnoresAppends() { final TypeTestClass testClass1 = new TypeTestClass(); @@ -453,14 +453,14 @@ public class DiffBuilderTest { .build(); assertEquals(0, list.getNumberOfDiffs()); } - - + + @Test public void testStylePassedToDiffResult() { final TypeTestClass class1 = new TypeTestClass(); DiffResult list = class1.diff(class1); assertEquals(SHORT_STYLE, list.getToStringStyle()); - + class1.style = ToStringStyle.MULTI_LINE_STYLE; list = class1.diff(class1); assertEquals(ToStringStyle.MULTI_LINE_STYLE, list.getToStringStyle()); diff --git a/src/test/java/org/apache/commons/lang3/builder/DiffTest.java b/src/test/java/org/apache/commons/lang3/builder/DiffTest.java index 26bf95a0c..1aff66ff8 100644 --- a/src/test/java/org/apache/commons/lang3/builder/DiffTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/DiffTest.java @@ -28,12 +28,12 @@ public class DiffTest { private static final String FIELD_NAME = "field"; private static final Diff<Boolean> booleanDiff = new BooleanDiff(FIELD_NAME); - - private static class BooleanDiff extends Diff<Boolean> { + + private static class BooleanDiff extends Diff<Boolean> { private static final long serialVersionUID = 1L; protected BooleanDiff(final String fieldName) { - super(fieldName); + super(fieldName); } @Override @@ -44,27 +44,27 @@ public class DiffTest { @Override public Boolean getRight() { return Boolean.FALSE; - } + } } - + @Test(expected = UnsupportedOperationException.class) public void testCannotModify() { booleanDiff.setValue(Boolean.FALSE); } - + @Test public void testGetFieldName() { assertEquals(FIELD_NAME, booleanDiff.getFieldName()); } - + @Test public void testGetType() { assertEquals(Boolean.class, booleanDiff.getType()); } - + @Test public void testToString() { - assertEquals(String.format("[%s: %s, %s]", FIELD_NAME, booleanDiff.getLeft(), + assertEquals(String.format("[%s: %s, %s]", FIELD_NAME, booleanDiff.getLeft(), booleanDiff.getRight()), booleanDiff.toString()); } } diff --git a/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java index b5cfdfa0e..0e0f5f452 100644 --- a/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/EqualsBuilderTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -99,7 +99,7 @@ public class EqualsBuilderTest { return b; } } - + static class TestEmptySubObject extends TestObject { public TestEmptySubObject(final int a) { super(a); @@ -150,17 +150,17 @@ public class EqualsBuilderTest { private final TestRecursiveInnerObject a; private final TestRecursiveInnerObject b; private int z; - - public TestRecursiveObject(final TestRecursiveInnerObject a, + + public TestRecursiveObject(final TestRecursiveInnerObject a, final TestRecursiveInnerObject b, final int z) { this.a = a; this.b = b; } - + public TestRecursiveInnerObject getA() { return a; } - + public TestRecursiveInnerObject getB() { return b; } @@ -168,7 +168,7 @@ public class EqualsBuilderTest { public int getZ() { return z; } - + } static class TestRecursiveInnerObject { @@ -176,7 +176,7 @@ public class EqualsBuilderTest { public TestRecursiveInnerObject(final int n) { this.n = n; } - + public int getN() { return n; } @@ -189,20 +189,20 @@ public class EqualsBuilderTest { this.n = n; this.cycle = this; } - + public TestRecursiveCycleObject(final TestRecursiveCycleObject cycle, final int n) { this.n = n; this.cycle = cycle; } - + public int getN() { return n; } - + public TestRecursiveCycleObject getCycle() { return cycle; } - + public void setCycle(final TestRecursiveCycleObject cycle) { this.cycle = cycle; } @@ -223,7 +223,7 @@ public class EqualsBuilderTest { assertFalse(EqualsBuilder.reflectionEquals(null, o2)); assertTrue(EqualsBuilder.reflectionEquals(null, null)); } - + @Test public void testReflectionHierarchyEquals() { testReflectionHierarchyEquals(false); @@ -306,7 +306,7 @@ public class EqualsBuilderTest { * @param toTer Left hand side, equal to to and toBis * @param to2 a different TestObject * @param oToChange a TestObject that will be changed - * @param testTransients whether to test transient instance variables + * @param testTransients whether to test transient instance variables */ private void testReflectionEqualsEquivalenceRelationship( final TestObject to, @@ -371,12 +371,12 @@ public class EqualsBuilderTest { assertTrue(new EqualsBuilder().append(o1, o2).isEquals()); assertFalse(new EqualsBuilder().append(o1, this).isEquals()); - + assertFalse(new EqualsBuilder().append(o1, null).isEquals()); assertFalse(new EqualsBuilder().append(null, o2).isEquals()); assertTrue(new EqualsBuilder().append((Object) null, null).isEquals()); } - + @Test public void testObjectBuild() { final TestObject o1 = new TestObject(4); @@ -387,7 +387,7 @@ public class EqualsBuilderTest { assertEquals(Boolean.TRUE, new EqualsBuilder().append(o1, o2).build()); assertEquals(Boolean.FALSE, new EqualsBuilder().append(o1, this).build()); - + assertEquals(Boolean.FALSE, new EqualsBuilder().append(o1, null).build()); assertEquals(Boolean.FALSE, new EqualsBuilder().append(null, o2).build()); assertEquals(Boolean.TRUE, new EqualsBuilder().append((Object) null, null).build()); @@ -401,17 +401,17 @@ public class EqualsBuilderTest { final TestRecursiveInnerObject i2_2 = new TestRecursiveInnerObject(2); final TestRecursiveInnerObject i3 = new TestRecursiveInnerObject(3); final TestRecursiveInnerObject i4 = new TestRecursiveInnerObject(4); - + final TestRecursiveObject o1_a = new TestRecursiveObject(i1_1, i2_1, 1); final TestRecursiveObject o1_b = new TestRecursiveObject(i1_2, i2_2, 1); final TestRecursiveObject o2 = new TestRecursiveObject(i3, i4, 2); final TestRecursiveObject oNull = new TestRecursiveObject(null, null, 2); - + assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1_a, o1_a).isEquals()); assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1_a, o1_b).isEquals()); - + assertFalse(new EqualsBuilder().setTestRecursive(true).append(o1_a, o2).isEquals()); - + assertTrue(new EqualsBuilder().setTestRecursive(true).append(oNull, oNull).isEquals()); assertFalse(new EqualsBuilder().setTestRecursive(true).append(o1_a, oNull).isEquals()); } @@ -421,7 +421,7 @@ public class EqualsBuilderTest { final TestRecursiveCycleObject o1_a = new TestRecursiveCycleObject(1); final TestRecursiveCycleObject o1_b = new TestRecursiveCycleObject(1); final TestRecursiveCycleObject o2 = new TestRecursiveCycleObject(2); - + assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1_a, o1_a).isEquals()); assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1_a, o1_b).isEquals()); assertFalse(new EqualsBuilder().setTestRecursive(true).append(o1_a, o2).isEquals()); @@ -432,19 +432,19 @@ public class EqualsBuilderTest { final TestRecursiveCycleObject o1_a = new TestRecursiveCycleObject(1); final TestRecursiveCycleObject i1_a = new TestRecursiveCycleObject(o1_a, 100); o1_a.setCycle(i1_a); - + final TestRecursiveCycleObject o1_b = new TestRecursiveCycleObject(1); final TestRecursiveCycleObject i1_b = new TestRecursiveCycleObject(o1_b, 100); o1_b.setCycle(i1_b); - + final TestRecursiveCycleObject o2 = new TestRecursiveCycleObject(2); final TestRecursiveCycleObject i2 = new TestRecursiveCycleObject(o1_b, 200); o2.setCycle(i2); - + assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1_a, o1_a).isEquals()); assertTrue(new EqualsBuilder().setTestRecursive(true).append(o1_a, o1_b).isEquals()); assertFalse(new EqualsBuilder().setTestRecursive(true).append(o1_a, o2).isEquals()); - + assertTrue(EqualsBuilder.reflectionEquals(o1_a, o1_b, false, null, true)); assertFalse(EqualsBuilder.reflectionEquals(o1_a, o2, false, null, true)); } @@ -530,7 +530,7 @@ public class EqualsBuilderTest { equalsBuilder.reset(); assertTrue(equalsBuilder.isEquals()); } - + @Test public void testBoolean() { final boolean o1 = true; @@ -549,7 +549,7 @@ public class EqualsBuilderTest { obj2[0] = new TestObject(4); obj2[1] = new TestObject(5); obj2[2] = null; - + assertTrue(new EqualsBuilder().append(obj1, obj1).isEquals()); assertTrue(new EqualsBuilder().append(obj2, obj2).isEquals()); assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals()); @@ -561,7 +561,7 @@ public class EqualsBuilderTest { assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals()); obj1[2] = null; assertTrue(new EqualsBuilder().append(obj1, obj2).isEquals()); - + obj2 = null; assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals()); obj1 = null; @@ -846,7 +846,7 @@ public class EqualsBuilderTest { assertTrue(new EqualsBuilder().append(array1, array2).isEquals()); array1[1][1] = false; assertFalse(new EqualsBuilder().append(array1, array2).isEquals()); - + // compare 1 dim to 2. final boolean[] array3 = new boolean[]{true, true}; assertFalse(new EqualsBuilder().append(array1, array3).isEquals()); @@ -1052,7 +1052,7 @@ public class EqualsBuilderTest { array1[1] = true; assertFalse(new EqualsBuilder().append(obj1, obj2).isEquals()); } - + public static class TestACanEqualB { private final int a; @@ -1114,7 +1114,7 @@ public class EqualsBuilderTest { return this.b; } } - + /** * Tests two instances of classes that can be equal and that are not "related". The two classes are not subclasses * of each other and do not share a parent aside from Object. @@ -1140,7 +1140,7 @@ public class EqualsBuilderTest { assertTrue(new EqualsBuilder().append(x, y).isEquals()); assertTrue(new EqualsBuilder().append(y, x).isEquals()); } - + /** * Test from http://issues.apache.org/bugzilla/show_bug.cgi?id=33067 */ @@ -1193,7 +1193,7 @@ public class EqualsBuilderTest { this.three = new TestObject(three); } } - + /** * Test cyclical object references which cause a StackOverflowException if * not handled properly. s. LANG-606 @@ -1242,7 +1242,7 @@ public class EqualsBuilderTest { return EqualsBuilder.reflectionEquals(this, obj); } } - + @Test public void testReflectionArrays() throws Exception { @@ -1256,11 +1256,11 @@ public class EqualsBuilderTest { assertFalse(EqualsBuilder.reflectionEquals(o1, o2)); assertTrue(EqualsBuilder.reflectionEquals(o1, o1)); assertTrue(EqualsBuilder.reflectionEquals(o1, o3)); - + final double[] d1 = { 0, 1 }; final double[] d2 = { 2, 3 }; final double[] d3 = { 0, 1 }; - + assertFalse(EqualsBuilder.reflectionEquals(d1, d2)); assertTrue(EqualsBuilder.reflectionEquals(d1, d1)); assertTrue(EqualsBuilder.reflectionEquals(d1, d3)); diff --git a/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderAndEqualsBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderAndEqualsBuilderTest.java index aa61e022b..f39d26abd 100644 --- a/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderAndEqualsBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderAndEqualsBuilderTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -72,9 +72,9 @@ public class HashCodeBuilderAndEqualsBuilderTest { } /** - * Asserts that if <code>lhs</code> equals <code>rhs</code> + * Asserts that if <code>lhs</code> equals <code>rhs</code> * then their hash codes MUST be identical. - * + * * @param lhs The Left-Hand-Side of the equals test * @param rhs The Right-Hand-Side of the equals test * @param testTransients whether to test transient fields diff --git a/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java index 633f5f566..4ded427c1 100644 --- a/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/HashCodeBuilderTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -61,7 +61,7 @@ public class HashCodeBuilderTest { public void testConstructorExEvenFirst() { new HashCodeBuilder(2, 3); } - + @Test(expected=IllegalArgumentException.class) public void testConstructorExEvenSecond() { new HashCodeBuilder(3, 2); @@ -195,7 +195,7 @@ public class HashCodeBuilderTest { obj = new Object(); assertEquals(17 * 37 + obj.hashCode(), new HashCodeBuilder(17, 37).append(obj).toHashCode()); } - + @Test public void testObjectBuild() { Object obj = null; @@ -529,7 +529,7 @@ public class HashCodeBuilderTest { final ReflectionTestCycleB b = new ReflectionTestCycleB(); a.b = b; b.a = a; - + // Used to caused: // java.lang.StackOverflowError // at java.lang.ClassLoader.getCallerClassLoader(Native Method) @@ -559,7 +559,7 @@ public class HashCodeBuilderTest { @Test public void testToHashCodeEqualsHashCode() { final HashCodeBuilder hcb = new HashCodeBuilder(17, 37).append(new Object()).append('a'); - assertEquals("hashCode() is no longer returning the same value as toHashCode() - see LANG-520", + assertEquals("hashCode() is no longer returning the same value as toHashCode() - see LANG-520", hcb.toHashCode(), hcb.hashCode()); } diff --git a/src/test/java/org/apache/commons/lang3/builder/JsonToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/JsonToStringStyleTest.java index c60dc050c..6f76cfecf 100644 --- a/src/test/java/org/apache/commons/lang3/builder/JsonToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/JsonToStringStyleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -224,7 +224,7 @@ public class JsonToStringStyleTest { .append("age", p.age).append("smoker", p.smoker) .toString()); } - + @Test public void testNestingPerson() { final Person p = new Person(){ @@ -357,10 +357,10 @@ public class JsonToStringStyleTest { } catch (final UnsupportedOperationException e) { } } - + /** * An object with nested object structures used to test {@link ToStringStyle.JsonToStringStyle}. - * + * */ static class NestingPerson { /** diff --git a/src/test/java/org/apache/commons/lang3/builder/MultiLineToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/MultiLineToStringStyleTest.java index 8454c5bf7..ca02df0dd 100644 --- a/src/test/java/org/apache/commons/lang3/builder/MultiLineToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/MultiLineToStringStyleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,7 +33,7 @@ public class MultiLineToStringStyleTest { private final Integer base = Integer.valueOf(5); private final String baseStr = base.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(base)); - + @Before public void setUp() throws Exception { ToStringBuilder.setDefaultStyle(ToStringStyle.MULTI_LINE_STYLE); @@ -55,12 +55,12 @@ public class MultiLineToStringStyleTest { public void testAppendSuper() { assertEquals(baseStr + "[" + System.lineSeparator() + "]", new ToStringBuilder(base).appendSuper("Integer@8888[" + System.lineSeparator() + "]").toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " <null>" + System.lineSeparator() + "]", new ToStringBuilder(base).appendSuper("Integer@8888[" + System.lineSeparator() + " <null>" + System.lineSeparator() + "]").toString()); - + assertEquals(baseStr + "[" + System.lineSeparator() + " a=hello" + System.lineSeparator() + "]", new ToStringBuilder(base).appendSuper("Integer@8888[" + System.lineSeparator() + "]").append("a", "hello").toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " <null>" + System.lineSeparator() + " a=hello" + System.lineSeparator() + "]", new ToStringBuilder(base).appendSuper("Integer@8888[" + System.lineSeparator() + " <null>" + System.lineSeparator() + "]").append("a", "hello").toString()); assertEquals(baseStr + "[" + System.lineSeparator() + " a=hello" + System.lineSeparator() + "]", new ToStringBuilder(base).appendSuper(null).append("a", "hello").toString()); } - + @Test public void testObject() { final Integer i3 = Integer.valueOf(3); diff --git a/src/test/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyleTest.java index 08c638230..cb08ae01e 100644 --- a/src/test/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/MultilineRecursiveToStringStyleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,9 +33,9 @@ public class MultilineRecursiveToStringStyleTest { @Test public void simpleObject() { final Transaction tx = new Transaction("2014.10.15", 100); - final String expected = getClassPrefix(tx) + "[" + BR - + " amount=100.0," + BR - + " date=2014.10.15" + BR + final String expected = getClassPrefix(tx) + "[" + BR + + " amount=100.0," + BR + + " date=2014.10.15" + BR + "]"; assertEquals(expected, toString(tx)); } @@ -45,12 +45,12 @@ public class MultilineRecursiveToStringStyleTest { final Customer customer = new Customer("Douglas Adams"); final Bank bank = new Bank("ASF Bank"); customer.bank = bank; - final String exp = getClassPrefix(customer) + "[" + BR - + " name=Douglas Adams," + BR - + " bank=" + getClassPrefix(bank) + "[" + BR - + " name=ASF Bank" + BR - + " ]," + BR - + " accounts=<null>" + BR + final String exp = getClassPrefix(customer) + "[" + BR + + " name=Douglas Adams," + BR + + " bank=" + getClassPrefix(bank) + "[" + BR + + " name=ASF Bank" + BR + + " ]," + BR + + " accounts=<null>" + BR + "]"; assertEquals(exp, toString(customer)); } @@ -62,18 +62,18 @@ public class MultilineRecursiveToStringStyleTest { final Transaction tx2 = new Transaction("2014.10.15", 50); acc.transactions.add(tx1); acc.transactions.add(tx2); - final String expected = getClassPrefix(acc) + "[" + BR - + " owner=<null>," + BR - + " transactions=" + getClassPrefix(acc.transactions) + "{" + BR - + " " + getClassPrefix(tx1) + "[" + BR - + " amount=100.0," + BR - + " date=2014.10.14" + BR - + " ]," + BR + final String expected = getClassPrefix(acc) + "[" + BR + + " owner=<null>," + BR + + " transactions=" + getClassPrefix(acc.transactions) + "{" + BR + + " " + getClassPrefix(tx1) + "[" + BR + + " amount=100.0," + BR + + " date=2014.10.14" + BR + + " ]," + BR + " " + getClassPrefix(tx2) + "[" + BR - + " amount=50.0," + BR - + " date=2014.10.15" + BR - + " ]" + BR - + " }" + BR + + " amount=50.0," + BR + + " date=2014.10.15" + BR + + " ]" + BR + + " }" + BR + "]"; assertEquals(expected, toString(acc)); } @@ -81,13 +81,13 @@ public class MultilineRecursiveToStringStyleTest { @Test public void noArray() { final WithArrays wa = new WithArrays(); - final String exp = getClassPrefix(wa) + "[" + BR - + " boolArray=<null>," + BR + final String exp = getClassPrefix(wa) + "[" + BR + + " boolArray=<null>," + BR + " charArray=<null>," + BR - + " intArray=<null>," + BR - + " doubleArray=<null>," + BR - + " longArray=<null>," + BR - + " stringArray=<null>" + BR + + " intArray=<null>," + BR + + " doubleArray=<null>," + BR + + " longArray=<null>," + BR + + " stringArray=<null>" + BR + "]"; assertEquals(exp, toString(wa)); } @@ -96,17 +96,17 @@ public class MultilineRecursiveToStringStyleTest { public void boolArray() { final WithArrays wa = new WithArrays(); wa.boolArray = new boolean[] { true, false, true }; - final String exp = getClassPrefix(wa) + "[" + BR - + " boolArray={" + BR - + " true," + BR - + " false," + BR - + " true" + BR - + " }," + BR - + " charArray=<null>," + BR - + " intArray=<null>," + BR + final String exp = getClassPrefix(wa) + "[" + BR + + " boolArray={" + BR + + " true," + BR + + " false," + BR + + " true" + BR + + " }," + BR + + " charArray=<null>," + BR + + " intArray=<null>," + BR + " doubleArray=<null>," + BR - + " longArray=<null>," + BR - + " stringArray=<null>" + BR + + " longArray=<null>," + BR + + " stringArray=<null>" + BR + "]"; assertEquals(exp, toString(wa)); } @@ -115,16 +115,16 @@ public class MultilineRecursiveToStringStyleTest { public void charArray() { final WithArrays wa = new WithArrays(); wa.charArray = new char[] { 'a', 'A' }; - final String exp = getClassPrefix(wa) + "[" + BR - + " boolArray=<null>," + BR - + " charArray={" + BR - + " a," + BR - + " A" + BR - + " }," + BR - + " intArray=<null>," + BR - + " doubleArray=<null>," + BR + final String exp = getClassPrefix(wa) + "[" + BR + + " boolArray=<null>," + BR + + " charArray={" + BR + + " a," + BR + + " A" + BR + + " }," + BR + + " intArray=<null>," + BR + + " doubleArray=<null>," + BR + " longArray=<null>," + BR - + " stringArray=<null>" + BR + + " stringArray=<null>" + BR + "]"; assertEquals(exp, toString(wa)); } @@ -133,16 +133,16 @@ public class MultilineRecursiveToStringStyleTest { public void intArray() { final WithArrays wa = new WithArrays(); wa.intArray = new int[] { 1, 2 }; - final String exp = getClassPrefix(wa) + "[" + BR - + " boolArray=<null>," + BR - + " charArray=<null>," + BR - + " intArray={" + BR - + " 1," + BR - + " 2" + BR - + " }," + BR - + " doubleArray=<null>," + BR + final String exp = getClassPrefix(wa) + "[" + BR + + " boolArray=<null>," + BR + + " charArray=<null>," + BR + + " intArray={" + BR + + " 1," + BR + + " 2" + BR + + " }," + BR + + " doubleArray=<null>," + BR + " longArray=<null>," + BR - + " stringArray=<null>" + BR + + " stringArray=<null>" + BR + "]"; assertEquals(exp, toString(wa)); } @@ -151,16 +151,16 @@ public class MultilineRecursiveToStringStyleTest { public void doubleArray() { final WithArrays wa = new WithArrays(); wa.doubleArray = new double[] { 1, 2 }; - final String exp = getClassPrefix(wa) + "[" + BR - + " boolArray=<null>," + BR + final String exp = getClassPrefix(wa) + "[" + BR + + " boolArray=<null>," + BR + " charArray=<null>," + BR - + " intArray=<null>," + BR - + " doubleArray={" + BR - + " 1.0," + BR - + " 2.0" + BR + + " intArray=<null>," + BR + + " doubleArray={" + BR + + " 1.0," + BR + + " 2.0" + BR + " }," + BR - + " longArray=<null>," + BR - + " stringArray=<null>" + BR + + " longArray=<null>," + BR + + " stringArray=<null>" + BR + "]"; assertEquals(exp, toString(wa)); } @@ -169,16 +169,16 @@ public class MultilineRecursiveToStringStyleTest { public void longArray() { final WithArrays wa = new WithArrays(); wa.longArray = new long[] { 1L, 2L }; - final String exp = getClassPrefix(wa) + "[" + BR - + " boolArray=<null>," + BR + final String exp = getClassPrefix(wa) + "[" + BR + + " boolArray=<null>," + BR + " charArray=<null>," + BR - + " intArray=<null>," + BR - + " doubleArray=<null>," + BR - + " longArray={" + BR - + " 1," + BR + + " intArray=<null>," + BR + + " doubleArray=<null>," + BR + + " longArray={" + BR + + " 1," + BR + " 2" + BR - + " }," + BR - + " stringArray=<null>" + BR + + " }," + BR + + " stringArray=<null>" + BR + "]"; assertEquals(exp, toString(wa)); } @@ -187,30 +187,30 @@ public class MultilineRecursiveToStringStyleTest { public void stringArray() { final WithArrays wa = new WithArrays(); wa.stringArray = new String[] { "a", "A" }; - final String exp = getClassPrefix(wa) + "[" + BR - + " boolArray=<null>," + BR + final String exp = getClassPrefix(wa) + "[" + BR + + " boolArray=<null>," + BR + " charArray=<null>," + BR - + " intArray=<null>," + BR - + " doubleArray=<null>," + BR - + " longArray=<null>," + BR + + " intArray=<null>," + BR + + " doubleArray=<null>," + BR + + " longArray=<null>," + BR + " stringArray={" + BR - + " a," + BR - + " A" + BR - + " }" + BR + + " a," + BR + + " A" + BR + + " }" + BR + "]"; assertEquals(exp, toString(wa)); } - - + + @Test public void testLANG1319() throws Exception { final String[] stringArray = {"1", "2"}; - - final String exp = getClassPrefix(stringArray) + "[" + BR - + " {" + BR - + " 1," + BR - + " 2" + BR - + " }" + BR + + final String exp = getClassPrefix(stringArray) + "[" + BR + + " {" + BR + + " 1," + BR + + " 2" + BR + + " }" + BR + "]"; assertEquals(exp, toString(stringArray)); } diff --git a/src/test/java/org/apache/commons/lang3/builder/NoClassNameToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/NoClassNameToStringStyleTest.java index 73184a5d5..4865b034c 100644 --- a/src/test/java/org/apache/commons/lang3/builder/NoClassNameToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/NoClassNameToStringStyleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/builder/NoFieldNamesToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/NoFieldNamesToStringStyleTest.java index d5388a91b..defd998bc 100644 --- a/src/test/java/org/apache/commons/lang3/builder/NoFieldNamesToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/NoFieldNamesToStringStyleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,7 +33,7 @@ public class NoFieldNamesToStringStyleTest { private final Integer base = Integer.valueOf(5); private final String baseStr = base.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(base)); - + @Before public void setUp() throws Exception { ToStringBuilder.setDefaultStyle(ToStringStyle.NO_FIELD_NAMES_STYLE); @@ -45,7 +45,7 @@ public class NoFieldNamesToStringStyleTest { } //---------------------------------------------------------------- - + @Test public void testBlank() { assertEquals(baseStr + "[]", new ToStringBuilder(base).toString()); @@ -55,12 +55,12 @@ public class NoFieldNamesToStringStyleTest { public void testAppendSuper() { assertEquals(baseStr + "[]", new ToStringBuilder(base).appendSuper("Integer@8888[]").toString()); assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).appendSuper("Integer@8888[<null>]").toString()); - + assertEquals(baseStr + "[hello]", new ToStringBuilder(base).appendSuper("Integer@8888[]").append("a", "hello").toString()); assertEquals(baseStr + "[<null>,hello]", new ToStringBuilder(base).appendSuper("Integer@8888[<null>]").append("a", "hello").toString()); assertEquals(baseStr + "[hello]", new ToStringBuilder(base).appendSuper(null).append("a", "hello").toString()); } - + @Test public void testObject() { final Integer i3 = Integer.valueOf(3); diff --git a/src/test/java/org/apache/commons/lang3/builder/RecursiveToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/RecursiveToStringStyleTest.java index dbf36c1b0..d46dd6d18 100644 --- a/src/test/java/org/apache/commons/lang3/builder/RecursiveToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/RecursiveToStringStyleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,7 +32,7 @@ public class RecursiveToStringStyleTest { private final Integer base = Integer.valueOf(5); private final String baseStr = base.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(base)); - + @Before public void setUp() throws Exception { ToStringBuilder.setDefaultStyle(new RecursiveToStringStyle()); @@ -44,7 +44,7 @@ public class RecursiveToStringStyleTest { } //---------------------------------------------------------------- - + @Test public void testBlank() { assertEquals(baseStr + "[]", new ToStringBuilder(base).toString()); @@ -54,25 +54,25 @@ public class RecursiveToStringStyleTest { public void testAppendSuper() { assertEquals(baseStr + "[]", new ToStringBuilder(base).appendSuper("Integer@8888[]").toString()); assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).appendSuper("Integer@8888[<null>]").toString()); - + assertEquals(baseStr + "[a=hello]", new ToStringBuilder(base).appendSuper("Integer@8888[]").append("a", "hello").toString()); assertEquals(baseStr + "[<null>,a=hello]", new ToStringBuilder(base).appendSuper("Integer@8888[<null>]").append("a", "hello").toString()); assertEquals(baseStr + "[a=hello]", new ToStringBuilder(base).appendSuper(null).append("a", "hello").toString()); } - + @Test public void testObject() { final Integer i3 = Integer.valueOf(3); final Integer i4 = Integer.valueOf(4); final ArrayList<Object> emptyList = new ArrayList<>(); - + assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append((Object) null).toString()); assertEquals(baseStr + "[3]", new ToStringBuilder(base).append(i3).toString()); assertEquals(baseStr + "[a=<null>]", new ToStringBuilder(base).append("a", (Object) null).toString()); assertEquals(baseStr + "[a=3]", new ToStringBuilder(base).append("a", i3).toString()); assertEquals(baseStr + "[a=3,b=4]", new ToStringBuilder(base).append("a", i3).append("b", i4).toString()); assertEquals(baseStr + "[a=<Integer>]", new ToStringBuilder(base).append("a", i3, false).toString()); - assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", emptyList, false).toString()); + assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", emptyList, false).toString()); assertEquals(baseStr + "[a=java.util.ArrayList@" + Integer.toHexString(System.identityHashCode(emptyList)) + "{}]", new ToStringBuilder(base).append("a", emptyList, true).toString()); assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", new HashMap<>(), false).toString()); @@ -147,13 +147,13 @@ public class RecursiveToStringStyleTest { * Test boolean field. */ boolean smoker; - + /** * Test Object field. */ Job job; } - + static class Job { /** * Test String field. diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderConcurrencyTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderConcurrencyTest.java index d5249d50c..7cd899e8a 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderConcurrencyTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderConcurrencyTest.java @@ -42,7 +42,7 @@ import org.junit.Test; * <p> * The tests on the non-thread-safe collections do not pass. * </p> - * + * * @see <a href="https://issues.apache.org/jira/browse/LANG-762">[LANG-762] Handle or document ReflectionToStringBuilder * and ToStringBuilder for collections that are not thread safe</a> * @since 3.1 diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java index dd94c51a7..4250ddf18 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -35,26 +35,26 @@ public class ReflectionToStringBuilderExcludeNullValuesTest { this.testStringField = b; } } - + private static final String INTEGER_FIELD_NAME = "testIntegerField"; private static final String STRING_FIELD_NAME = "testStringField"; private final TestFixture BOTH_NON_NULL = new TestFixture(0, "str"); private final TestFixture FIRST_NULL = new TestFixture(null, "str"); private final TestFixture SECOND_NULL = new TestFixture(0, null); private final TestFixture BOTH_NULL = new TestFixture(null, null); - + @Test public void test_NonExclude(){ //normal case= String toString = ReflectionToStringBuilder.toString(BOTH_NON_NULL, null, false, false, false, null); assertTrue(toString.contains(INTEGER_FIELD_NAME)); assertTrue(toString.contains(STRING_FIELD_NAME)); - + //make one null toString = ReflectionToStringBuilder.toString(FIRST_NULL, null, false, false, false, null); assertTrue(toString.contains(INTEGER_FIELD_NAME)); assertTrue(toString.contains(STRING_FIELD_NAME)); - + //other one null toString = ReflectionToStringBuilder.toString(SECOND_NULL, null, false, false, false, null); assertTrue(toString.contains(INTEGER_FIELD_NAME)); @@ -65,31 +65,31 @@ public class ReflectionToStringBuilderExcludeNullValuesTest { assertTrue(toString.contains(INTEGER_FIELD_NAME)); assertTrue(toString.contains(STRING_FIELD_NAME)); } - + @Test public void test_excludeNull(){ - + //test normal case String toString = ReflectionToStringBuilder.toString(BOTH_NON_NULL, null, false, false, true, null); assertTrue(toString.contains(INTEGER_FIELD_NAME)); assertTrue(toString.contains(STRING_FIELD_NAME)); - + //make one null toString = ReflectionToStringBuilder.toString(FIRST_NULL, null, false, false, true, null); assertFalse(toString.contains(INTEGER_FIELD_NAME)); assertTrue(toString.contains(STRING_FIELD_NAME)); - + //other one null toString = ReflectionToStringBuilder.toString(SECOND_NULL, null, false, false, true, null); assertTrue(toString.contains(INTEGER_FIELD_NAME)); assertFalse(toString.contains(STRING_FIELD_NAME)); - + //both null toString = ReflectionToStringBuilder.toString(BOTH_NULL, null, false, false, true, null); assertFalse(toString.contains(INTEGER_FIELD_NAME)); assertFalse(toString.contains(STRING_FIELD_NAME)); } - + @Test public void test_ConstructorOption(){ ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NON_NULL, null, null, null, false, false, true); @@ -97,23 +97,23 @@ public class ReflectionToStringBuilderExcludeNullValuesTest { String toString = builder.toString(); assertTrue(toString.contains(INTEGER_FIELD_NAME)); assertTrue(toString.contains(STRING_FIELD_NAME)); - + builder = new ReflectionToStringBuilder(FIRST_NULL, null, null, null, false, false, true); toString = builder.toString(); assertFalse(toString.contains(INTEGER_FIELD_NAME)); assertTrue(toString.contains(STRING_FIELD_NAME)); - + builder = new ReflectionToStringBuilder(SECOND_NULL, null, null, null, false, false, true); toString = builder.toString(); assertTrue(toString.contains(INTEGER_FIELD_NAME)); assertFalse(toString.contains(STRING_FIELD_NAME)); - + builder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false, true); toString = builder.toString(); assertFalse(toString.contains(INTEGER_FIELD_NAME)); assertFalse(toString.contains(STRING_FIELD_NAME)); } - + @Test public void test_ConstructorOptionNormal(){ ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false, false); @@ -121,24 +121,24 @@ public class ReflectionToStringBuilderExcludeNullValuesTest { String toString = builder.toString(); assertTrue(toString.contains(STRING_FIELD_NAME)); assertTrue(toString.contains(INTEGER_FIELD_NAME)); - + //regression test older constructors ReflectionToStringBuilder oldBuilder = new ReflectionToStringBuilder(BOTH_NULL); toString = oldBuilder.toString(); assertTrue(toString.contains(STRING_FIELD_NAME)); assertTrue(toString.contains(INTEGER_FIELD_NAME)); - + oldBuilder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false); toString = oldBuilder.toString(); assertTrue(toString.contains(STRING_FIELD_NAME)); assertTrue(toString.contains(INTEGER_FIELD_NAME)); - + oldBuilder = new ReflectionToStringBuilder(BOTH_NULL, null, null); toString = oldBuilder.toString(); assertTrue(toString.contains(STRING_FIELD_NAME)); assertTrue(toString.contains(INTEGER_FIELD_NAME)); } - + @Test public void test_ConstructorOption_ExcludeNull(){ ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false, false); @@ -147,12 +147,12 @@ public class ReflectionToStringBuilderExcludeNullValuesTest { String toString = builder.toString(); assertFalse(toString.contains(STRING_FIELD_NAME)); assertFalse(toString.contains(INTEGER_FIELD_NAME)); - + builder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false, true); toString = builder.toString(); assertFalse(toString.contains(STRING_FIELD_NAME)); assertFalse(toString.contains(INTEGER_FIELD_NAME)); - + ReflectionToStringBuilder oldBuilder = new ReflectionToStringBuilder(BOTH_NULL); oldBuilder.setExcludeNullValues(true); assertTrue(oldBuilder.isExcludeNullValues()); diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java index c36d254d8..aa8909e5b 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeWithAnnotationTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeWithAnnotationTest.java index fb237a564..a28cbb146 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeWithAnnotationTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeWithAnnotationTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderMutateInspectConcurrencyTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderMutateInspectConcurrencyTest.java index 8cb58e5d9..2cf240877 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderMutateInspectConcurrencyTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderMutateInspectConcurrencyTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,7 +29,7 @@ import org.junit.Test; * The {@link ToStringStyle} class includes a registry to avoid infinite loops for objects with circular references. We * want to make sure that we do not get concurrency exceptions accessing this registry. * </p> - * + * * @see <a href="https://issues.apache.org/jira/browse/LANG-762">[LANG-762] Handle or document ReflectionToStringBuilder * and ToStringBuilder for collections that are not thread safe</a> * @since 3.1 diff --git a/src/test/java/org/apache/commons/lang3/builder/ShortPrefixToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/ShortPrefixToStringStyleTest.java index e27e9f10c..62b8bac8b 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ShortPrefixToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ShortPrefixToStringStyleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,7 +33,7 @@ public class ShortPrefixToStringStyleTest { private final Integer base = Integer.valueOf(5); private final String baseStr = "Integer"; - + @Before public void setUp() throws Exception { ToStringBuilder.setDefaultStyle(ToStringStyle.SHORT_PREFIX_STYLE); @@ -45,7 +45,7 @@ public class ShortPrefixToStringStyleTest { } //---------------------------------------------------------------- - + @Test public void testBlank() { assertEquals(baseStr + "[]", new ToStringBuilder(base).toString()); @@ -55,12 +55,12 @@ public class ShortPrefixToStringStyleTest { public void testAppendSuper() { assertEquals(baseStr + "[]", new ToStringBuilder(base).appendSuper("Integer@8888[]").toString()); assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).appendSuper("Integer@8888[<null>]").toString()); - + assertEquals(baseStr + "[a=hello]", new ToStringBuilder(base).appendSuper("Integer@8888[]").append("a", "hello").toString()); assertEquals(baseStr + "[<null>,a=hello]", new ToStringBuilder(base).appendSuper("Integer@8888[<null>]").append("a", "hello").toString()); assertEquals(baseStr + "[a=hello]", new ToStringBuilder(base).appendSuper(null).append("a", "hello").toString()); } - + @Test public void testObject() { final Integer i3 = Integer.valueOf(3); @@ -125,5 +125,5 @@ public class ShortPrefixToStringStyleTest { assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append(array).toString()); assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append((Object) array).toString()); } - + } diff --git a/src/test/java/org/apache/commons/lang3/builder/SimpleToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/SimpleToStringStyleTest.java index 1bf18db86..63ea46b6e 100644 --- a/src/test/java/org/apache/commons/lang3/builder/SimpleToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/SimpleToStringStyleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -32,7 +32,7 @@ import org.junit.Test; public class SimpleToStringStyleTest { private final Integer base = Integer.valueOf(5); - + @Before public void setUp() throws Exception { ToStringBuilder.setDefaultStyle(ToStringStyle.SIMPLE_STYLE); @@ -44,7 +44,7 @@ public class SimpleToStringStyleTest { } //---------------------------------------------------------------- - + @Test public void testBlank() { assertEquals("", new ToStringBuilder(base).toString()); @@ -54,12 +54,12 @@ public class SimpleToStringStyleTest { public void testAppendSuper() { assertEquals("", new ToStringBuilder(base).appendSuper("").toString()); assertEquals("<null>", new ToStringBuilder(base).appendSuper("<null>").toString()); - + assertEquals("hello", new ToStringBuilder(base).appendSuper("").append("a", "hello").toString()); assertEquals("<null>,hello", new ToStringBuilder(base).appendSuper("<null>").append("a", "hello").toString()); assertEquals("hello", new ToStringBuilder(base).appendSuper(null).append("a", "hello").toString()); } - + @Test public void testObject() { final Integer i3 = Integer.valueOf(3); diff --git a/src/test/java/org/apache/commons/lang3/builder/StandardToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/StandardToStringStyleTest.java index 17b19d011..fb60bc318 100644 --- a/src/test/java/org/apache/commons/lang3/builder/StandardToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/StandardToStringStyleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -33,9 +33,9 @@ public class StandardToStringStyleTest { private final Integer base = Integer.valueOf(5); private final String baseStr = "Integer"; - + private static final StandardToStringStyle STYLE = new StandardToStringStyle(); - + static { STYLE.setUseShortClassName(true); STYLE.setUseIdentityHashCode(false); @@ -48,7 +48,7 @@ public class StandardToStringStyleTest { STYLE.setSummaryObjectStartText("%"); STYLE.setSummaryObjectEndText("%"); } - + @Before public void setUp() throws Exception { ToStringBuilder.setDefaultStyle(STYLE); @@ -60,7 +60,7 @@ public class StandardToStringStyleTest { } //---------------------------------------------------------------- - + @Test public void testBlank() { assertEquals(baseStr + "[]", new ToStringBuilder(base).toString()); @@ -70,12 +70,12 @@ public class StandardToStringStyleTest { public void testAppendSuper() { assertEquals(baseStr + "[]", new ToStringBuilder(base).appendSuper("Integer@8888[]").toString()); assertEquals(baseStr + "[%NULL%]", new ToStringBuilder(base).appendSuper("Integer@8888[%NULL%]").toString()); - + assertEquals(baseStr + "[a=hello]", new ToStringBuilder(base).appendSuper("Integer@8888[]").append("a", "hello").toString()); assertEquals(baseStr + "[%NULL%,a=hello]", new ToStringBuilder(base).appendSuper("Integer@8888[%NULL%]").append("a", "hello").toString()); assertEquals(baseStr + "[a=hello]", new ToStringBuilder(base).appendSuper(null).append("a", "hello").toString()); } - + @Test public void testObject() { final Integer i3 = Integer.valueOf(3); diff --git a/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java b/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java index 8e32287eb..619b9f255 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ToStringBuilderTest.java @@ -40,7 +40,7 @@ public class ToStringBuilderTest { private final String baseStr = base.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(base)); /* - * All tests should leave the registry empty. + * All tests should leave the registry empty. */ @After public void after(){ @@ -839,7 +839,7 @@ public class ToStringBuilderTest { assertEquals(baseStr + "[<null>]", new ToStringBuilder(base).append(null, (boolean[]) null, false).toString()); assertEquals(baseStr + "[<size=4>]", new ToStringBuilder(base).append(null, array, false).toString()); } - + @Test public void testConstructToStringBuilder(){ ToStringBuilder stringBuilder1 = new ToStringBuilder(base, null, null); @@ -870,7 +870,7 @@ public class ToStringBuilderTest { assertEquals(baseStr + "[a=<size=0>]", new ToStringBuilder(base).append("a", (Object) new String[0], false).toString()); assertEquals(baseStr + "[a={}]", new ToStringBuilder(base).append("a", (Object) new String[0], true).toString()); } - + @Test public void testObjectBuild() { final Integer i3 = Integer.valueOf(3); diff --git a/src/test/java/org/apache/commons/lang3/builder/ToStringStyleConcurrencyTest.java b/src/test/java/org/apache/commons/lang3/builder/ToStringStyleConcurrencyTest.java index 40dd27366..83fa06836 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ToStringStyleConcurrencyTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ToStringStyleConcurrencyTest.java @@ -40,7 +40,7 @@ import org.junit.Test; * <p> * This test passes but only tests one aspect of the issue. * </p> - * + * * @see <a href="https://issues.apache.org/jira/browse/LANG-762">[LANG-762] Handle or document ReflectionToStringBuilder * and ToStringBuilder for collections that are not thread safe</a> * @since 3.1 diff --git a/src/test/java/org/apache/commons/lang3/builder/ToStringStyleTest.java b/src/test/java/org/apache/commons/lang3/builder/ToStringStyleTest.java index 81a8b83c8..a2d9d34d4 100644 --- a/src/test/java/org/apache/commons/lang3/builder/ToStringStyleTest.java +++ b/src/test/java/org/apache/commons/lang3/builder/ToStringStyleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -117,7 +117,7 @@ public class ToStringStyleTest { /** * An object used to test {@link ToStringStyle}. - * + * */ static class Person { /** diff --git a/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java b/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java index caad3b38d..5d64378b1 100644 --- a/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java +++ b/src/test/java/org/apache/commons/lang3/concurrent/CallableBackgroundInitializerTest.java @@ -68,7 +68,7 @@ public class CallableBackgroundInitializerTest { exec.shutdown(); exec.awaitTermination(1, TimeUnit.SECONDS); } - + } /** diff --git a/src/test/java/org/apache/commons/lang3/concurrent/CircuitBreakingExceptionTest.java b/src/test/java/org/apache/commons/lang3/concurrent/CircuitBreakingExceptionTest.java index a7940187b..df814788c 100644 --- a/src/test/java/org/apache/commons/lang3/concurrent/CircuitBreakingExceptionTest.java +++ b/src/test/java/org/apache/commons/lang3/concurrent/CircuitBreakingExceptionTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -28,54 +28,54 @@ import static org.junit.Assert.assertNull; * JUnit tests for {@link CircuitBreakingException}. */ public class CircuitBreakingExceptionTest extends AbstractExceptionTest { - + @Test(expected = CircuitBreakingException.class) public void testThrowingInformativeException() throws Exception { throw new CircuitBreakingException(EXCEPTION_MESSAGE, generateCause()); } - + @Test(expected = CircuitBreakingException.class) public void testThrowingExceptionWithMessage() throws Exception { throw new CircuitBreakingException(EXCEPTION_MESSAGE); } - + @Test(expected = CircuitBreakingException.class) public void testThrowingExceptionWithCause() throws Exception { throw new CircuitBreakingException(generateCause()); } - + @Test(expected = CircuitBreakingException.class) public void testThrowingEmptyException() throws Exception { throw new CircuitBreakingException(); } - + @Test public void testWithCauseAndMessage() throws Exception { final Exception exception = new CircuitBreakingException(EXCEPTION_MESSAGE, generateCause()); assertNotNull(exception); assertEquals(WRONG_EXCEPTION_MESSAGE, EXCEPTION_MESSAGE, exception.getMessage()); - + final Throwable cause = exception.getCause(); assertNotNull(cause); assertEquals(WRONG_CAUSE_MESSAGE, CAUSE_MESSAGE, cause.getMessage()); } - + @Test public void testWithoutCause() throws Exception { final Exception exception = new CircuitBreakingException(EXCEPTION_MESSAGE); assertNotNull(exception); assertEquals(WRONG_EXCEPTION_MESSAGE, EXCEPTION_MESSAGE, exception.getMessage()); - + final Throwable cause = exception.getCause(); assertNull(cause); } - + @Test public void testWithoutMessage() throws Exception { final Exception exception = new CircuitBreakingException(generateCause()); assertNotNull(exception); assertNotNull(exception.getMessage()); - + final Throwable cause = exception.getCause(); assertNotNull(cause); assertEquals(WRONG_CAUSE_MESSAGE, CAUSE_MESSAGE, cause.getMessage()); diff --git a/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java b/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java index f5b74ff80..ffa78d684 100644 --- a/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java +++ b/src/test/java/org/apache/commons/lang3/event/EventListenerSupportTest.java @@ -49,7 +49,7 @@ public class EventListenerSupportTest { assertEquals(0, listeners.length); assertEquals(VetoableChangeListener.class, listeners.getClass().getComponentType()); final VetoableChangeListener[] empty = listeners; - //for fun, show that the same empty instance is used + //for fun, show that the same empty instance is used assertSame(empty, listenerSupport.getListeners()); final VetoableChangeListener listener1 = EasyMock.createNiceMock(VetoableChangeListener.class); @@ -117,7 +117,7 @@ public class EventListenerSupportTest { assertEquals(0, listeners.length); assertEquals(VetoableChangeListener.class, listeners.getClass().getComponentType()); final VetoableChangeListener[] empty = listeners; - //for fun, show that the same empty instance is used + //for fun, show that the same empty instance is used assertSame(empty, listenerSupport.getListeners()); final VetoableChangeListener listener1 = EasyMock.createNiceMock(VetoableChangeListener.class); diff --git a/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java b/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java index 4c8d6153d..db54742cc 100644 --- a/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/event/EventUtilsTest.java @@ -41,7 +41,7 @@ import org.junit.Test; /** * @since 3.0 */ -public class EventUtilsTest +public class EventUtilsTest { @Test @@ -53,7 +53,7 @@ public class EventUtilsTest assertTrue(Modifier.isPublic(EventUtils.class.getModifiers())); assertFalse(Modifier.isFinal(EventUtils.class.getModifiers())); } - + @Test public void testAddEventListener() { diff --git a/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java b/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java index ce9412208..8d5de1048 100644 --- a/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionContextTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -150,7 +150,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext & @Test public void testGetContextLabels() { assertEquals(5, exceptionContext.getContextEntries().size()); - + exceptionContext.addContextValue("test2", "different value"); final Set<String> labels = exceptionContext.getContextLabels(); @@ -165,7 +165,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext & @Test public void testGetContextEntries() { assertEquals(5, exceptionContext.getContextEntries().size()); - + exceptionContext.addContextValue("test2", "different value"); final List<Pair<String, Object>> entries = exceptionContext.getContextEntries(); @@ -177,7 +177,7 @@ public abstract class AbstractExceptionContextTest<T extends ExceptionContext & assertEquals("test Poorly written obj", entries.get(4).getKey()); assertEquals("test2", entries.get(5).getKey()); } - + @Test public void testJavaSerialization() { exceptionContext.setContextValue("test Poorly written obj", "serializable replacement"); diff --git a/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionTest.java b/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionTest.java index ee5e0c5fb..e0e607174 100644 --- a/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/AbstractExceptionTest.java @@ -21,13 +21,13 @@ package org.apache.commons.lang3.exception; * Base class for testing {@link Exception} descendants */ public abstract class AbstractExceptionTest { - + protected static final String CAUSE_MESSAGE = "Cause message"; protected static final String EXCEPTION_MESSAGE = "Exception message"; - + protected static final String WRONG_EXCEPTION_MESSAGE = "Wrong exception message"; protected static final String WRONG_CAUSE_MESSAGE = "Wrong cause message"; - + protected Exception generateCause() { return new Exception(CAUSE_MESSAGE); } diff --git a/src/test/java/org/apache/commons/lang3/exception/CloneFailedExceptionTest.java b/src/test/java/org/apache/commons/lang3/exception/CloneFailedExceptionTest.java index 5406be55a..6030f89e4 100644 --- a/src/test/java/org/apache/commons/lang3/exception/CloneFailedExceptionTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/CloneFailedExceptionTest.java @@ -26,49 +26,49 @@ import static org.junit.Assert.assertNull; * JUnit tests for {@link CloneFailedExceptionTest}. */ public class CloneFailedExceptionTest extends AbstractExceptionTest { - + @Test(expected = CloneFailedException.class) public void testThrowingInformativeException() throws Exception { throw new CloneFailedException(EXCEPTION_MESSAGE, generateCause()); } - + @Test(expected = CloneFailedException.class) public void testThrowingExceptionWithMessage() throws Exception { throw new CloneFailedException(EXCEPTION_MESSAGE); } - + @Test(expected = CloneFailedException.class) public void testThrowingExceptionWithCause() throws Exception { throw new CloneFailedException(generateCause()); } - + @Test public void testWithCauseAndMessage() throws Exception { final Exception exception = new CloneFailedException(EXCEPTION_MESSAGE, generateCause()); assertNotNull(exception); assertEquals(WRONG_EXCEPTION_MESSAGE, EXCEPTION_MESSAGE, exception.getMessage()); - + final Throwable cause = exception.getCause(); assertNotNull(cause); assertEquals(WRONG_CAUSE_MESSAGE, CAUSE_MESSAGE, cause.getMessage()); } - + @Test public void testWithoutCause() throws Exception { final Exception exception = new CloneFailedException(EXCEPTION_MESSAGE); assertNotNull(exception); assertEquals(WRONG_EXCEPTION_MESSAGE, EXCEPTION_MESSAGE, exception.getMessage()); - + final Throwable cause = exception.getCause(); assertNull(cause); } - + @Test public void testWithoutMessage() throws Exception { final Exception exception = new CloneFailedException(generateCause()); assertNotNull(exception); assertNotNull(exception.getMessage()); - + final Throwable cause = exception.getCause(); assertNotNull(cause); assertEquals(WRONG_CAUSE_MESSAGE, CAUSE_MESSAGE, cause.getMessage()); diff --git a/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java b/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java index 75b66ab4d..9df0e7559 100644 --- a/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/ContextedExceptionTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,7 +29,7 @@ import org.junit.Test; * JUnit tests for ContextedException. */ public class ContextedExceptionTest extends AbstractExceptionContextTest<ContextedException> { - + @Override public void setUp() throws Exception { exceptionContext = new ContextedException(new Exception(TEST_MESSAGE)); @@ -49,7 +49,7 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context public void testContextedExceptionString() { exceptionContext = new ContextedException(TEST_MESSAGE); assertEquals(TEST_MESSAGE, exceptionContext.getMessage()); - + final String trace = ExceptionUtils.getStackTrace(exceptionContext); assertTrue(trace.contains(TEST_MESSAGE)); } @@ -74,7 +74,7 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context assertTrue(trace.contains(TEST_MESSAGE_2)); assertTrue(message.contains(TEST_MESSAGE_2)); } - + @Test public void testContextedExceptionStringThrowableContext() { exceptionContext = new ContextedException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE), new DefaultExceptionContext()); @@ -94,7 +94,7 @@ public class ContextedExceptionTest extends AbstractExceptionContextTest<Context .addContextValue("test Date", new Date()) .addContextValue("test Nbr", Integer.valueOf(5)) .addContextValue("test Poorly written obj", new ObjectWithFaultyToString()); - + final String message = exceptionContext.getMessage(); assertTrue(message != null); } diff --git a/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java b/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java index c10b1e866..3a3217576 100644 --- a/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/ContextedRuntimeExceptionTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,7 +30,7 @@ import org.junit.Test; * JUnit tests for ContextedRuntimeException. */ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest<ContextedRuntimeException> { - + @Override @Before public void setUp() throws Exception { @@ -51,7 +51,7 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest< public void testContextedExceptionString() { exceptionContext = new ContextedRuntimeException(TEST_MESSAGE); assertEquals(TEST_MESSAGE, exceptionContext.getMessage()); - + final String trace = ExceptionUtils.getStackTrace(exceptionContext); assertTrue(trace.contains(TEST_MESSAGE)); } @@ -76,11 +76,11 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest< assertTrue(trace.contains(TEST_MESSAGE_2)); assertTrue(message.contains(TEST_MESSAGE_2)); } - + @Test 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), + exceptionContext = new ContextedRuntimeException(TEST_MESSAGE_2, new Exception(TEST_MESSAGE), new DefaultExceptionContext() {private static final long serialVersionUID = 1L;}); final String message = exceptionContext.getMessage(); final String trace = ExceptionUtils.getStackTrace(exceptionContext); @@ -98,7 +98,7 @@ public class ContextedRuntimeExceptionTest extends AbstractExceptionContextTest< .addContextValue("test Date", new Date()) .addContextValue("test Nbr", Integer.valueOf(5)) .addContextValue("test Poorly written obj", new ObjectWithFaultyToString()); - + final String message = exceptionContext.getMessage(); assertTrue(message != null); } diff --git a/src/test/java/org/apache/commons/lang3/exception/DefaultExceptionContextTest.java b/src/test/java/org/apache/commons/lang3/exception/DefaultExceptionContextTest.java index 79bf3328f..5a6c292ae 100644 --- a/src/test/java/org/apache/commons/lang3/exception/DefaultExceptionContextTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/DefaultExceptionContextTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -23,14 +23,14 @@ import org.junit.Test; * JUnit tests for DefaultExceptionContext. */ public class DefaultExceptionContextTest extends AbstractExceptionContextTest<DefaultExceptionContext> { - + @Override @Before public void setUp() throws Exception { exceptionContext = new DefaultExceptionContext(); super.setUp(); } - + @Test public void testFormattedExceptionMessageNull() { exceptionContext = new DefaultExceptionContext(); diff --git a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java index af8b847b3..00ec843fd 100644 --- a/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/exception/ExceptionUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -43,7 +43,7 @@ import org.junit.Test; * @since 1.0 */ public class ExceptionUtilsTest { - + private NestableException nested; private Throwable withCause; private Throwable withoutCause; @@ -98,7 +98,7 @@ public class ExceptionUtilsTest { } //----------------------------------------------------------------------- - + @Test public void testConstructor() { assertNotNull(new ExceptionUtils()); @@ -108,7 +108,7 @@ public class ExceptionUtilsTest { assertTrue(Modifier.isPublic(ExceptionUtils.class.getModifiers())); assertFalse(Modifier.isFinal(ExceptionUtils.class.getModifiers())); } - + //----------------------------------------------------------------------- @SuppressWarnings("deprecation") // Specifically tests the deprecated methods @Test @@ -135,7 +135,7 @@ public class ExceptionUtilsTest { assertSame(null, ExceptionUtils.getCause(withCause, new String[0])); assertSame(null, ExceptionUtils.getCause(withCause, new String[] {null})); assertSame(nested, ExceptionUtils.getCause(withCause, new String[] {"getCause"})); - + // not known type, so match on supplied method names assertSame(null, ExceptionUtils.getCause(withoutCause, null)); assertSame(null, ExceptionUtils.getCause(withoutCause, new String[0])); @@ -263,22 +263,22 @@ public class ExceptionUtilsTest { public void testIndexOf_ThrowableClass() { assertEquals(-1, ExceptionUtils.indexOfThrowable(null, null)); assertEquals(-1, ExceptionUtils.indexOfThrowable(null, NestableException.class)); - + assertEquals(-1, ExceptionUtils.indexOfThrowable(withoutCause, null)); assertEquals(-1, ExceptionUtils.indexOfThrowable(withoutCause, ExceptionWithCause.class)); assertEquals(-1, ExceptionUtils.indexOfThrowable(withoutCause, NestableException.class)); assertEquals(0, ExceptionUtils.indexOfThrowable(withoutCause, ExceptionWithoutCause.class)); - + assertEquals(-1, ExceptionUtils.indexOfThrowable(nested, null)); assertEquals(-1, ExceptionUtils.indexOfThrowable(nested, ExceptionWithCause.class)); assertEquals(0, ExceptionUtils.indexOfThrowable(nested, NestableException.class)); assertEquals(1, ExceptionUtils.indexOfThrowable(nested, ExceptionWithoutCause.class)); - + assertEquals(-1, ExceptionUtils.indexOfThrowable(withCause, null)); assertEquals(0, ExceptionUtils.indexOfThrowable(withCause, ExceptionWithCause.class)); assertEquals(1, ExceptionUtils.indexOfThrowable(withCause, NestableException.class)); assertEquals(2, ExceptionUtils.indexOfThrowable(withCause, ExceptionWithoutCause.class)); - + assertEquals(-1, ExceptionUtils.indexOfThrowable(withCause, Exception.class)); } @@ -286,17 +286,17 @@ public class ExceptionUtilsTest { public void testIndexOf_ThrowableClassInt() { assertEquals(-1, ExceptionUtils.indexOfThrowable(null, null, 0)); assertEquals(-1, ExceptionUtils.indexOfThrowable(null, NestableException.class, 0)); - + assertEquals(-1, ExceptionUtils.indexOfThrowable(withoutCause, null)); assertEquals(-1, ExceptionUtils.indexOfThrowable(withoutCause, ExceptionWithCause.class, 0)); assertEquals(-1, ExceptionUtils.indexOfThrowable(withoutCause, NestableException.class, 0)); assertEquals(0, ExceptionUtils.indexOfThrowable(withoutCause, ExceptionWithoutCause.class, 0)); - + assertEquals(-1, ExceptionUtils.indexOfThrowable(nested, null, 0)); assertEquals(-1, ExceptionUtils.indexOfThrowable(nested, ExceptionWithCause.class, 0)); assertEquals(0, ExceptionUtils.indexOfThrowable(nested, NestableException.class, 0)); assertEquals(1, ExceptionUtils.indexOfThrowable(nested, ExceptionWithoutCause.class, 0)); - + assertEquals(-1, ExceptionUtils.indexOfThrowable(withCause, null)); assertEquals(0, ExceptionUtils.indexOfThrowable(withCause, ExceptionWithCause.class, 0)); assertEquals(1, ExceptionUtils.indexOfThrowable(withCause, NestableException.class, 0)); @@ -306,7 +306,7 @@ public class ExceptionUtilsTest { assertEquals(0, ExceptionUtils.indexOfThrowable(withCause, ExceptionWithCause.class, 0)); assertEquals(-1, ExceptionUtils.indexOfThrowable(withCause, ExceptionWithCause.class, 1)); assertEquals(-1, ExceptionUtils.indexOfThrowable(withCause, ExceptionWithCause.class, 9)); - + assertEquals(-1, ExceptionUtils.indexOfThrowable(withCause, Exception.class, 0)); } @@ -315,22 +315,22 @@ public class ExceptionUtilsTest { public void testIndexOfType_ThrowableClass() { assertEquals(-1, ExceptionUtils.indexOfType(null, null)); assertEquals(-1, ExceptionUtils.indexOfType(null, NestableException.class)); - + assertEquals(-1, ExceptionUtils.indexOfType(withoutCause, null)); assertEquals(-1, ExceptionUtils.indexOfType(withoutCause, ExceptionWithCause.class)); assertEquals(-1, ExceptionUtils.indexOfType(withoutCause, NestableException.class)); assertEquals(0, ExceptionUtils.indexOfType(withoutCause, ExceptionWithoutCause.class)); - + assertEquals(-1, ExceptionUtils.indexOfType(nested, null)); assertEquals(-1, ExceptionUtils.indexOfType(nested, ExceptionWithCause.class)); assertEquals(0, ExceptionUtils.indexOfType(nested, NestableException.class)); assertEquals(1, ExceptionUtils.indexOfType(nested, ExceptionWithoutCause.class)); - + assertEquals(-1, ExceptionUtils.indexOfType(withCause, null)); assertEquals(0, ExceptionUtils.indexOfType(withCause, ExceptionWithCause.class)); assertEquals(1, ExceptionUtils.indexOfType(withCause, NestableException.class)); assertEquals(2, ExceptionUtils.indexOfType(withCause, ExceptionWithoutCause.class)); - + assertEquals(0, ExceptionUtils.indexOfType(withCause, Exception.class)); } @@ -338,17 +338,17 @@ public class ExceptionUtilsTest { public void testIndexOfType_ThrowableClassInt() { assertEquals(-1, ExceptionUtils.indexOfType(null, null, 0)); assertEquals(-1, ExceptionUtils.indexOfType(null, NestableException.class, 0)); - + assertEquals(-1, ExceptionUtils.indexOfType(withoutCause, null)); assertEquals(-1, ExceptionUtils.indexOfType(withoutCause, ExceptionWithCause.class, 0)); assertEquals(-1, ExceptionUtils.indexOfType(withoutCause, NestableException.class, 0)); assertEquals(0, ExceptionUtils.indexOfType(withoutCause, ExceptionWithoutCause.class, 0)); - + assertEquals(-1, ExceptionUtils.indexOfType(nested, null, 0)); assertEquals(-1, ExceptionUtils.indexOfType(nested, ExceptionWithCause.class, 0)); assertEquals(0, ExceptionUtils.indexOfType(nested, NestableException.class, 0)); assertEquals(1, ExceptionUtils.indexOfType(nested, ExceptionWithoutCause.class, 0)); - + assertEquals(-1, ExceptionUtils.indexOfType(withCause, null)); assertEquals(0, ExceptionUtils.indexOfType(withCause, ExceptionWithCause.class, 0)); assertEquals(1, ExceptionUtils.indexOfType(withCause, NestableException.class, 0)); @@ -358,7 +358,7 @@ public class ExceptionUtilsTest { assertEquals(0, ExceptionUtils.indexOfType(withCause, ExceptionWithCause.class, 0)); assertEquals(-1, ExceptionUtils.indexOfType(withCause, ExceptionWithCause.class, 1)); assertEquals(-1, ExceptionUtils.indexOfType(withCause, ExceptionWithCause.class, 9)); - + assertEquals(0, ExceptionUtils.indexOfType(withCause, Exception.class, 0)); } @@ -369,27 +369,27 @@ public class ExceptionUtilsTest { // could pipe system.err to a known stream, but not much point as // internally this method calls stream method anyway } - + @Test public void testPrintRootCauseStackTrace_ThrowableStream() throws Exception { ByteArrayOutputStream out = new ByteArrayOutputStream(1024); ExceptionUtils.printRootCauseStackTrace(null, (PrintStream) null); ExceptionUtils.printRootCauseStackTrace(null, new PrintStream(out)); assertEquals(0, out.toString().length()); - + out = new ByteArrayOutputStream(1024); try { ExceptionUtils.printRootCauseStackTrace(withCause, (PrintStream) null); fail(); } catch (final IllegalArgumentException ex) { } - + out = new ByteArrayOutputStream(1024); final Throwable cause = createExceptionWithCause(); ExceptionUtils.printRootCauseStackTrace(cause, new PrintStream(out)); String stackTrace = out.toString(); assertTrue(stackTrace.contains(ExceptionUtils.WRAPPED_MARKER)); - + out = new ByteArrayOutputStream(1024); ExceptionUtils.printRootCauseStackTrace(withoutCause, new PrintStream(out)); stackTrace = out.toString(); @@ -402,20 +402,20 @@ public class ExceptionUtilsTest { ExceptionUtils.printRootCauseStackTrace(null, (PrintWriter) null); ExceptionUtils.printRootCauseStackTrace(null, new PrintWriter(writer)); assertEquals(0, writer.getBuffer().length()); - + writer = new StringWriter(1024); try { ExceptionUtils.printRootCauseStackTrace(withCause, (PrintWriter) null); fail(); } catch (final IllegalArgumentException ex) { } - + writer = new StringWriter(1024); final Throwable cause = createExceptionWithCause(); ExceptionUtils.printRootCauseStackTrace(cause, new PrintWriter(writer)); String stackTrace = writer.toString(); assertTrue(stackTrace.contains(ExceptionUtils.WRAPPED_MARKER)); - + writer = new StringWriter(1024); ExceptionUtils.printRootCauseStackTrace(withoutCause, new PrintWriter(writer)); stackTrace = writer.toString(); @@ -426,7 +426,7 @@ public class ExceptionUtilsTest { @Test public void testGetRootCauseStackTrace_Throwable() throws Exception { assertEquals(0, ExceptionUtils.getRootCauseStackTrace(null).length); - + final Throwable cause = createExceptionWithCause(); String[] stackTrace = ExceptionUtils.getRootCauseStackTrace(cause); boolean match = false; @@ -437,7 +437,7 @@ public class ExceptionUtilsTest { } } assertTrue(match); - + stackTrace = ExceptionUtils.getRootCauseStackTrace(withoutCause); match = false; for (final String element : stackTrace) { @@ -458,10 +458,10 @@ public class ExceptionUtilsTest { public void test_getMessage_Throwable() { Throwable th = null; assertEquals("", ExceptionUtils.getMessage(th)); - + th = new IllegalArgumentException("Base"); assertEquals("IllegalArgumentException: Base", ExceptionUtils.getMessage(th)); - + th = new ExceptionWithCause("Wrapper", th); assertEquals("ExceptionUtilsTest.ExceptionWithCause: Wrapper", ExceptionUtils.getMessage(th)); } @@ -470,10 +470,10 @@ public class ExceptionUtilsTest { public void test_getRootCauseMessage_Throwable() { Throwable th = null; assertEquals("", ExceptionUtils.getRootCauseMessage(th)); - + th = new IllegalArgumentException("Base"); assertEquals("IllegalArgumentException: Base", ExceptionUtils.getRootCauseMessage(th)); - + th = new ExceptionWithCause("Wrapper", th); assertEquals("IllegalArgumentException: Base", ExceptionUtils.getRootCauseMessage(th)); } @@ -522,9 +522,9 @@ public class ExceptionUtilsTest { } } - // Temporary classes to allow the nested exception code to be removed - // prior to a rewrite of this test class. - private static class NestableException extends Exception { + // Temporary classes to allow the nested exception code to be removed + // prior to a rewrite of this test class. + private static class NestableException extends Exception { private static final long serialVersionUID = 1L; @SuppressWarnings("unused") @@ -554,7 +554,7 @@ public class ExceptionUtilsTest { assertTrue(ioe instanceof IOException); assertEquals(1, ExceptionUtils.getThrowableCount(ioe)); } - + try { redeclareCheckedException(); Assert.fail("Exception not thrown"); diff --git a/src/test/java/org/apache/commons/lang3/math/FractionTest.java b/src/test/java/org/apache/commons/lang3/math/FractionTest.java index d55b8d81b..3c3676126 100644 --- a/src/test/java/org/apache/commons/lang3/math/FractionTest.java +++ b/src/test/java/org/apache/commons/lang3/math/FractionTest.java @@ -30,7 +30,7 @@ import org.junit.Test; * Test cases for the {@link Fraction} class */ public class FractionTest { - + private static final int SKIP = 500; //53 //-------------------------------------------------------------------------- @@ -38,37 +38,37 @@ public class FractionTest { public void testConstants() { assertEquals(0, Fraction.ZERO.getNumerator()); assertEquals(1, Fraction.ZERO.getDenominator()); - + assertEquals(1, Fraction.ONE.getNumerator()); assertEquals(1, Fraction.ONE.getDenominator()); - + assertEquals(1, Fraction.ONE_HALF.getNumerator()); assertEquals(2, Fraction.ONE_HALF.getDenominator()); - + assertEquals(1, Fraction.ONE_THIRD.getNumerator()); assertEquals(3, Fraction.ONE_THIRD.getDenominator()); - + assertEquals(2, Fraction.TWO_THIRDS.getNumerator()); assertEquals(3, Fraction.TWO_THIRDS.getDenominator()); - + assertEquals(1, Fraction.ONE_QUARTER.getNumerator()); assertEquals(4, Fraction.ONE_QUARTER.getDenominator()); - + assertEquals(2, Fraction.TWO_QUARTERS.getNumerator()); assertEquals(4, Fraction.TWO_QUARTERS.getDenominator()); - + assertEquals(3, Fraction.THREE_QUARTERS.getNumerator()); assertEquals(4, Fraction.THREE_QUARTERS.getDenominator()); - + assertEquals(1, Fraction.ONE_FIFTH.getNumerator()); assertEquals(5, Fraction.ONE_FIFTH.getDenominator()); - + assertEquals(2, Fraction.TWO_FIFTHS.getNumerator()); assertEquals(5, Fraction.TWO_FIFTHS.getDenominator()); - + assertEquals(3, Fraction.THREE_FIFTHS.getNumerator()); assertEquals(5, Fraction.THREE_FIFTHS.getDenominator()); - + assertEquals(4, Fraction.FOUR_FIFTHS.getNumerator()); assertEquals(5, Fraction.FOUR_FIFTHS.getDenominator()); } @@ -76,58 +76,58 @@ public class FractionTest { @Test public void testFactory_int_int() { Fraction f = null; - + // zero f = Fraction.getFraction(0, 1); assertEquals(0, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f = Fraction.getFraction(0, 2); assertEquals(0, f.getNumerator()); assertEquals(2, f.getDenominator()); - + // normal f = Fraction.getFraction(1, 1); assertEquals(1, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f = Fraction.getFraction(2, 1); assertEquals(2, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f = Fraction.getFraction(23, 345); assertEquals(23, f.getNumerator()); assertEquals(345, f.getDenominator()); - + // improper f = Fraction.getFraction(22, 7); assertEquals(22, f.getNumerator()); assertEquals(7, f.getDenominator()); - + // negatives f = Fraction.getFraction(-6, 10); assertEquals(-6, f.getNumerator()); assertEquals(10, f.getDenominator()); - + f = Fraction.getFraction(6, -10); assertEquals(-6, f.getNumerator()); assertEquals(10, f.getDenominator()); - + f = Fraction.getFraction(-6, -10); assertEquals(6, f.getNumerator()); assertEquals(10, f.getDenominator()); - + // zero denominator try { f = Fraction.getFraction(1, 0); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f = Fraction.getFraction(2, 0); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f = Fraction.getFraction(-3, 0); fail("expecting ArithmeticException"); @@ -147,25 +147,25 @@ public class FractionTest { @Test public void testFactory_int_int_int() { Fraction f = null; - + // zero f = Fraction.getFraction(0, 0, 2); assertEquals(0, f.getNumerator()); assertEquals(2, f.getDenominator()); - + f = Fraction.getFraction(2, 0, 2); assertEquals(4, f.getNumerator()); assertEquals(2, f.getDenominator()); - + f = Fraction.getFraction(0, 1, 2); assertEquals(1, f.getNumerator()); assertEquals(2, f.getDenominator()); - + // normal f = Fraction.getFraction(1, 1, 2); assertEquals(3, f.getNumerator()); assertEquals(2, f.getDenominator()); - + // negatives try { f = Fraction.getFraction(1, -6, -10); @@ -181,12 +181,12 @@ public class FractionTest { f = Fraction.getFraction(1, -6, -10); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + // negative whole f = Fraction.getFraction(-1, 6, 10); assertEquals(-16, f.getNumerator()); assertEquals(10, f.getDenominator()); - + try { f = Fraction.getFraction(-1, -6, 10); fail("expecting ArithmeticException"); @@ -196,33 +196,33 @@ public class FractionTest { f = Fraction.getFraction(-1, 6, -10); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f = Fraction.getFraction(-1, -6, -10); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + // zero denominator try { f = Fraction.getFraction(0, 1, 0); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f = Fraction.getFraction(1, 2, 0); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f = Fraction.getFraction(-1, -3, 0); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { - f = Fraction.getFraction(Integer.MAX_VALUE, 1, 2); + f = Fraction.getFraction(Integer.MAX_VALUE, 1, 2); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f = Fraction.getFraction(-Integer.MAX_VALUE, 1, 2); fail("expecting ArithmeticException"); @@ -250,87 +250,87 @@ public class FractionTest { @Test public void testReducedFactory_int_int() { Fraction f = null; - + // zero f = Fraction.getReducedFraction(0, 1); assertEquals(0, f.getNumerator()); assertEquals(1, f.getDenominator()); - + // normal f = Fraction.getReducedFraction(1, 1); assertEquals(1, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f = Fraction.getReducedFraction(2, 1); assertEquals(2, f.getNumerator()); assertEquals(1, f.getDenominator()); - + // improper f = Fraction.getReducedFraction(22, 7); assertEquals(22, f.getNumerator()); assertEquals(7, f.getDenominator()); - + // negatives f = Fraction.getReducedFraction(-6, 10); assertEquals(-3, f.getNumerator()); assertEquals(5, f.getDenominator()); - + f = Fraction.getReducedFraction(6, -10); assertEquals(-3, f.getNumerator()); assertEquals(5, f.getDenominator()); - + f = Fraction.getReducedFraction(-6, -10); assertEquals(3, f.getNumerator()); assertEquals(5, f.getDenominator()); - + // zero denominator try { f = Fraction.getReducedFraction(1, 0); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f = Fraction.getReducedFraction(2, 0); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f = Fraction.getReducedFraction(-3, 0); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - // reduced + // reduced f = Fraction.getReducedFraction(0, 2); assertEquals(0, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f = Fraction.getReducedFraction(2, 2); assertEquals(1, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f = Fraction.getReducedFraction(2, 4); assertEquals(1, f.getNumerator()); assertEquals(2, f.getDenominator()); - + f = Fraction.getReducedFraction(15, 10); assertEquals(3, f.getNumerator()); assertEquals(2, f.getDenominator()); - + f = Fraction.getReducedFraction(121, 22); assertEquals(11, f.getNumerator()); assertEquals(2, f.getDenominator()); - - // Extreme values + + // Extreme values // OK, can reduce before negating f = Fraction.getReducedFraction(-2, Integer.MIN_VALUE); assertEquals(1, f.getNumerator()); assertEquals(-(Integer.MIN_VALUE / 2), f.getDenominator()); - + // Can't reduce, negation will throw - try { - f = Fraction.getReducedFraction(-7, Integer.MIN_VALUE); + try { + f = Fraction.getReducedFraction(-7, Integer.MIN_VALUE); fail("Expecting ArithmeticException"); - } catch (final ArithmeticException ex) {} + } catch (final ArithmeticException ex) {} // LANG-662 f = Fraction.getReducedFraction(Integer.MIN_VALUE, 2); @@ -341,62 +341,62 @@ public class FractionTest { @Test public void testFactory_double() { Fraction f = null; - + try { f = Fraction.getFraction(Double.NaN); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f = Fraction.getFraction(Double.POSITIVE_INFINITY); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f = Fraction.getFraction(Double.NEGATIVE_INFINITY); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f = Fraction.getFraction((double) Integer.MAX_VALUE + 1); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + // zero f = Fraction.getFraction(0.0d); assertEquals(0, f.getNumerator()); assertEquals(1, f.getDenominator()); - + // one f = Fraction.getFraction(1.0d); assertEquals(1, f.getNumerator()); assertEquals(1, f.getDenominator()); - + // one half f = Fraction.getFraction(0.5d); assertEquals(1, f.getNumerator()); assertEquals(2, f.getDenominator()); - + // negative f = Fraction.getFraction(-0.875d); assertEquals(-7, f.getNumerator()); assertEquals(8, f.getDenominator()); - + // over 1 f = Fraction.getFraction(1.25d); assertEquals(5, f.getNumerator()); assertEquals(4, f.getDenominator()); - + // two thirds f = Fraction.getFraction(0.66666d); assertEquals(2, f.getNumerator()); assertEquals(3, f.getDenominator()); - + // small f = Fraction.getFraction(1.0d/10001d); assertEquals(0, f.getNumerator()); assertEquals(1, f.getDenominator()); - + // normal Fraction f2 = null; for (int i = 1; i <= 100; i++) { // denominator @@ -432,38 +432,38 @@ public class FractionTest { public void testFactory_String() { Fraction.getFraction(null); } - - + + @Test public void testFactory_String_double() { Fraction f = null; - + f = Fraction.getFraction("0.0"); assertEquals(0, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f = Fraction.getFraction("0.2"); assertEquals(1, f.getNumerator()); assertEquals(5, f.getDenominator()); - + f = Fraction.getFraction("0.5"); assertEquals(1, f.getNumerator()); assertEquals(2, f.getDenominator()); - + f = Fraction.getFraction("0.66666"); assertEquals(2, f.getNumerator()); assertEquals(3, f.getDenominator()); - + try { f = Fraction.getFraction("2.3R"); fail("Expecting NumberFormatException"); } catch (final NumberFormatException ex) {} - + try { f = Fraction.getFraction("2147483648"); // too big fail("Expecting NumberFormatException"); } catch (final NumberFormatException ex) {} - + try { f = Fraction.getFraction("."); fail("Expecting NumberFormatException"); @@ -473,46 +473,46 @@ public class FractionTest { @Test public void testFactory_String_proper() { Fraction f = null; - + f = Fraction.getFraction("0 0/1"); assertEquals(0, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f = Fraction.getFraction("1 1/5"); assertEquals(6, f.getNumerator()); assertEquals(5, f.getDenominator()); - + f = Fraction.getFraction("7 1/2"); assertEquals(15, f.getNumerator()); assertEquals(2, f.getDenominator()); - + f = Fraction.getFraction("1 2/4"); assertEquals(6, f.getNumerator()); assertEquals(4, f.getDenominator()); - + f = Fraction.getFraction("-7 1/2"); assertEquals(-15, f.getNumerator()); assertEquals(2, f.getDenominator()); - + f = Fraction.getFraction("-1 2/4"); assertEquals(-6, f.getNumerator()); assertEquals(4, f.getDenominator()); - + try { f = Fraction.getFraction("2 3"); fail("expecting NumberFormatException"); } catch (final NumberFormatException ex) {} - + try { f = Fraction.getFraction("a 3"); fail("expecting NumberFormatException"); } catch (final NumberFormatException ex) {} - + try { f = Fraction.getFraction("2 b/4"); fail("expecting NumberFormatException"); } catch (final NumberFormatException ex) {} - + try { f = Fraction.getFraction("2 "); fail("expecting NumberFormatException"); @@ -522,7 +522,7 @@ public class FractionTest { f = Fraction.getFraction(" 3"); fail("expecting NumberFormatException"); } catch (final NumberFormatException ex) {} - + try { f = Fraction.getFraction(" "); fail("expecting NumberFormatException"); @@ -532,46 +532,46 @@ public class FractionTest { @Test public void testFactory_String_improper() { Fraction f = null; - + f = Fraction.getFraction("0/1"); assertEquals(0, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f = Fraction.getFraction("1/5"); assertEquals(1, f.getNumerator()); assertEquals(5, f.getDenominator()); - + f = Fraction.getFraction("1/2"); assertEquals(1, f.getNumerator()); assertEquals(2, f.getDenominator()); - + f = Fraction.getFraction("2/3"); assertEquals(2, f.getNumerator()); assertEquals(3, f.getDenominator()); - + f = Fraction.getFraction("7/3"); assertEquals(7, f.getNumerator()); assertEquals(3, f.getDenominator()); - + f = Fraction.getFraction("2/4"); assertEquals(2, f.getNumerator()); assertEquals(4, f.getDenominator()); - + try { f = Fraction.getFraction("2/d"); fail("expecting NumberFormatException"); } catch (final NumberFormatException ex) {} - + try { f = Fraction.getFraction("2e/3"); fail("expecting NumberFormatException"); } catch (final NumberFormatException ex) {} - + try { f = Fraction.getFraction("2/"); fail("expecting NumberFormatException"); } catch (final NumberFormatException ex) {} - + try { f = Fraction.getFraction("/"); fail("expecting NumberFormatException"); @@ -581,13 +581,13 @@ public class FractionTest { @Test public void testGets() { Fraction f = null; - + f = Fraction.getFraction(3, 5, 6); assertEquals(23, f.getNumerator()); assertEquals(3, f.getProperWhole()); assertEquals(5, f.getProperNumerator()); assertEquals(6, f.getDenominator()); - + f = Fraction.getFraction(-3, 5, 6); assertEquals(-23, f.getNumerator()); assertEquals(-3, f.getProperWhole()); @@ -600,22 +600,22 @@ public class FractionTest { assertEquals(0, f.getProperNumerator()); assertEquals(1, f.getDenominator()); } - + @Test public void testConversions() { Fraction f = null; - + f = Fraction.getFraction(3, 7, 8); assertEquals(3, f.intValue()); assertEquals(3L, f.longValue()); assertEquals(3.875f, f.floatValue(), 0.00001f); assertEquals(3.875d, f.doubleValue(), 0.00001d); } - + @Test public void testReduce() { Fraction f = null; - + f = Fraction.getFraction(50, 75); Fraction result = f.reduce(); assertEquals(2, result.getNumerator()); @@ -660,26 +660,26 @@ public class FractionTest { assertEquals(Integer.MIN_VALUE / 2, result.getNumerator()); assertEquals(1, result.getDenominator()); } - + @Test public void testInvert() { Fraction f = null; - + f = Fraction.getFraction(50, 75); f = f.invert(); assertEquals(75, f.getNumerator()); assertEquals(50, f.getDenominator()); - + f = Fraction.getFraction(4, 3); f = f.invert(); assertEquals(3, f.getNumerator()); assertEquals(4, f.getDenominator()); - + f = Fraction.getFraction(-15, 47); f = f.invert(); assertEquals(-47, f.getNumerator()); assertEquals(15, f.getDenominator()); - + f = Fraction.getFraction(0, 3); try { f = f.invert(); @@ -698,16 +698,16 @@ public class FractionTest { assertEquals(1, f.getNumerator()); assertEquals(Integer.MAX_VALUE, f.getDenominator()); } - + @Test public void testNegate() { Fraction f = null; - + f = Fraction.getFraction(50, 75); f = f.negate(); assertEquals(-50, f.getNumerator()); assertEquals(75, f.getDenominator()); - + f = Fraction.getFraction(-50, 75); f = f.negate(); assertEquals(50, f.getNumerator()); @@ -725,16 +725,16 @@ public class FractionTest { fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} } - + @Test public void testAbs() { Fraction f = null; - + f = Fraction.getFraction(50, 75); f = f.abs(); assertEquals(50, f.getNumerator()); assertEquals(75, f.getDenominator()); - + f = Fraction.getFraction(-50, 75); f = f.abs(); assertEquals(50, f.getNumerator()); @@ -756,14 +756,14 @@ public class FractionTest { fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} } - + @Test public void testPow() { Fraction f = null; - + f = Fraction.getFraction(3, 5); assertEquals(Fraction.ONE, f.pow(0)); - + f = Fraction.getFraction(3, 5); assertSame(f, f.pow(1)); assertEquals(f, f.pow(1)); @@ -772,26 +772,26 @@ public class FractionTest { f = f.pow(2); assertEquals(9, f.getNumerator()); assertEquals(25, f.getDenominator()); - + f = Fraction.getFraction(3, 5); f = f.pow(3); assertEquals(27, f.getNumerator()); assertEquals(125, f.getDenominator()); - + f = Fraction.getFraction(3, 5); f = f.pow(-1); assertEquals(5, f.getNumerator()); assertEquals(3, f.getDenominator()); - + f = Fraction.getFraction(3, 5); f = f.pow(-2); assertEquals(25, f.getNumerator()); assertEquals(9, f.getDenominator()); - + // check unreduced fractions stay that way. f = Fraction.getFraction(6, 10); assertEquals(Fraction.ONE, f.pow(0)); - + f = Fraction.getFraction(6, 10); assertEquals(f, f.pow(1)); assertFalse(f.pow(1).equals(Fraction.getFraction(3,5))); @@ -800,22 +800,22 @@ public class FractionTest { f = f.pow(2); assertEquals(9, f.getNumerator()); assertEquals(25, f.getDenominator()); - + f = Fraction.getFraction(6, 10); f = f.pow(3); assertEquals(27, f.getNumerator()); assertEquals(125, f.getDenominator()); - + f = Fraction.getFraction(6, 10); f = f.pow(-1); assertEquals(10, f.getNumerator()); assertEquals(6, f.getDenominator()); - + f = Fraction.getFraction(6, 10); f = f.pow(-2); assertEquals(25, f.getNumerator()); assertEquals(9, f.getDenominator()); - + // zero to any positive power is still zero. f = Fraction.getFraction(0, 1231); f = f.pow(1); @@ -869,73 +869,73 @@ public class FractionTest { fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} } - + @Test public void testAdd() { Fraction f = null; Fraction f1 = null; Fraction f2 = null; - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(1, 5); f = f1.add(f2); assertEquals(4, f.getNumerator()); assertEquals(5, f.getDenominator()); - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(2, 5); f = f1.add(f2); assertEquals(1, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(3, 5); f = f1.add(f2); assertEquals(6, f.getNumerator()); assertEquals(5, f.getDenominator()); - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(-4, 5); f = f1.add(f2); assertEquals(-1, f.getNumerator()); assertEquals(5, f.getDenominator()); - + f1 = Fraction.getFraction(Integer.MAX_VALUE - 1, 1); f2 = Fraction.ONE; f = f1.add(f2); assertEquals(Integer.MAX_VALUE, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(1, 2); f = f1.add(f2); assertEquals(11, f.getNumerator()); assertEquals(10, f.getDenominator()); - + f1 = Fraction.getFraction(3, 8); f2 = Fraction.getFraction(1, 6); f = f1.add(f2); assertEquals(13, f.getNumerator()); assertEquals(24, f.getDenominator()); - + f1 = Fraction.getFraction(0, 5); f2 = Fraction.getFraction(1, 5); f = f1.add(f2); assertSame(f2, f); f = f2.add(f1); assertSame(f2, f); - + f1 = Fraction.getFraction(-1, 13*13*2*2); f2 = Fraction.getFraction(-2, 13*17*2); f = f1.add(f2); assertEquals(13*13*17*2*2, f.getDenominator()); assertEquals(-17 - 2*13*2, f.getNumerator()); - + try { f.add(null); fail("expecting IllegalArgumentException"); } catch (final IllegalArgumentException ex) {} - + // if this fraction is added naively, it will overflow. // check that it doesn't. f1 = Fraction.getFraction(1,32768*3); @@ -949,18 +949,18 @@ public class FractionTest { f = f1.add(f2); assertEquals(Integer.MIN_VALUE+1, f.getNumerator()); assertEquals(3, f.getDenominator()); - + f1 = Fraction.getFraction(Integer.MAX_VALUE - 1, 1); f2 = Fraction.ONE; f = f1.add(f2); assertEquals(Integer.MAX_VALUE, f.getNumerator()); assertEquals(1, f.getDenominator()); - + try { f = f.add(Fraction.ONE); // should overflow fail("expecting ArithmeticException but got: " + f.toString()); } catch (final ArithmeticException ex) {} - + // denominator should not be a multiple of 2 or 3 to trigger overflow f1 = Fraction.getFraction(Integer.MIN_VALUE, 5); f2 = Fraction.getFraction(-1,5); @@ -968,19 +968,19 @@ public class FractionTest { f = f1.add(f2); // should overflow fail("expecting ArithmeticException but got: " + f.toString()); } catch (final ArithmeticException ex) {} - + try { f= Fraction.getFraction(-Integer.MAX_VALUE, 1); f = f.add(f); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f= Fraction.getFraction(-Integer.MAX_VALUE, 1); f = f.add(f); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + f1 = Fraction.getFraction(3,327680); f2 = Fraction.getFraction(2,59049); try { @@ -988,65 +988,65 @@ public class FractionTest { fail("expecting ArithmeticException but got: " + f.toString()); } catch (final ArithmeticException ex) {} } - + @Test public void testSubtract() { Fraction f = null; Fraction f1 = null; Fraction f2 = null; - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(1, 5); f = f1.subtract(f2); assertEquals(2, f.getNumerator()); assertEquals(5, f.getDenominator()); - + f1 = Fraction.getFraction(7, 5); f2 = Fraction.getFraction(2, 5); f = f1.subtract(f2); assertEquals(1, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(3, 5); f = f1.subtract(f2); assertEquals(0, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(-4, 5); f = f1.subtract(f2); assertEquals(7, f.getNumerator()); assertEquals(5, f.getDenominator()); - + f1 = Fraction.getFraction(0, 5); f2 = Fraction.getFraction(4, 5); f = f1.subtract(f2); assertEquals(-4, f.getNumerator()); assertEquals(5, f.getDenominator()); - + f1 = Fraction.getFraction(0, 5); f2 = Fraction.getFraction(-4, 5); f = f1.subtract(f2); assertEquals(4, f.getNumerator()); assertEquals(5, f.getDenominator()); - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(1, 2); f = f1.subtract(f2); assertEquals(1, f.getNumerator()); assertEquals(10, f.getDenominator()); - + f1 = Fraction.getFraction(0, 5); f2 = Fraction.getFraction(1, 5); f = f2.subtract(f1); assertSame(f2, f); - + try { f.subtract(null); fail("expecting IllegalArgumentException"); } catch (final IllegalArgumentException ex) {} - + // if this fraction is subtracted naively, it will overflow. // check that it doesn't. f1 = Fraction.getFraction(1,32768*3); @@ -1060,7 +1060,7 @@ public class FractionTest { f = f1.subtract(f2); assertEquals(Integer.MIN_VALUE+1, f.getNumerator()); assertEquals(3, f.getDenominator()); - + f1 = Fraction.getFraction(Integer.MAX_VALUE, 1); f2 = Fraction.ONE; f = f1.subtract(f2); @@ -1073,7 +1073,7 @@ public class FractionTest { f = f1.subtract(f2); fail("expecting ArithmeticException"); //should overflow } catch (final ArithmeticException ex) {} - + // denominator should not be a multiple of 2 or 3 to trigger overflow f1 = Fraction.getFraction(Integer.MIN_VALUE, 5); f2 = Fraction.getFraction(1,5); @@ -1081,19 +1081,19 @@ public class FractionTest { f = f1.subtract(f2); // should overflow fail("expecting ArithmeticException but got: " + f.toString()); } catch (final ArithmeticException ex) {} - + try { f= Fraction.getFraction(Integer.MIN_VALUE, 1); f = f.subtract(Fraction.ONE); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f= Fraction.getFraction(Integer.MAX_VALUE, 1); f = f.subtract(Fraction.ONE.negate()); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + f1 = Fraction.getFraction(3,327680); f2 = Fraction.getFraction(2,59049); try { @@ -1101,19 +1101,19 @@ public class FractionTest { fail("expecting ArithmeticException but got: " + f.toString()); } catch (final ArithmeticException ex) {} } - + @Test public void testMultiply() { Fraction f = null; Fraction f1 = null; Fraction f2 = null; - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(2, 5); f = f1.multiplyBy(f2); assertEquals(6, f.getNumerator()); assertEquals(25, f.getDenominator()); - + f1 = Fraction.getFraction(6, 10); f2 = Fraction.getFraction(6, 10); f = f1.multiplyBy(f2); @@ -1122,31 +1122,31 @@ public class FractionTest { f = f.multiplyBy(f2); assertEquals(27, f.getNumerator()); assertEquals(125, f.getDenominator()); - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(-2, 5); f = f1.multiplyBy(f2); assertEquals(-6, f.getNumerator()); assertEquals(25, f.getDenominator()); - + f1 = Fraction.getFraction(-3, 5); f2 = Fraction.getFraction(-2, 5); f = f1.multiplyBy(f2); assertEquals(6, f.getNumerator()); assertEquals(25, f.getDenominator()); - - + + f1 = Fraction.getFraction(0, 5); f2 = Fraction.getFraction(2, 7); f = f1.multiplyBy(f2); assertSame(Fraction.ZERO, f); - + f1 = Fraction.getFraction(2, 7); f2 = Fraction.ONE; f = f1.multiplyBy(f2); assertEquals(2, f.getNumerator()); assertEquals(7, f.getDenominator()); - + f1 = Fraction.getFraction(Integer.MAX_VALUE, 1); f2 = Fraction.getFraction(Integer.MIN_VALUE, Integer.MAX_VALUE); f = f1.multiplyBy(f2); @@ -1157,55 +1157,55 @@ public class FractionTest { f.multiplyBy(null); fail("expecting IllegalArgumentException"); } catch (final IllegalArgumentException ex) {} - + try { f1 = Fraction.getFraction(1, Integer.MAX_VALUE); f = f1.multiplyBy(f1); // should overflow fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + try { f1 = Fraction.getFraction(1, -Integer.MAX_VALUE); f = f1.multiplyBy(f1); // should overflow fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} } - + @Test public void testDivide() { Fraction f = null; Fraction f1 = null; Fraction f2 = null; - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(2, 5); f = f1.divideBy(f2); assertEquals(3, f.getNumerator()); assertEquals(2, f.getDenominator()); - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.ZERO; try { f = f1.divideBy(f2); fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} - + f1 = Fraction.getFraction(0, 5); f2 = Fraction.getFraction(2, 7); f = f1.divideBy(f2); assertSame(Fraction.ZERO, f); - + f1 = Fraction.getFraction(2, 7); f2 = Fraction.ONE; f = f1.divideBy(f2); assertEquals(2, f.getNumerator()); assertEquals(7, f.getDenominator()); - + f1 = Fraction.getFraction(1, Integer.MAX_VALUE); - f = f1.divideBy(f1); + f = f1.divideBy(f1); assertEquals(1, f.getNumerator()); assertEquals(1, f.getDenominator()); - + f1 = Fraction.getFraction(Integer.MIN_VALUE, Integer.MAX_VALUE); f2 = Fraction.getFraction(1, Integer.MAX_VALUE); f = f1.divideBy(f2); @@ -1216,7 +1216,7 @@ public class FractionTest { f.divideBy(null); fail("IllegalArgumentException"); } catch (final IllegalArgumentException ex) {} - + try { f1 = Fraction.getFraction(1, Integer.MAX_VALUE); f = f1.divideBy(f1.invert()); // should overflow @@ -1228,69 +1228,69 @@ public class FractionTest { fail("expecting ArithmeticException"); } catch (final ArithmeticException ex) {} } - + @Test public void testEquals() { Fraction f1 = null; Fraction f2 = null; - + f1 = Fraction.getFraction(3, 5); assertFalse(f1.equals(null)); assertFalse(f1.equals(new Object())); assertFalse(f1.equals(Integer.valueOf(6))); - + f1 = Fraction.getFraction(3, 5); f2 = Fraction.getFraction(2, 5); assertFalse(f1.equals(f2)); assertTrue(f1.equals(f1)); assertTrue(f2.equals(f2)); - + f2 = Fraction.getFraction(3, 5); assertTrue(f1.equals(f2)); - + f2 = Fraction.getFraction(6, 10); assertFalse(f1.equals(f2)); } - + @Test public void testHashCode() { final Fraction f1 = Fraction.getFraction(3, 5); Fraction f2 = Fraction.getFraction(3, 5); - + assertTrue(f1.hashCode() == f2.hashCode()); - + f2 = Fraction.getFraction(2, 5); assertTrue(f1.hashCode() != f2.hashCode()); - + f2 = Fraction.getFraction(6, 10); assertTrue(f1.hashCode() != f2.hashCode()); } - + @Test public void testCompareTo() { Fraction f1 = null; Fraction f2 = null; - + f1 = Fraction.getFraction(3, 5); assertTrue(f1.compareTo(f1) == 0); - + try { f1.compareTo(null); fail("expecting NullPointerException"); } catch (final NullPointerException ex) {} - + f2 = Fraction.getFraction(2, 5); assertTrue(f1.compareTo(f2) > 0); assertTrue(f2.compareTo(f2) == 0); - + f2 = Fraction.getFraction(4, 5); assertTrue(f1.compareTo(f2) < 0); assertTrue(f2.compareTo(f2) == 0); - + f2 = Fraction.getFraction(3, 5); assertTrue(f1.compareTo(f2) == 0); assertTrue(f2.compareTo(f2) == 0); - + f2 = Fraction.getFraction(6, 10); assertTrue(f1.compareTo(f2) == 0); assertTrue(f2.compareTo(f2) == 0); @@ -1300,7 +1300,7 @@ public class FractionTest { assertTrue(f2.compareTo(f2) == 0); } - + @Test public void testToString() { Fraction f = null; @@ -1309,26 +1309,26 @@ public class FractionTest { final String str = f.toString(); assertEquals("3/5", str); assertSame(str, f.toString()); - + f = Fraction.getFraction(7, 5); - assertEquals("7/5", f.toString()); - + assertEquals("7/5", f.toString()); + f = Fraction.getFraction(4, 2); - assertEquals("4/2", f.toString()); - + assertEquals("4/2", f.toString()); + f = Fraction.getFraction(0, 2); - assertEquals("0/2", f.toString()); - + assertEquals("0/2", f.toString()); + f = Fraction.getFraction(2, 2); - assertEquals("2/2", f.toString()); + assertEquals("2/2", f.toString()); f = Fraction.getFraction(Integer.MIN_VALUE, 0, 1); - assertEquals("-2147483648/1", f.toString()); + assertEquals("-2147483648/1", f.toString()); f = Fraction.getFraction(-1, 1, Integer.MAX_VALUE); assertEquals("-2147483648/2147483647", f.toString()); } - + @Test public void testToProperString() { Fraction f = null; @@ -1337,27 +1337,27 @@ public class FractionTest { final String str = f.toProperString(); assertEquals("3/5", str); assertSame(str, f.toProperString()); - + f = Fraction.getFraction(7, 5); - assertEquals("1 2/5", f.toProperString()); - + assertEquals("1 2/5", f.toProperString()); + f = Fraction.getFraction(14, 10); - assertEquals("1 4/10", f.toProperString()); - + assertEquals("1 4/10", f.toProperString()); + f = Fraction.getFraction(4, 2); - assertEquals("2", f.toProperString()); - + assertEquals("2", f.toProperString()); + f = Fraction.getFraction(0, 2); - assertEquals("0", f.toProperString()); - + assertEquals("0", f.toProperString()); + f = Fraction.getFraction(2, 2); - assertEquals("1", f.toProperString()); - + assertEquals("1", f.toProperString()); + f = Fraction.getFraction(-7, 5); - assertEquals("-1 2/5", f.toProperString()); + assertEquals("-1 2/5", f.toProperString()); f = Fraction.getFraction(Integer.MIN_VALUE, 0, 1); - assertEquals("-2147483648", f.toProperString()); + assertEquals("-2147483648", f.toProperString()); f = Fraction.getFraction(-1, 1, Integer.MAX_VALUE); assertEquals("-1 1/2147483647", f.toProperString()); diff --git a/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java b/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java index 1c98c3ddc..026c0f72c 100644 --- a/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/math/IEEE754rUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -101,5 +101,5 @@ public class IEEE754rUtilsTest { public void testConstructorExists() { new IEEE754rUtils(); } - + } diff --git a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java index e50423923..3a53c1ebb 100644 --- a/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java @@ -114,7 +114,7 @@ public class NumberUtilsTest { assertTrue("toFloat(String,int) 1 failed", NumberUtils.toFloat("1.2345", 5.1f) == 1.2345f); assertTrue("toFloat(String,int) 2 failed", NumberUtils.toFloat("a", 5.0f) == 5.0f); } - + /** * Test for {(@link NumberUtils#createNumber(String)} */ @@ -123,7 +123,7 @@ public class NumberUtilsTest { final String shouldBeFloat = "1.23"; final String shouldBeDouble = "3.40282354e+38"; final String shouldBeBigDecimal = "1.797693134862315759e+308"; - + assertTrue(NumberUtils.createNumber(shouldBeFloat) instanceof Float); assertTrue(NumberUtils.createNumber(shouldBeDouble) instanceof Double); assertTrue(NumberUtils.createNumber(shouldBeBigDecimal) instanceof BigDecimal); @@ -243,7 +243,7 @@ public class NumberUtilsTest { final Number bigNum = NumberUtils.createNumber("-1.1E-700F"); assertNotNull(bigNum); assertEquals(BigDecimal.class, bigNum.getClass()); - + // LANG-1018 assertEquals("createNumber(String) LANG-1018 failed", Double.valueOf("-160952.54"), NumberUtils.createNumber("-160952.54")); @@ -254,7 +254,7 @@ public class NumberUtilsTest { assertEquals("createNumber(String) LANG-1215 failed", Double.valueOf("193343.82"), NumberUtils.createNumber("193343.82")); } - + @Test public void testLang1087(){ // no sign cases @@ -1418,7 +1418,7 @@ public class NumberUtilsTest { } fail("Expecting "+ expected + " for isCreatable/createNumber using \"" + val + "\" but got " + isValid + " and " + canCreate); } - + @Test public void testIsParsable() { assertFalse( NumberUtils.isParsable(null) ); diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java index 67c6229a0..09c793c58 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableBooleanTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,7 +25,7 @@ import static org.junit.Assert.assertTrue; /** * JUnit tests. - * + * * @since 2.2 * @see MutableBoolean */ @@ -41,7 +41,7 @@ public class MutableBooleanTest { assertEquals(+1, mutBool.compareTo(new MutableBoolean(false))); assertEquals(0, mutBool.compareTo(new MutableBoolean(true))); } - + @Test(expected=NullPointerException.class) public void testCompareToNull() { final MutableBoolean mutBool = new MutableBoolean(false); @@ -88,7 +88,7 @@ public class MutableBooleanTest { public void testGetSet() { assertFalse(new MutableBoolean().booleanValue()); assertEquals(Boolean.FALSE, new MutableBoolean().getValue()); - + final MutableBoolean mutBool = new MutableBoolean(false); assertEquals(Boolean.FALSE, mutBool.toBoolean()); assertFalse(mutBool.booleanValue()); diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java index 10d9aeeed..61dfd0d9c 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableByteTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,7 +24,7 @@ import static org.junit.Assert.assertTrue; /** * JUnit tests. - * + * * @see MutableByte */ public class MutableByteTest { @@ -33,9 +33,9 @@ public class MutableByteTest { @Test public void testConstructors() { assertEquals((byte) 0, new MutableByte().byteValue()); - + assertEquals((byte) 1, new MutableByte((byte) 1).byteValue()); - + assertEquals((byte) 2, new MutableByte(Byte.valueOf((byte) 2)).byteValue()); assertEquals((byte) 3, new MutableByte(new MutableByte((byte) 3)).byteValue()); @@ -53,15 +53,15 @@ public class MutableByteTest { final MutableByte mutNum = new MutableByte((byte) 0); assertEquals((byte) 0, new MutableByte().byteValue()); assertEquals(Byte.valueOf((byte) 0), new MutableByte().getValue()); - + mutNum.setValue((byte) 1); assertEquals((byte) 1, mutNum.byteValue()); assertEquals(Byte.valueOf((byte) 1), mutNum.getValue()); - + mutNum.setValue(Byte.valueOf((byte) 2)); assertEquals((byte) 2, mutNum.byteValue()); assertEquals(Byte.valueOf((byte) 2), mutNum.getValue()); - + mutNum.setValue(new MutableByte((byte) 3)); assertEquals((byte) 3, mutNum.byteValue()); assertEquals(Byte.valueOf((byte) 3), mutNum.getValue()); @@ -121,7 +121,7 @@ public class MutableByteTest { @Test public void testPrimitiveValues() { final MutableByte mutNum = new MutableByte( (byte) 1 ); - + assertEquals( 1.0F, mutNum.floatValue(), 0 ); assertEquals( 1.0, mutNum.doubleValue(), 0 ); assertEquals( (byte) 1, mutNum.byteValue() ); @@ -140,7 +140,7 @@ public class MutableByteTest { public void testIncrement() { final MutableByte mutNum = new MutableByte((byte) 1); mutNum.increment(); - + assertEquals(2, mutNum.intValue()); assertEquals(2L, mutNum.longValue()); } @@ -169,7 +169,7 @@ public class MutableByteTest { public void testDecrement() { final MutableByte mutNum = new MutableByte((byte) 1); mutNum.decrement(); - + assertEquals(0, mutNum.intValue()); assertEquals(0L, mutNum.longValue()); } @@ -198,7 +198,7 @@ public class MutableByteTest { public void testAddValuePrimitive() { final MutableByte mutNum = new MutableByte((byte) 1); mutNum.add((byte)1); - + assertEquals((byte) 2, mutNum.byteValue()); } @@ -206,7 +206,7 @@ public class MutableByteTest { public void testAddValueObject() { final MutableByte mutNum = new MutableByte((byte) 1); mutNum.add(Integer.valueOf(1)); - + assertEquals((byte) 2, mutNum.byteValue()); } @@ -250,7 +250,7 @@ public class MutableByteTest { public void testSubtractValuePrimitive() { final MutableByte mutNum = new MutableByte((byte) 1); mutNum.subtract((byte) 1); - + assertEquals((byte) 0, mutNum.byteValue()); } @@ -258,7 +258,7 @@ public class MutableByteTest { public void testSubtractValueObject() { final MutableByte mutNum = new MutableByte((byte) 1); mutNum.subtract(Integer.valueOf(1)); - + assertEquals((byte) 0, mutNum.byteValue()); } diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java index 8cfb8f327..df1b6d54c 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableDoubleTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,7 +24,7 @@ import static org.junit.Assert.assertTrue; /** * JUnit tests. - * + * * @see MutableDouble */ public class MutableDoubleTest { @@ -33,12 +33,12 @@ public class MutableDoubleTest { @Test public void testConstructors() { assertEquals(0d, new MutableDouble().doubleValue(), 0.0001d); - + assertEquals(1d, new MutableDouble(1d).doubleValue(), 0.0001d); - + assertEquals(2d, new MutableDouble(Double.valueOf(2d)).doubleValue(), 0.0001d); assertEquals(3d, new MutableDouble(new MutableDouble(3d)).doubleValue(), 0.0001d); - + assertEquals(2d, new MutableDouble("2.0").doubleValue(), 0.0001d); } @@ -53,15 +53,15 @@ public class MutableDoubleTest { final MutableDouble mutNum = new MutableDouble(0d); assertEquals(0d, new MutableDouble().doubleValue(), 0.0001d); assertEquals(Double.valueOf(0), new MutableDouble().getValue()); - + mutNum.setValue(1); assertEquals(1d, mutNum.doubleValue(), 0.0001d); assertEquals(Double.valueOf(1d), mutNum.getValue()); - + mutNum.setValue(Double.valueOf(2d)); assertEquals(2d, mutNum.doubleValue(), 0.0001d); assertEquals(Double.valueOf(2d), mutNum.getValue()); - + mutNum.setValue(new MutableDouble(3d)); assertEquals(3d, mutNum.doubleValue(), 0.0001d); assertEquals(Double.valueOf(3d), mutNum.getValue()); @@ -77,10 +77,10 @@ public class MutableDoubleTest { public void testNanInfinite() { MutableDouble mutNum = new MutableDouble(Double.NaN); assertTrue(mutNum.isNaN()); - + mutNum = new MutableDouble(Double.POSITIVE_INFINITY); assertTrue(mutNum.isInfinite()); - + mutNum = new MutableDouble(Double.NEGATIVE_INFINITY); assertTrue(mutNum.isInfinite()); } @@ -133,7 +133,7 @@ public class MutableDoubleTest { @Test public void testPrimitiveValues() { final MutableDouble mutNum = new MutableDouble(1.7); - + assertEquals( 1.7F, mutNum.floatValue(), 0 ); assertEquals( 1.7, mutNum.doubleValue(), 0 ); assertEquals( (byte) 1, mutNum.byteValue() ); @@ -152,7 +152,7 @@ public class MutableDoubleTest { public void testIncrement() { final MutableDouble mutNum = new MutableDouble(1); mutNum.increment(); - + assertEquals(2, mutNum.intValue()); assertEquals(2L, mutNum.longValue()); } @@ -181,7 +181,7 @@ public class MutableDoubleTest { public void testDecrement() { final MutableDouble mutNum = new MutableDouble(1); mutNum.decrement(); - + assertEquals(0, mutNum.intValue()); assertEquals(0L, mutNum.longValue()); } @@ -210,7 +210,7 @@ public class MutableDoubleTest { public void testAddValuePrimitive() { final MutableDouble mutNum = new MutableDouble(1); mutNum.add(1.1d); - + assertEquals(2.1d, mutNum.doubleValue(), 0.01d); } @@ -218,7 +218,7 @@ public class MutableDoubleTest { public void testAddValueObject() { final MutableDouble mutNum = new MutableDouble(1); mutNum.add(Double.valueOf(1.1d)); - + assertEquals(2.1d, mutNum.doubleValue(), 0.01d); } @@ -262,7 +262,7 @@ public class MutableDoubleTest { public void testSubtractValuePrimitive() { final MutableDouble mutNum = new MutableDouble(1); mutNum.subtract(0.9d); - + assertEquals(0.1d, mutNum.doubleValue(), 0.01d); } @@ -270,7 +270,7 @@ public class MutableDoubleTest { public void testSubtractValueObject() { final MutableDouble mutNum = new MutableDouble(1); mutNum.subtract(Double.valueOf(0.9d)); - + assertEquals(0.1d, mutNum.doubleValue(), 0.01d); } diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java index af4abd8da..169763a50 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableFloatTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,7 +24,7 @@ import static org.junit.Assert.assertTrue; /** * JUnit tests. - * + * * @see MutableFloat */ public class MutableFloatTest { @@ -33,9 +33,9 @@ public class MutableFloatTest { @Test public void testConstructors() { assertEquals(0f, new MutableFloat().floatValue(), 0.0001f); - + assertEquals(1f, new MutableFloat(1f).floatValue(), 0.0001f); - + assertEquals(2f, new MutableFloat(Float.valueOf(2f)).floatValue(), 0.0001f); assertEquals(3f, new MutableFloat(new MutableFloat(3f)).floatValue(), 0.0001f); @@ -53,15 +53,15 @@ public class MutableFloatTest { final MutableFloat mutNum = new MutableFloat(0f); assertEquals(0f, new MutableFloat().floatValue(), 0.0001f); assertEquals(Float.valueOf(0), new MutableFloat().getValue()); - + mutNum.setValue(1); assertEquals(1f, mutNum.floatValue(), 0.0001f); assertEquals(Float.valueOf(1f), mutNum.getValue()); - + mutNum.setValue(Float.valueOf(2f)); assertEquals(2f, mutNum.floatValue(), 0.0001f); assertEquals(Float.valueOf(2f), mutNum.getValue()); - + mutNum.setValue(new MutableFloat(3f)); assertEquals(3f, mutNum.floatValue(), 0.0001f); assertEquals(Float.valueOf(3f), mutNum.getValue()); @@ -77,10 +77,10 @@ public class MutableFloatTest { public void testNanInfinite() { MutableFloat mutNum = new MutableFloat(Float.NaN); assertTrue(mutNum.isNaN()); - + mutNum = new MutableFloat(Float.POSITIVE_INFINITY); assertTrue(mutNum.isInfinite()); - + mutNum = new MutableFloat(Float.NEGATIVE_INFINITY); assertTrue(mutNum.isInfinite()); } @@ -133,7 +133,7 @@ public class MutableFloatTest { @Test public void testPrimitiveValues() { final MutableFloat mutNum = new MutableFloat(1.7F); - + assertEquals( 1, mutNum.intValue() ); assertEquals( 1.7, mutNum.doubleValue(), 0.00001 ); assertEquals( (byte) 1, mutNum.byteValue() ); @@ -152,7 +152,7 @@ public class MutableFloatTest { public void testIncrement() { final MutableFloat mutNum = new MutableFloat(1); mutNum.increment(); - + assertEquals(2, mutNum.intValue()); assertEquals(2L, mutNum.longValue()); } @@ -181,7 +181,7 @@ public class MutableFloatTest { public void testDecrement() { final MutableFloat mutNum = new MutableFloat(1); mutNum.decrement(); - + assertEquals(0, mutNum.intValue()); assertEquals(0L, mutNum.longValue()); } @@ -210,7 +210,7 @@ public class MutableFloatTest { public void testAddValuePrimitive() { final MutableFloat mutNum = new MutableFloat(1); mutNum.add(1.1f); - + assertEquals(2.1f, mutNum.floatValue(), 0.01f); } @@ -218,7 +218,7 @@ public class MutableFloatTest { public void testAddValueObject() { final MutableFloat mutNum = new MutableFloat(1); mutNum.add(Float.valueOf(1.1f)); - + assertEquals(2.1f, mutNum.floatValue(), 0.01f); } @@ -262,7 +262,7 @@ public class MutableFloatTest { public void testSubtractValuePrimitive() { final MutableFloat mutNum = new MutableFloat(1); mutNum.subtract(0.9f); - + assertEquals(0.1f, mutNum.floatValue(), 0.01f); } @@ -270,7 +270,7 @@ public class MutableFloatTest { public void testSubtractValueObject() { final MutableFloat mutNum = new MutableFloat(1); mutNum.subtract(Float.valueOf(0.9f)); - + assertEquals(0.1f, mutNum.floatValue(), 0.01f); } diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java index d7efefd1d..9cf711edf 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableIntTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,7 +24,7 @@ import static org.junit.Assert.assertTrue; /** * JUnit tests. - * + * * @see MutableInt */ public class MutableIntTest { @@ -33,9 +33,9 @@ public class MutableIntTest { @Test public void testConstructors() { assertEquals(0, new MutableInt().intValue()); - + assertEquals(1, new MutableInt(1).intValue()); - + assertEquals(2, new MutableInt(Integer.valueOf(2)).intValue()); assertEquals(3, new MutableInt(new MutableLong(3)).intValue()); @@ -53,15 +53,15 @@ public class MutableIntTest { final MutableInt mutNum = new MutableInt(0); assertEquals(0, new MutableInt().intValue()); assertEquals(Integer.valueOf(0), new MutableInt().getValue()); - + mutNum.setValue(1); assertEquals(1, mutNum.intValue()); assertEquals(Integer.valueOf(1), mutNum.getValue()); - + mutNum.setValue(Integer.valueOf(2)); assertEquals(2, mutNum.intValue()); assertEquals(Integer.valueOf(2), mutNum.getValue()); - + mutNum.setValue(new MutableLong(3)); assertEquals(3, mutNum.intValue()); assertEquals(Integer.valueOf(3), mutNum.getValue()); @@ -128,7 +128,7 @@ public class MutableIntTest { @Test public void testPrimitiveValues() { final MutableInt mutNum = new MutableInt(1); - + assertEquals( (byte) 1, mutNum.byteValue() ); assertEquals( (short) 1, mutNum.shortValue() ); assertEquals( 1.0F, mutNum.floatValue(), 0 ); @@ -146,7 +146,7 @@ public class MutableIntTest { public void testIncrement() { final MutableInt mutNum = new MutableInt(1); mutNum.increment(); - + assertEquals(2, mutNum.intValue()); assertEquals(2L, mutNum.longValue()); } @@ -175,7 +175,7 @@ public class MutableIntTest { public void testDecrement() { final MutableInt mutNum = new MutableInt(1); mutNum.decrement(); - + assertEquals(0, mutNum.intValue()); assertEquals(0L, mutNum.longValue()); } @@ -204,7 +204,7 @@ public class MutableIntTest { public void testAddValuePrimitive() { final MutableInt mutNum = new MutableInt(1); mutNum.add(1); - + assertEquals(2, mutNum.intValue()); assertEquals(2L, mutNum.longValue()); } @@ -213,7 +213,7 @@ public class MutableIntTest { public void testAddValueObject() { final MutableInt mutNum = new MutableInt(1); mutNum.add(Integer.valueOf(1)); - + assertEquals(2, mutNum.intValue()); assertEquals(2L, mutNum.longValue()); } @@ -258,7 +258,7 @@ public class MutableIntTest { public void testSubtractValuePrimitive() { final MutableInt mutNum = new MutableInt(1); mutNum.subtract(1); - + assertEquals(0, mutNum.intValue()); assertEquals(0L, mutNum.longValue()); } @@ -267,7 +267,7 @@ public class MutableIntTest { public void testSubtractValueObject() { final MutableInt mutNum = new MutableInt(1); mutNum.subtract(Integer.valueOf(1)); - + assertEquals(0, mutNum.intValue()); assertEquals(0L, mutNum.longValue()); } diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java index c65c7895b..1ec522e5c 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableLongTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -24,7 +24,7 @@ import static org.junit.Assert.assertTrue; /** * JUnit tests. - * + * * @see MutableLong */ public class MutableLongTest { @@ -33,9 +33,9 @@ public class MutableLongTest { @Test public void testConstructors() { assertEquals(0, new MutableLong().longValue()); - + assertEquals(1, new MutableLong(1).longValue()); - + assertEquals(2, new MutableLong(Long.valueOf(2)).longValue()); assertEquals(3, new MutableLong(new MutableLong(3)).longValue()); @@ -53,15 +53,15 @@ public class MutableLongTest { final MutableLong mutNum = new MutableLong(0); assertEquals(0, new MutableLong().longValue()); assertEquals(Long.valueOf(0), new MutableLong().getValue()); - + mutNum.setValue(1); assertEquals(1, mutNum.longValue()); assertEquals(Long.valueOf(1), mutNum.getValue()); - + mutNum.setValue(Long.valueOf(2)); assertEquals(2, mutNum.longValue()); assertEquals(Long.valueOf(2), mutNum.getValue()); - + mutNum.setValue(new MutableLong(3)); assertEquals(3, mutNum.longValue()); assertEquals(Long.valueOf(3), mutNum.getValue()); @@ -140,7 +140,7 @@ public class MutableLongTest { public void testIncrement() { final MutableLong mutNum = new MutableLong(1); mutNum.increment(); - + assertEquals(2, mutNum.intValue()); assertEquals(2L, mutNum.longValue()); } @@ -169,7 +169,7 @@ public class MutableLongTest { public void testDecrement() { final MutableLong mutNum = new MutableLong(1); mutNum.decrement(); - + assertEquals(0, mutNum.intValue()); assertEquals(0L, mutNum.longValue()); } @@ -198,7 +198,7 @@ public class MutableLongTest { public void testAddValuePrimitive() { final MutableLong mutNum = new MutableLong(1); mutNum.add(1); - + assertEquals(2, mutNum.intValue()); assertEquals(2L, mutNum.longValue()); } @@ -207,7 +207,7 @@ public class MutableLongTest { public void testAddValueObject() { final MutableLong mutNum = new MutableLong(1); mutNum.add(Long.valueOf(1)); - + assertEquals(2, mutNum.intValue()); assertEquals(2L, mutNum.longValue()); } @@ -252,7 +252,7 @@ public class MutableLongTest { public void testSubtractValuePrimitive() { final MutableLong mutNum = new MutableLong(1); mutNum.subtract(1); - + assertEquals(0, mutNum.intValue()); assertEquals(0L, mutNum.longValue()); } @@ -261,7 +261,7 @@ public class MutableLongTest { public void testSubtractValueObject() { final MutableLong mutNum = new MutableLong(1); mutNum.subtract(Long.valueOf(1)); - + assertEquals(0, mutNum.intValue()); assertEquals(0L, mutNum.longValue()); } diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java index 7e0047b7a..505047794 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableObjectTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,7 +26,7 @@ import org.junit.Test; /** * JUnit tests. - * + * * @see MutableShort */ public class MutableObjectTest { @@ -35,7 +35,7 @@ public class MutableObjectTest { @Test public void testConstructors() { assertEquals(null, new MutableObject<String>().getValue()); - + final Integer i = Integer.valueOf(6); assertSame(i, new MutableObject<>(i).getValue()); assertSame("HI", new MutableObject<>("HI").getValue()); @@ -46,10 +46,10 @@ public class MutableObjectTest { public void testGetSet() { final MutableObject<String> mutNum = new MutableObject<>(); assertEquals(null, new MutableObject<>().getValue()); - + mutNum.setValue("HELLO"); assertSame("HELLO", mutNum.getValue()); - + mutNum.setValue(null); assertSame(null, mutNum.getValue()); } @@ -70,7 +70,7 @@ public class MutableObjectTest { assertTrue(mutNumC.equals(mutNumC)); assertFalse(mutNumA.equals(mutNumD)); assertTrue(mutNumD.equals(mutNumD)); - + assertFalse(mutNumA.equals(null)); assertFalse(mutNumA.equals(new Object())); assertFalse(mutNumA.equals("0")); diff --git a/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java b/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java index 2b91b79da..fe926fff6 100644 --- a/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java +++ b/src/test/java/org/apache/commons/lang3/mutable/MutableShortTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,7 +25,7 @@ import static org.junit.Assert.fail; /** * JUnit tests. - * + * * @see MutableShort */ public class MutableShortTest { @@ -34,9 +34,9 @@ public class MutableShortTest { @Test public void testConstructors() { assertEquals((short) 0, new MutableShort().shortValue()); - + assertEquals((short) 1, new MutableShort((short) 1).shortValue()); - + assertEquals((short) 2, new MutableShort(Short.valueOf((short) 2)).shortValue()); assertEquals((short) 3, new MutableShort(new MutableShort((short) 3)).shortValue()); @@ -53,15 +53,15 @@ public class MutableShortTest { final MutableShort mutNum = new MutableShort((short) 0); assertEquals((short) 0, new MutableShort().shortValue()); assertEquals(Short.valueOf((short) 0), new MutableShort().getValue()); - + mutNum.setValue((short) 1); assertEquals((short) 1, mutNum.shortValue()); assertEquals(Short.valueOf((short) 1), mutNum.getValue()); - + mutNum.setValue(Short.valueOf((short) 2)); assertEquals((short) 2, mutNum.shortValue()); assertEquals(Short.valueOf((short) 2), mutNum.getValue()); - + mutNum.setValue(new MutableShort((short) 3)); assertEquals((short) 3, mutNum.shortValue()); assertEquals(Short.valueOf((short) 3), mutNum.getValue()); @@ -117,7 +117,7 @@ public class MutableShortTest { @Test public void testPrimitiveValues() { final MutableShort mutNum = new MutableShort( (short) 1 ); - + assertEquals( 1.0F, mutNum.floatValue(), 0 ); assertEquals( 1.0, mutNum.doubleValue(), 0 ); assertEquals( (byte) 1, mutNum.byteValue() ); @@ -136,7 +136,7 @@ public class MutableShortTest { public void testIncrement() { final MutableShort mutNum = new MutableShort((short) 1); mutNum.increment(); - + assertEquals(2, mutNum.intValue()); assertEquals(2L, mutNum.longValue()); } @@ -165,7 +165,7 @@ public class MutableShortTest { public void testDecrement() { final MutableShort mutNum = new MutableShort((short) 1); mutNum.decrement(); - + assertEquals(0, mutNum.intValue()); assertEquals(0L, mutNum.longValue()); } @@ -194,7 +194,7 @@ public class MutableShortTest { public void testAddValuePrimitive() { final MutableShort mutNum = new MutableShort((short) 1); mutNum.add((short) 1); - + assertEquals((short) 2, mutNum.shortValue()); } @@ -202,7 +202,7 @@ public class MutableShortTest { public void testAddValueObject() { final MutableShort mutNum = new MutableShort((short) 1); mutNum.add(Short.valueOf((short) 1)); - + assertEquals((short) 2, mutNum.shortValue()); } @@ -246,7 +246,7 @@ public class MutableShortTest { public void testSubtractValuePrimitive() { final MutableShort mutNum = new MutableShort((short) 1); mutNum.subtract((short) 1); - + assertEquals((short) 0, mutNum.shortValue()); } @@ -254,7 +254,7 @@ public class MutableShortTest { public void testSubtractValueObject() { final MutableShort mutNum = new MutableShort((short) 1); mutNum.subtract(Short.valueOf((short) 1)); - + assertEquals((short) 0, mutNum.shortValue()); } diff --git a/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java index 3b7ca3c5a..16a3f59f5 100644 --- a/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/reflect/FieldUtilsTest.java @@ -1332,7 +1332,7 @@ public class FieldUtilsTest { assertFalse(Modifier.isFinal(field.getModifiers())); assertFalse(field.isAccessible()); } - + @Test public void testRemoveFinalModifierWithAccess() throws Exception { final Field field = StaticContainer.class.getDeclaredField("IMMUTABLE_PRIVATE_2"); diff --git a/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java index 16069e975..b3cef7a54 100644 --- a/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java @@ -685,14 +685,14 @@ public class TypeUtilsTest<B> { stringComparableType)); Assert.assertEquals("java.lang.Comparable<java.lang.String>", stringComparableType.toString()); } - + @Test public void testParameterizeWithOwner() throws Exception { final Type owner = TypeUtils.parameterize(TypeUtilsTest.class, String.class); final ParameterizedType dat2Type = TypeUtils.parameterizeWithOwner(owner, That.class, String.class, String.class); Assert.assertTrue(TypeUtils.equals(getClass().getField("dat2").getGenericType(), dat2Type)); } - + @Test public void testWildcardType() throws Exception { final WildcardType simpleWildcard = TypeUtils.wildcardType().withUpperBounds(String.class).build(); diff --git a/src/test/java/org/apache/commons/lang3/test/SystemDefaults.java b/src/test/java/org/apache/commons/lang3/test/SystemDefaults.java index e5893a2c6..0bb091254 100644 --- a/src/test/java/org/apache/commons/lang3/test/SystemDefaults.java +++ b/src/test/java/org/apache/commons/lang3/test/SystemDefaults.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/test/SystemDefaultsSwitch.java b/src/test/java/org/apache/commons/lang3/test/SystemDefaultsSwitch.java index 398341c72..cc26fa465 100644 --- a/src/test/java/org/apache/commons/lang3/test/SystemDefaultsSwitch.java +++ b/src/test/java/org/apache/commons/lang3/test/SystemDefaultsSwitch.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -26,12 +26,12 @@ import org.junit.runners.model.Statement; /** * Test Rule used with {@link SystemDefaults} annotation that sets and restores the system default Locale and TimeZone. - * + * * <p> * Set up tests to use alternate system default Locale and/or TimeZone by creating an instance of this rule - * and annotating the test method with {@link SystemDefaults} + * and annotating the test method with {@link SystemDefaults} * </p> - * + * * <pre> * public class SystemDefaultsDependentTest { * @@ -48,7 +48,7 @@ import org.junit.runners.model.Statement; * public void testWithSimplifiedChinaDefaultLocale() { * // Locale.getDefault() will return Locale.CHINA until the end of this test method * } - * + * * {@literal @}Test * {@literal @}SystemDefaults(timezone="America/New_York") * public void testWithNorthAmericaEasternTimeZone() { @@ -58,7 +58,7 @@ import org.junit.runners.model.Statement; * </pre> */ public class SystemDefaultsSwitch implements TestRule { - + @Override public Statement apply(final Statement stmt, final Description description) { final SystemDefaults defaults = description.getAnnotation(SystemDefaults.class); diff --git a/src/test/java/org/apache/commons/lang3/test/SystemDefaultsSwitchTest.java b/src/test/java/org/apache/commons/lang3/test/SystemDefaultsSwitchTest.java index d85d6abca..f2cd6f52c 100644 --- a/src/test/java/org/apache/commons/lang3/test/SystemDefaultsSwitchTest.java +++ b/src/test/java/org/apache/commons/lang3/test/SystemDefaultsSwitchTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/text/CompositeFormatTest.java b/src/test/java/org/apache/commons/lang3/text/CompositeFormatTest.java index 78202ffdc..f3b6cf765 100644 --- a/src/test/java/org/apache/commons/lang3/text/CompositeFormatTest.java +++ b/src/test/java/org/apache/commons/lang3/text/CompositeFormatTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,7 +34,7 @@ import java.util.Locale; public class CompositeFormatTest { /** - * Ensures that the parse/format separation is correctly maintained. + * Ensures that the parse/format separation is correctly maintained. */ @Test public void testCompositeFormat() { diff --git a/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java b/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java index f8916f640..41468a9bb 100644 --- a/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java +++ b/src/test/java/org/apache/commons/lang3/text/ExtendedMessageFormatTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -93,12 +93,12 @@ public class ExtendedMessageFormatTest { */ @Test public void testEscapedBraces_LANG_948() { - // message without placeholder because braces are escaped by quotes + // message without placeholder because braces are escaped by quotes final String pattern = "Message without placeholders '{}'"; final ExtendedMessageFormat emf = new ExtendedMessageFormat(pattern, registry); assertEquals("Message without placeholders {}", emf.format(new Object[] {"DUMMY"})); - // message with placeholder because quotes are escaped by quotes + // message with placeholder because quotes are escaped by quotes final String pattern2 = "Message with placeholder ''{0}''"; final ExtendedMessageFormat emf2 = new ExtendedMessageFormat(pattern2, registry); assertEquals("Message with placeholder 'DUMMY'", emf2.format(new Object[] {"DUMMY"})); @@ -313,7 +313,7 @@ public class ExtendedMessageFormatTest { other = new OtherExtendedMessageFormat(pattern, Locale.US, fmtRegistry); assertFalse("class, equals()", emf.equals(other)); assertTrue("class, hashcode()", emf.hashCode() == other.hashCode()); // same hashcode - + // Different pattern other = new ExtendedMessageFormat("X" + pattern, Locale.US, fmtRegistry); assertFalse("pattern, equals()", emf.equals(other)); @@ -471,7 +471,7 @@ public class ExtendedMessageFormatTest { final Map<String, ? extends FormatFactory> registry) { super(pattern, locale, registry); } - + } } diff --git a/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java b/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java index dbb38e2ee..ed86721e1 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrBuilderAppendInsertTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -51,7 +51,7 @@ public class StrBuilderAppendInsertTest { StrBuilder sb = new StrBuilder("---"); sb.appendNewLine().append("+++"); assertEquals("---" + SEP + "+++", sb.toString()); - + sb = new StrBuilder("---"); sb.setNewLineText("#").appendNewLine().setNewLineText(null).appendNewLine(); assertEquals("---#" + SEP, sb.toString()); @@ -117,7 +117,7 @@ public class StrBuilderAppendInsertTest { sb.append(new StringBuilder("bld")); // Check it supports StringBuilder assertEquals("foobazyesSeqbld", sb.toString()); } - + //----------------------------------------------------------------------- @Test public void testAppend_StringBuilder() { @@ -216,7 +216,7 @@ public class StrBuilderAppendInsertTest { sb.append( (CharSequence)"abcbardef", 4, 3); assertEquals("foobarard", sb.toString()); } - + //----------------------------------------------------------------------- @Test public void testAppend_StringBuilder_int_int() { @@ -826,7 +826,7 @@ public class StrBuilderAppendInsertTest { final StrBuilder sb = new StrBuilder(); sb.appendln(true); assertEquals("true" + SEP, sb.toString()); - + sb.clear(); sb.appendln(false); assertEquals("false" + SEP, sb.toString()); @@ -838,15 +838,15 @@ public class StrBuilderAppendInsertTest { final StrBuilder sb = new StrBuilder(); sb.appendln(0); assertEquals("0" + SEP, sb.toString()); - + sb.clear(); sb.appendln(1L); assertEquals("1" + SEP, sb.toString()); - + sb.clear(); sb.appendln(2.3f); assertEquals("2.3" + SEP, sb.toString()); - + sb.clear(); sb.appendln(4.5d); assertEquals("4.5" + SEP, sb.toString()); @@ -1201,7 +1201,7 @@ public class StrBuilderAppendInsertTest { sb.appendSeparator(","); assertEquals("foo,", sb.toString()); } - + //----------------------------------------------------------------------- @Test public void testAppendSeparator_String_String() { @@ -1213,11 +1213,11 @@ public class StrBuilderAppendInsertTest { assertEquals("", sb.toString()); sb.appendSeparator(standardSeparator, null); assertEquals("", sb.toString()); - sb.appendSeparator(standardSeparator, startSeparator); + sb.appendSeparator(standardSeparator, startSeparator); assertEquals(startSeparator, sb.toString()); - sb.appendSeparator(null, null); + sb.appendSeparator(null, null); assertEquals(startSeparator, sb.toString()); - sb.appendSeparator(null, startSeparator); + sb.appendSeparator(null, startSeparator); assertEquals(startSeparator, sb.toString()); sb.append(foo); assertEquals(startSeparator + foo, sb.toString()); @@ -1260,7 +1260,7 @@ public class StrBuilderAppendInsertTest { assertEquals("foo", sb.toString()); sb.appendSeparator(",", 1); assertEquals("foo,", sb.toString()); - + sb.appendSeparator(",", -1); // no effect assertEquals("foo,", sb.toString()); } @@ -1275,7 +1275,7 @@ public class StrBuilderAppendInsertTest { assertEquals("foo", sb.toString()); sb.appendSeparator(',', 1); assertEquals("foo,", sb.toString()); - + sb.appendSeparator(',', -1); // no effect assertEquals("foo,", sb.toString()); } diff --git a/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java b/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java index 09af460cb..ea684b621 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrBuilderTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -305,7 +305,7 @@ public class StrBuilderTest { public void testLength() { final StrBuilder sb = new StrBuilder(); assertEquals(0, sb.length()); - + sb.append("Hello"); assertEquals(5, sb.length()); } @@ -334,7 +334,7 @@ public class StrBuilderTest { public void testCapacity() { final StrBuilder sb = new StrBuilder(); assertEquals(sb.buffer.length, sb.capacity()); - + sb.append("HelloWorldHelloWorldHelloWorldHelloWorld"); assertEquals(sb.buffer.length, sb.capacity()); } @@ -344,10 +344,10 @@ public class StrBuilderTest { final StrBuilder sb = new StrBuilder(); sb.ensureCapacity(2); assertTrue(sb.capacity() >= 2); - + sb.ensureCapacity(-1); assertTrue(sb.capacity() >= 0); - + sb.append("HelloWorld"); sb.ensureCapacity(40); assertTrue(sb.capacity() >= 40); @@ -358,7 +358,7 @@ public class StrBuilderTest { final StrBuilder sb = new StrBuilder(); sb.minimizeCapacity(); assertEquals(0, sb.capacity()); - + sb.append("HelloWorld"); sb.minimizeCapacity(); assertEquals(10, sb.capacity()); @@ -369,7 +369,7 @@ public class StrBuilderTest { public void testSize() { final StrBuilder sb = new StrBuilder(); assertEquals(0, sb.size()); - + sb.append("Hello"); assertEquals(5, sb.size()); } @@ -378,10 +378,10 @@ public class StrBuilderTest { public void testIsEmpty() { final StrBuilder sb = new StrBuilder(); assertTrue(sb.isEmpty()); - + sb.append("Hello"); assertFalse(sb.isEmpty()); - + sb.clear(); assertTrue(sb.isEmpty()); } @@ -463,8 +463,8 @@ public class StrBuilderTest { public void testDeleteCharAt() { final StrBuilder sb = new StrBuilder("abc"); sb.deleteCharAt(0); - assertEquals("bc", sb.toString()); - + assertEquals("bc", sb.toString()); + try { sb.deleteCharAt(1000); fail("Expected IndexOutOfBoundsException"); @@ -524,26 +524,26 @@ public class StrBuilderTest { @Test public void testGetChars ( ) { final StrBuilder sb = new StrBuilder(); - + char[] input = new char[10]; char[] a = sb.getChars(input); assertSame (input, a); assertTrue(Arrays.equals(new char[10], a)); - + 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)); - + a = sb.getChars(null); assertNotSame(input,a); assertEquals(5,a.length); assertTrue(Arrays.equals("junit".toCharArray(),a)); - + input = new char[5]; a = sb.getChars(input); assertSame(input, a); - + input = new char[4]; a = sb.getChars(input); assertNotSame(input, a); @@ -552,37 +552,37 @@ public class StrBuilderTest { @Test public void testGetCharsIntIntCharArrayInt( ) { final StrBuilder sb = new StrBuilder(); - + 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)); - + a = new char[5]; sb.getChars(0,2,a,3); assertTrue(Arrays.equals(new char[] {0,0,0,'j','u'},a)); - + try { sb.getChars(-1,0,a,0); fail("no exception"); } catch (final IndexOutOfBoundsException e) { } - + try { sb.getChars(0,-1,a,0); fail("no exception"); } catch (final IndexOutOfBoundsException e) { } - + try { sb.getChars(0,20,a,0); fail("no exception"); } catch (final IndexOutOfBoundsException e) { } - + try { sb.getChars(4,2,a,0); fail("no exception"); @@ -596,14 +596,14 @@ public class StrBuilderTest { public void testDeleteIntInt() { StrBuilder sb = new StrBuilder("abc"); sb.delete(0, 1); - assertEquals("bc", sb.toString()); + assertEquals("bc", sb.toString()); sb.delete(1, 2); assertEquals("b", sb.toString()); sb.delete(0, 1); - assertEquals("", sb.toString()); + assertEquals("", sb.toString()); sb.delete(0, 1000); - assertEquals("", sb.toString()); - + assertEquals("", sb.toString()); + try { sb.delete(1, 2); fail("Expected IndexOutOfBoundsException"); @@ -612,7 +612,7 @@ public class StrBuilderTest { sb.delete(-1, 1); fail("Expected IndexOutOfBoundsException"); } catch (final IndexOutOfBoundsException e) {} - + sb = new StrBuilder("anything"); try { sb.delete(2, 1); @@ -663,7 +663,7 @@ public class StrBuilderTest { assertEquals("abcbccba", sb.toString()); sb.deleteAll(""); assertEquals("abcbccba", sb.toString()); - + sb.deleteAll("X"); assertEquals("abcbccba", sb.toString()); sb.deleteAll("a"); @@ -759,7 +759,7 @@ public class StrBuilderTest { assertEquals("btext", sb.toString()); sb.replace(0, 1000, "text"); assertEquals("text", sb.toString()); - + sb = new StrBuilder("atext"); sb.replace(1, 1, "ny"); assertEquals("anytext", sb.toString()); @@ -767,7 +767,7 @@ public class StrBuilderTest { sb.replace(2, 1, "anything"); fail("Expected IndexOutOfBoundsException"); } catch (final IndexOutOfBoundsException e) {} - + sb = new StrBuilder(); try { sb.replace(1, 2, "anything"); @@ -823,7 +823,7 @@ public class StrBuilderTest { assertEquals("abcbccba", sb.toString()); sb.replaceAll("", "anything"); assertEquals("abcbccba", sb.toString()); - + sb.replaceAll("x", "y"); assertEquals("abcbccba", sb.toString()); sb.replaceAll("a", "d"); @@ -832,11 +832,11 @@ public class StrBuilderTest { assertEquals("bcbccb", sb.toString()); sb.replaceAll("cb", "-"); assertEquals("b-c-", sb.toString()); - + sb = new StrBuilder("abcba"); sb.replaceAll("b", "xbx"); assertEquals("axbxcxbxa", sb.toString()); - + sb = new StrBuilder("bb"); sb.replaceAll("b", "xbx"); assertEquals("xbxxbx", sb.toString()); @@ -853,7 +853,7 @@ public class StrBuilderTest { assertEquals("abcbccba", sb.toString()); sb.replaceFirst("", "anything"); assertEquals("abcbccba", sb.toString()); - + sb.replaceFirst("x", "y"); assertEquals("abcbccba", sb.toString()); sb.replaceFirst("a", "d"); @@ -862,11 +862,11 @@ public class StrBuilderTest { assertEquals("bcbccba", sb.toString()); sb.replaceFirst("cb", "-"); assertEquals("b-ccba", sb.toString()); - + sb = new StrBuilder("abcba"); sb.replaceFirst("b", "xbx"); assertEquals("axbxcba", sb.toString()); - + sb = new StrBuilder("bb"); sb.replaceFirst("b", "xbx"); assertEquals("xbxb", sb.toString()); @@ -884,7 +884,7 @@ public class StrBuilderTest { assertEquals("abcbccba", sb.toString()); sb.replaceAll(StrMatcher.noneMatcher(), "anything"); assertEquals("abcbccba", sb.toString()); - + sb.replaceAll(StrMatcher.charMatcher('x'), "y"); assertEquals("abcbccba", sb.toString()); sb.replaceAll(StrMatcher.charMatcher('a'), "d"); @@ -893,15 +893,15 @@ public class StrBuilderTest { assertEquals("bcbccb", sb.toString()); sb.replaceAll(StrMatcher.stringMatcher("cb"), "-"); assertEquals("b-c-", sb.toString()); - + sb = new StrBuilder("abcba"); sb.replaceAll(StrMatcher.charMatcher('b'), "xbx"); assertEquals("axbxcxbxa", sb.toString()); - + sb = new StrBuilder("bb"); sb.replaceAll(StrMatcher.charMatcher('b'), "xbx"); assertEquals("xbxxbx", sb.toString()); - + sb = new StrBuilder("A1-A2A3-A4"); sb.replaceAll(A_NUMBER_MATCHER, "***"); assertEquals("***-******-***", sb.toString()); @@ -922,7 +922,7 @@ public class StrBuilderTest { assertEquals("abcbccba", sb.toString()); sb.replaceFirst(StrMatcher.noneMatcher(), "anything"); assertEquals("abcbccba", sb.toString()); - + sb.replaceFirst(StrMatcher.charMatcher('x'), "y"); assertEquals("abcbccba", sb.toString()); sb.replaceFirst(StrMatcher.charMatcher('a'), "d"); @@ -931,15 +931,15 @@ public class StrBuilderTest { assertEquals("bcbccba", sb.toString()); sb.replaceFirst(StrMatcher.stringMatcher("cb"), "-"); assertEquals("b-ccba", sb.toString()); - + sb = new StrBuilder("abcba"); sb.replaceFirst(StrMatcher.charMatcher('b'), "xbx"); assertEquals("axbxcba", sb.toString()); - + sb = new StrBuilder("bb"); sb.replaceFirst(StrMatcher.charMatcher('b'), "xbx"); assertEquals("xbxb", sb.toString()); - + sb = new StrBuilder("A1-A2A3-A4"); sb.replaceFirst(A_NUMBER_MATCHER, "***"); assertEquals("***-A2A3-A4", sb.toString()); @@ -951,17 +951,17 @@ public class StrBuilderTest { StrBuilder sb = new StrBuilder("abcbccba"); sb.replace(null, "x", 0, sb.length(), -1); assertEquals("abcbccba", sb.toString()); - + sb.replace(StrMatcher.charMatcher('a'), "x", 0, sb.length(), -1); assertEquals("xbcbccbx", sb.toString()); - + sb.replace(StrMatcher.stringMatcher("cb"), "x", 0, sb.length(), -1); assertEquals("xbxcxx", sb.toString()); - + sb = new StrBuilder("A1-A2A3-A4"); sb.replace(A_NUMBER_MATCHER, "***", 0, sb.length(), -1); assertEquals("***-******-***", sb.toString()); - + sb = new StrBuilder(); sb.replace(A_NUMBER_MATCHER, "***", 0, sb.length(), -1); assertEquals("", sb.toString()); @@ -972,19 +972,19 @@ public class StrBuilderTest { StrBuilder sb = new StrBuilder("abcbccba"); sb.replace(StrMatcher.stringMatcher("cb"), "cb", 0, sb.length(), -1); assertEquals("abcbccba", sb.toString()); - + sb = new StrBuilder("abcbccba"); sb.replace(StrMatcher.stringMatcher("cb"), "-", 0, sb.length(), -1); assertEquals("ab-c-a", sb.toString()); - + sb = new StrBuilder("abcbccba"); sb.replace(StrMatcher.stringMatcher("cb"), "+++", 0, sb.length(), -1); assertEquals("ab+++c+++a", sb.toString()); - + sb = new StrBuilder("abcbccba"); sb.replace(StrMatcher.stringMatcher("cb"), "", 0, sb.length(), -1); assertEquals("abca", sb.toString()); - + sb = new StrBuilder("abcbccba"); sb.replace(StrMatcher.stringMatcher("cb"), null, 0, sb.length(), -1); assertEquals("abca", sb.toString()); @@ -995,54 +995,54 @@ public class StrBuilderTest { StrBuilder sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, sb.length(), -1); assertEquals("-x--y-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 1, sb.length(), -1); assertEquals("aax--y-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 2, sb.length(), -1); assertEquals("aax--y-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 3, sb.length(), -1); assertEquals("aax--y-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 4, sb.length(), -1); assertEquals("aaxa-ay-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 5, sb.length(), -1); assertEquals("aaxaa-y-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 6, sb.length(), -1); assertEquals("aaxaaaay-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 7, sb.length(), -1); assertEquals("aaxaaaay-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 8, sb.length(), -1); assertEquals("aaxaaaay-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 9, sb.length(), -1); assertEquals("aaxaaaayaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 10, sb.length(), -1); assertEquals("aaxaaaayaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); try { sb.replace(StrMatcher.stringMatcher("aa"), "-", 11, sb.length(), -1); fail(); } catch (final IndexOutOfBoundsException ex) {} assertEquals("aaxaaaayaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); try { sb.replace(StrMatcher.stringMatcher("aa"), "-", -1, sb.length(), -1); @@ -1056,47 +1056,47 @@ public class StrBuilderTest { StrBuilder sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 0, -1); assertEquals("aaxaaaayaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 2, -1); assertEquals("-xaaaayaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 3, -1); assertEquals("-xaaaayaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 4, -1); assertEquals("-xaaaayaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 5, -1); assertEquals("-x-aayaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 6, -1); assertEquals("-x-aayaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 7, -1); assertEquals("-x--yaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 8, -1); assertEquals("-x--yaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 9, -1); assertEquals("-x--yaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 10, -1); assertEquals("-x--y-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 1000, -1); assertEquals("-x--y-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); try { sb.replace(StrMatcher.stringMatcher("aa"), "-", 2, 1, -1); @@ -1110,27 +1110,27 @@ public class StrBuilderTest { StrBuilder sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 10, -1); assertEquals("-x--y-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 10, 0); assertEquals("aaxaaaayaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 10, 1); assertEquals("-xaaaayaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 10, 2); assertEquals("-x-aayaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 10, 3); assertEquals("-x--yaa", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 10, 4); assertEquals("-x--y-", sb.toString()); - + sb = new StrBuilder("aaxaaaayaa"); sb.replace(StrMatcher.stringMatcher("aa"), "-", 0, 10, 5); assertEquals("-x--y-", sb.toString()); @@ -1141,7 +1141,7 @@ public class StrBuilderTest { public void testReverse() { final StrBuilder sb = new StrBuilder(); assertEquals("", sb.reverse().toString()); - + sb.clear().append(true); assertEquals("eurt", sb.reverse().toString()); assertEquals("true", sb.reverse().toString()); @@ -1152,19 +1152,19 @@ public class StrBuilderTest { public void testTrim() { final StrBuilder sb = new StrBuilder(); assertEquals("", sb.reverse().toString()); - + sb.clear().append(" \u0000 "); assertEquals("", sb.trim().toString()); - + sb.clear().append(" \u0000 a b c"); assertEquals("a b c", sb.trim().toString()); - + sb.clear().append("a b c \u0000 "); assertEquals("a b c", sb.trim().toString()); - + sb.clear().append(" \u0000 a b c \u0000 "); assertEquals("a b c", sb.trim().toString()); - + sb.clear().append("a b c"); assertEquals("a b c", sb.trim().toString()); } @@ -1209,25 +1209,25 @@ public class StrBuilderTest { sb.subSequence(-1, 5); fail(); } catch (final IndexOutOfBoundsException e) {} - + // End index is negative try { sb.subSequence(2, -1); fail(); } catch (final IndexOutOfBoundsException e) {} - + // End index greater than length() try { sb.subSequence(2, sb.length() + 1); fail(); } catch (final IndexOutOfBoundsException e) {} - + // Start index greater then end index try { sb.subSequence(3, 2); fail(); } catch (final IndexOutOfBoundsException e) {} - + // Normal cases assertEquals ("hello", sb.subSequence(0, 5)); assertEquals ("hello goodbye".subSequence(0, 6), sb.subSequence(0, 6)); @@ -1246,30 +1246,30 @@ public class StrBuilderTest { sb.substring(-1); fail (); } catch (final IndexOutOfBoundsException e) {} - + try { sb.substring(15); fail (); } catch (final IndexOutOfBoundsException e) {} - + } - + @Test public void testSubstringIntInt() { final StrBuilder sb = new StrBuilder ("hello goodbye"); assertEquals ("hello", sb.substring(0, 5)); 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 ("goodbye", sb.substring(6, 20)); - + try { sb.substring(-1, 5); fail(); } catch (final IndexOutOfBoundsException e) {} - + try { sb.substring(15, 20); fail(); @@ -1346,7 +1346,7 @@ public class StrBuilderTest { public void testIndexOf_char() { final StrBuilder sb = new StrBuilder("abab"); assertEquals(0, sb.indexOf('a')); - + // should work like String#indexOf assertEquals("abab".indexOf('a'), sb.indexOf('a')); @@ -1381,14 +1381,14 @@ public class StrBuilderTest { @Test public void testLastIndexOf_char() { final StrBuilder sb = new StrBuilder("abab"); - + assertEquals (2, sb.lastIndexOf('a')); //should work like String#lastIndexOf assertEquals ("abab".lastIndexOf('a'), sb.lastIndexOf('a')); - + assertEquals(3, sb.lastIndexOf('b')); assertEquals ("abab".lastIndexOf('b'), sb.lastIndexOf('b')); - + assertEquals (-1, sb.lastIndexOf('z')); } @@ -1416,23 +1416,23 @@ public class StrBuilderTest { @Test public void testIndexOf_String() { final StrBuilder sb = new StrBuilder("abab"); - + assertEquals(0, sb.indexOf("a")); //should work like String#indexOf assertEquals("abab".indexOf("a"), sb.indexOf("a")); - + assertEquals(0, sb.indexOf("ab")); //should work like String#indexOf assertEquals("abab".indexOf("ab"), sb.indexOf("ab")); - + assertEquals(1, sb.indexOf("b")); assertEquals("abab".indexOf("b"), sb.indexOf("b")); - + assertEquals(1, sb.indexOf("ba")); assertEquals("abab".indexOf("ba"), sb.indexOf("ba")); - + assertEquals(-1, sb.indexOf("z")); - + assertEquals(-1, sb.indexOf((String) null)); } @@ -1446,53 +1446,53 @@ public class StrBuilderTest { assertEquals(-1, sb.indexOf("a", 3)); assertEquals(-1, sb.indexOf("a", 4)); assertEquals(-1, sb.indexOf("a", 5)); - + assertEquals(-1, sb.indexOf("abcdef", 0)); assertEquals(0, sb.indexOf("", 0)); assertEquals(1, sb.indexOf("", 1)); - + //should work like String#indexOf assertEquals ("abab".indexOf("a", 1), sb.indexOf("a", 1)); - + assertEquals(2, sb.indexOf("ab", 1)); //should work like String#indexOf assertEquals("abab".indexOf("ab", 1), sb.indexOf("ab", 1)); - + assertEquals(3, sb.indexOf("b", 2)); assertEquals("abab".indexOf("b", 2), sb.indexOf("b", 2)); - + assertEquals(1, sb.indexOf("ba", 1)); assertEquals("abab".indexOf("ba", 2), sb.indexOf("ba", 2)); - + assertEquals(-1, sb.indexOf("z", 2)); - + sb = new StrBuilder("xyzabc"); assertEquals(2, sb.indexOf("za", 0)); assertEquals(-1, sb.indexOf("za", 3)); - + assertEquals(-1, sb.indexOf((String) null, 2)); } @Test public void testLastIndexOf_String() { final StrBuilder sb = new StrBuilder("abab"); - + assertEquals(2, sb.lastIndexOf("a")); //should work like String#lastIndexOf assertEquals("abab".lastIndexOf("a"), sb.lastIndexOf("a")); - + assertEquals(2, sb.lastIndexOf("ab")); //should work like String#lastIndexOf assertEquals("abab".lastIndexOf("ab"), sb.lastIndexOf("ab")); - + assertEquals(3, sb.lastIndexOf("b")); assertEquals("abab".lastIndexOf("b"), sb.lastIndexOf("b")); - + assertEquals(1, sb.lastIndexOf("ba")); assertEquals("abab".lastIndexOf("ba"), sb.lastIndexOf("ba")); - + assertEquals(-1, sb.lastIndexOf("z")); - + assertEquals(-1, sb.lastIndexOf((String) null)); } @@ -1506,30 +1506,30 @@ public class StrBuilderTest { assertEquals(2, sb.lastIndexOf("a", 3)); assertEquals(2, sb.lastIndexOf("a", 4)); assertEquals(2, sb.lastIndexOf("a", 5)); - + assertEquals(-1, sb.lastIndexOf("abcdef", 3)); assertEquals("abab".lastIndexOf("", 3), sb.lastIndexOf("", 3)); assertEquals("abab".lastIndexOf("", 1), sb.lastIndexOf("", 1)); - + //should work like String#lastIndexOf assertEquals("abab".lastIndexOf("a", 1), sb.lastIndexOf("a", 1)); - + assertEquals(0, sb.lastIndexOf("ab", 1)); //should work like String#lastIndexOf assertEquals("abab".lastIndexOf("ab", 1), sb.lastIndexOf("ab", 1)); - + assertEquals(1, sb.lastIndexOf("b", 2)); assertEquals("abab".lastIndexOf("b", 2), sb.lastIndexOf("b", 2)); - + assertEquals(1, sb.lastIndexOf("ba", 2)); assertEquals("abab".lastIndexOf("ba", 2), sb.lastIndexOf("ba", 2)); - + assertEquals(-1, sb.lastIndexOf("z", 2)); - + sb = new StrBuilder("xyzabc"); assertEquals(2, sb.lastIndexOf("za", sb.length())); assertEquals(-1, sb.lastIndexOf("za", 1)); - + assertEquals(-1, sb.lastIndexOf((String) null, 2)); } @@ -1539,7 +1539,7 @@ public class StrBuilderTest { final StrBuilder sb = new StrBuilder(); assertEquals(-1, sb.indexOf((StrMatcher) null)); assertEquals(-1, sb.indexOf(StrMatcher.charMatcher('a'))); - + sb.append("ab bd"); assertEquals(0, sb.indexOf(StrMatcher.charMatcher('a'))); assertEquals(1, sb.indexOf(StrMatcher.charMatcher('b'))); @@ -1547,7 +1547,7 @@ public class StrBuilderTest { assertEquals(4, sb.indexOf(StrMatcher.charMatcher('d'))); assertEquals(-1, sb.indexOf(StrMatcher.noneMatcher())); assertEquals(-1, sb.indexOf((StrMatcher) null)); - + sb.append(" A1 junction"); assertEquals(6, sb.indexOf(A_NUMBER_MATCHER)); } @@ -1558,13 +1558,13 @@ public class StrBuilderTest { assertEquals(-1, sb.indexOf((StrMatcher) null, 2)); assertEquals(-1, sb.indexOf(StrMatcher.charMatcher('a'), 2)); assertEquals(-1, sb.indexOf(StrMatcher.charMatcher('a'), 0)); - + sb.append("ab bd"); assertEquals(0, sb.indexOf(StrMatcher.charMatcher('a'), -2)); assertEquals(0, sb.indexOf(StrMatcher.charMatcher('a'), 0)); assertEquals(-1, sb.indexOf(StrMatcher.charMatcher('a'), 2)); assertEquals(-1, sb.indexOf(StrMatcher.charMatcher('a'), 20)); - + assertEquals(1, sb.indexOf(StrMatcher.charMatcher('b'), -1)); assertEquals(1, sb.indexOf(StrMatcher.charMatcher('b'), 0)); assertEquals(1, sb.indexOf(StrMatcher.charMatcher('b'), 1)); @@ -1573,16 +1573,16 @@ public class StrBuilderTest { assertEquals(-1, sb.indexOf(StrMatcher.charMatcher('b'), 4)); assertEquals(-1, sb.indexOf(StrMatcher.charMatcher('b'), 5)); assertEquals(-1, sb.indexOf(StrMatcher.charMatcher('b'), 6)); - + assertEquals(2, sb.indexOf(StrMatcher.spaceMatcher(), -2)); assertEquals(2, sb.indexOf(StrMatcher.spaceMatcher(), 0)); assertEquals(2, sb.indexOf(StrMatcher.spaceMatcher(), 2)); assertEquals(-1, sb.indexOf(StrMatcher.spaceMatcher(), 4)); assertEquals(-1, sb.indexOf(StrMatcher.spaceMatcher(), 20)); - + assertEquals(-1, sb.indexOf(StrMatcher.noneMatcher(), 0)); assertEquals(-1, sb.indexOf((StrMatcher) null, 0)); - + sb.append(" A1 junction with A2"); assertEquals(6, sb.indexOf(A_NUMBER_MATCHER, 5)); assertEquals(6, sb.indexOf(A_NUMBER_MATCHER, 6)); @@ -1597,7 +1597,7 @@ public class StrBuilderTest { final StrBuilder sb = new StrBuilder(); assertEquals(-1, sb.lastIndexOf((StrMatcher) null)); assertEquals(-1, sb.lastIndexOf(StrMatcher.charMatcher('a'))); - + sb.append("ab bd"); assertEquals(0, sb.lastIndexOf(StrMatcher.charMatcher('a'))); assertEquals(3, sb.lastIndexOf(StrMatcher.charMatcher('b'))); @@ -1605,7 +1605,7 @@ public class StrBuilderTest { assertEquals(4, sb.lastIndexOf(StrMatcher.charMatcher('d'))); assertEquals(-1, sb.lastIndexOf(StrMatcher.noneMatcher())); assertEquals(-1, sb.lastIndexOf((StrMatcher) null)); - + sb.append(" A1 junction"); assertEquals(6, sb.lastIndexOf(A_NUMBER_MATCHER)); } @@ -1617,13 +1617,13 @@ public class StrBuilderTest { assertEquals(-1, sb.lastIndexOf(StrMatcher.charMatcher('a'), 2)); assertEquals(-1, sb.lastIndexOf(StrMatcher.charMatcher('a'), 0)); assertEquals(-1, sb.lastIndexOf(StrMatcher.charMatcher('a'), -1)); - + sb.append("ab bd"); assertEquals(-1, sb.lastIndexOf(StrMatcher.charMatcher('a'), -2)); assertEquals(0, sb.lastIndexOf(StrMatcher.charMatcher('a'), 0)); assertEquals(0, sb.lastIndexOf(StrMatcher.charMatcher('a'), 2)); assertEquals(0, sb.lastIndexOf(StrMatcher.charMatcher('a'), 20)); - + assertEquals(-1, sb.lastIndexOf(StrMatcher.charMatcher('b'), -1)); assertEquals(-1, sb.lastIndexOf(StrMatcher.charMatcher('b'), 0)); assertEquals(1, sb.lastIndexOf(StrMatcher.charMatcher('b'), 1)); @@ -1632,16 +1632,16 @@ public class StrBuilderTest { assertEquals(3, sb.lastIndexOf(StrMatcher.charMatcher('b'), 4)); assertEquals(3, sb.lastIndexOf(StrMatcher.charMatcher('b'), 5)); assertEquals(3, sb.lastIndexOf(StrMatcher.charMatcher('b'), 6)); - + assertEquals(-1, sb.lastIndexOf(StrMatcher.spaceMatcher(), -2)); assertEquals(-1, sb.lastIndexOf(StrMatcher.spaceMatcher(), 0)); assertEquals(2, sb.lastIndexOf(StrMatcher.spaceMatcher(), 2)); assertEquals(2, sb.lastIndexOf(StrMatcher.spaceMatcher(), 4)); assertEquals(2, sb.lastIndexOf(StrMatcher.spaceMatcher(), 20)); - + assertEquals(-1, sb.lastIndexOf(StrMatcher.noneMatcher(), 0)); assertEquals(-1, sb.lastIndexOf((StrMatcher) null, 0)); - + sb.append(" A1 junction with A2"); assertEquals(-1, sb.lastIndexOf(A_NUMBER_MATCHER, 5)); assertEquals(-1, sb.lastIndexOf(A_NUMBER_MATCHER, 6)); // A matches, 1 is outside bounds @@ -1671,13 +1671,13 @@ public class StrBuilderTest { final StrBuilder b = new StrBuilder(); b.append("a b "); final StrTokenizer t = b.asTokenizer(); - + final String[] tokens1 = t.getTokenArray(); assertEquals(2, tokens1.length); assertEquals("a", tokens1[0]); assertEquals("b", tokens1[1]); assertEquals(2, t.size()); - + b.append("c d "); final String[] tokens2 = t.getTokenArray(); assertEquals(2, tokens2.length); @@ -1686,7 +1686,7 @@ public class StrBuilderTest { assertEquals(2, t.size()); assertEquals("a", t.next()); assertEquals("b", t.next()); - + t.reset(); final String[] tokens3 = t.getTokenArray(); assertEquals(4, tokens3.length); @@ -1699,7 +1699,7 @@ public class StrBuilderTest { assertEquals("b", t.next()); assertEquals("c", t.next()); assertEquals("d", t.next()); - + assertEquals("a b c d ", t.getContent()); } @@ -1712,12 +1712,12 @@ public class StrBuilderTest { final char[] buf = new char[40]; assertEquals(9, reader.read(buf)); assertEquals("some text", new String(buf, 0, 9)); - + assertEquals(-1, reader.read()); assertFalse(reader.ready()); assertEquals(0, reader.skip(2)); assertEquals(0, reader.skip(-1)); - + assertTrue(reader.markSupported()); reader = sb.asReader(); assertEquals('s', reader.read()); @@ -1734,11 +1734,11 @@ public class StrBuilderTest { assertEquals('e', array[2]); assertEquals(2, reader.skip(2)); assertEquals(' ', reader.read()); - + assertTrue(reader.ready()); reader.close(); assertTrue(reader.ready()); - + reader = sb.asReader(); array = new char[3]; try { @@ -1761,15 +1761,15 @@ public class StrBuilderTest { reader.read(array, Integer.MAX_VALUE, Integer.MAX_VALUE); fail(); } catch (final IndexOutOfBoundsException ex) {} - + assertEquals(0, reader.read(array, 0, 0)); assertEquals(0, array[0]); assertEquals(0, array[1]); assertEquals(0, array[2]); - + reader.skip(9); assertEquals(-1, reader.read(array, 0, 1)); - + reader.reset(); array = new char[30]; assertEquals(9, reader.read(array, 0, 30)); @@ -1780,31 +1780,31 @@ public class StrBuilderTest { public void testAsWriter() throws Exception { final StrBuilder sb = new StrBuilder("base"); final Writer writer = sb.asWriter(); - + writer.write('l'); assertEquals("basel", sb.toString()); - + writer.write(new char[] {'i', 'n'}); assertEquals("baselin", sb.toString()); - + writer.write(new char[] {'n', 'e', 'r'}, 1, 2); assertEquals("baseliner", sb.toString()); - + writer.write(" rout"); assertEquals("baseliner rout", sb.toString()); - + writer.write("ping that server", 1, 3); assertEquals("baseliner routing", sb.toString()); - + writer.flush(); // no effect assertEquals("baseliner routing", sb.toString()); - + writer.close(); // no effect assertEquals("baseliner routing", sb.toString()); - + writer.write(" hi"); // works after close assertEquals("baseliner routing hi", sb.toString()); - + sb.setLength(4); // mix and match writer.write('d'); assertEquals("based", sb.toString()); @@ -1818,18 +1818,18 @@ public class StrBuilderTest { assertTrue(sb1.equalsIgnoreCase(sb1)); assertTrue(sb1.equalsIgnoreCase(sb2)); assertTrue(sb2.equalsIgnoreCase(sb2)); - + sb1.append("abc"); assertFalse(sb1.equalsIgnoreCase(sb2)); - + sb2.append("ABC"); assertTrue(sb1.equalsIgnoreCase(sb2)); - + sb2.clear().append("abc"); assertTrue(sb1.equalsIgnoreCase(sb2)); assertTrue(sb1.equalsIgnoreCase(sb1)); assertTrue(sb2.equalsIgnoreCase(sb2)); - + sb2.clear().append("aBc"); assertTrue(sb1.equalsIgnoreCase(sb2)); } @@ -1843,19 +1843,19 @@ public class StrBuilderTest { assertTrue(sb1.equals(sb1)); assertTrue(sb2.equals(sb2)); assertTrue(sb1.equals((Object) sb2)); - + sb1.append("abc"); assertFalse(sb1.equals(sb2)); assertFalse(sb1.equals((Object) sb2)); - + sb2.append("ABC"); assertFalse(sb1.equals(sb2)); assertFalse(sb1.equals((Object) sb2)); - + sb2.clear().append("abc"); assertTrue(sb1.equals(sb2)); assertTrue(sb1.equals((Object) sb2)); - + assertFalse(sb1.equals(Integer.valueOf(1))); assertFalse(sb1.equals("abc")); } @@ -1875,7 +1875,7 @@ public class StrBuilderTest { final int hc1b = sb.hashCode(); assertEquals(0, hc1a); assertEquals(hc1a, hc1b); - + sb.append("abc"); final int hc2a = sb.hashCode(); final int hc2b = sb.hashCode(); @@ -1895,7 +1895,7 @@ public class StrBuilderTest { public void testToStringBuffer() { final StrBuilder sb = new StrBuilder(); assertEquals(new StringBuffer().toString(), sb.toStringBuffer().toString()); - + sb.append("junit"); assertEquals(new StringBuffer("junit").toString(), sb.toStringBuffer().toString()); } @@ -1905,7 +1905,7 @@ public class StrBuilderTest { public void testToStringBuilder() { final StrBuilder sb = new StrBuilder(); assertEquals(new StringBuilder().toString(), sb.toStringBuilder().toString()); - + sb.append("junit"); assertEquals(new StringBuilder("junit").toString(), sb.toStringBuilder().toString()); } @@ -1915,7 +1915,7 @@ public class StrBuilderTest { public void testLang294() { final StrBuilder sb = new StrBuilder("\n%BLAH%\nDo more stuff\neven more stuff\n%BLAH%\n"); sb.deleteAll("\n%BLAH%"); - assertEquals("\nDo more stuff\neven more stuff\n", sb.toString()); + assertEquals("\nDo more stuff\neven more stuff\n", sb.toString()); } @Test diff --git a/src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java b/src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java index 1b286ebe1..c26f22e85 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrMatcherTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java b/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java index d9afde2f6..7325b7acf 100644 --- a/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java +++ b/src/test/java/org/apache/commons/lang3/text/StrTokenizerTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -506,7 +506,7 @@ public class StrTokenizerTest { final StrTokenizer tok = new StrTokenizer(input); final String[] array = tok.getTokenArray(); final List<?> list = tok.getTokenList(); - + assertEquals(Arrays.asList(array), list); assertEquals(3, list.size()); } @@ -555,7 +555,7 @@ public class StrTokenizerTest { tok = new StrTokenizer(input.toCharArray()); assertEquals(input, tok.getContent()); - + tok = new StrTokenizer(); assertEquals(null, tok.getContent()); } @@ -623,7 +623,7 @@ public class StrTokenizerTest { assertEquals("b", tokenizer.nextToken()); assertEquals("a", clonedTokenizer.nextToken()); } - + // ----------------------------------------------------------------------- @Test public void testConstructor_String() { @@ -631,10 +631,10 @@ public class StrTokenizerTest { assertEquals("a", tok.next()); assertEquals("b", tok.next()); assertFalse(tok.hasNext()); - + tok = new StrTokenizer(""); assertFalse(tok.hasNext()); - + tok = new StrTokenizer((String) null); assertFalse(tok.hasNext()); } @@ -647,10 +647,10 @@ public class StrTokenizerTest { assertEquals("a", tok.next()); assertEquals("b", tok.next()); assertFalse(tok.hasNext()); - + tok = new StrTokenizer("", ' '); assertFalse(tok.hasNext()); - + tok = new StrTokenizer((String) null, ' '); assertFalse(tok.hasNext()); } @@ -664,10 +664,10 @@ public class StrTokenizerTest { assertEquals("a", tok.next()); assertEquals("b", tok.next()); assertFalse(tok.hasNext()); - + tok = new StrTokenizer("", ' ', '"'); assertFalse(tok.hasNext()); - + tok = new StrTokenizer((String) null, ' ', '"'); assertFalse(tok.hasNext()); } @@ -679,10 +679,10 @@ public class StrTokenizerTest { assertEquals("a", tok.next()); assertEquals("b", tok.next()); assertFalse(tok.hasNext()); - + tok = new StrTokenizer(new char[0]); assertFalse(tok.hasNext()); - + tok = new StrTokenizer((char[]) null); assertFalse(tok.hasNext()); } @@ -695,10 +695,10 @@ public class StrTokenizerTest { assertEquals("a", tok.next()); assertEquals("b", tok.next()); assertFalse(tok.hasNext()); - + tok = new StrTokenizer(new char[0], ' '); assertFalse(tok.hasNext()); - + tok = new StrTokenizer((char[]) null, ' '); assertFalse(tok.hasNext()); } @@ -712,10 +712,10 @@ public class StrTokenizerTest { assertEquals("a", tok.next()); assertEquals("b", tok.next()); assertFalse(tok.hasNext()); - + tok = new StrTokenizer(new char[0], ' ', '"'); assertFalse(tok.hasNext()); - + tok = new StrTokenizer((char[]) null, ' ', '"'); assertFalse(tok.hasNext()); } @@ -728,7 +728,7 @@ public class StrTokenizerTest { assertEquals("b", tok.next()); assertEquals("c", tok.next()); assertFalse(tok.hasNext()); - + tok.reset(); assertEquals("a", tok.next()); assertEquals("b", tok.next()); @@ -744,7 +744,7 @@ public class StrTokenizerTest { assertEquals("d", tok.next()); assertEquals("e", tok.next()); assertFalse(tok.hasNext()); - + tok.reset((String) null); assertFalse(tok.hasNext()); } @@ -753,12 +753,12 @@ public class StrTokenizerTest { @Test public void testReset_charArray() { final StrTokenizer tok = new StrTokenizer("x x x"); - + final char[] array = new char[] {'a', 'b', 'c'}; tok.reset(array); assertEquals("abc", tok.next()); assertFalse(tok.hasNext()); - + tok.reset((char[]) null); assertFalse(tok.hasNext()); } @@ -810,7 +810,7 @@ public class StrTokenizerTest { fail(); } catch (final NoSuchElementException ex) {} assertTrue(tkn.hasNext()); - + assertEquals("a", tkn.next()); try { tkn.remove(); @@ -826,15 +826,15 @@ public class StrTokenizerTest { } catch (final UnsupportedOperationException ex) {} assertTrue(tkn.hasPrevious()); assertTrue(tkn.hasNext()); - + assertEquals("b", tkn.next()); assertTrue(tkn.hasPrevious()); assertTrue(tkn.hasNext()); - + assertEquals("c", tkn.next()); assertTrue(tkn.hasPrevious()); assertFalse(tkn.hasNext()); - + try { tkn.next(); fail(); diff --git a/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java b/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java index 370e7547d..32cf99af1 100644 --- a/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/text/WordUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -42,32 +42,32 @@ public class WordUtilsTest { assertTrue(Modifier.isPublic(WordUtils.class.getModifiers())); assertFalse(Modifier.isFinal(WordUtils.class.getModifiers())); } - + //----------------------------------------------------------------------- @Test public void testWrap_StringInt() { assertEquals(null, WordUtils.wrap(null, 20)); assertEquals(null, WordUtils.wrap(null, -1)); - + assertEquals("", WordUtils.wrap("", 20)); assertEquals("", WordUtils.wrap("", -1)); - + // normal final String systemNewLine = System.lineSeparator(); String input = "Here is one line of text that is going to be wrapped after 20 columns."; - String expected = "Here is one line of" + systemNewLine + "text that is going" + String expected = "Here is one line of" + systemNewLine + "text that is going" + systemNewLine + "to be wrapped after" + systemNewLine + "20 columns."; assertEquals(expected, WordUtils.wrap(input, 20)); - + // long word at end input = "Click here to jump to the commons website - http://commons.apache.org"; - expected = "Click here to jump" + systemNewLine + "to the commons" + systemNewLine + expected = "Click here to jump" + systemNewLine + "to the commons" + systemNewLine + "website -" + systemNewLine + "http://commons.apache.org"; assertEquals(expected, WordUtils.wrap(input, 20)); - + // long word in middle input = "Click here, http://commons.apache.org, to jump to the commons website"; - expected = "Click here," + systemNewLine + "http://commons.apache.org," + systemNewLine + expected = "Click here," + systemNewLine + "http://commons.apache.org," + systemNewLine + "to jump to the" + systemNewLine + "commons website"; assertEquals(expected, WordUtils.wrap(input, 20)); @@ -77,7 +77,7 @@ public class WordUtilsTest { expected = "word1 " + systemNewLine + "word2 " + systemNewLine + "word3"; assertEquals(expected, WordUtils.wrap(input, 7)); } - + @Test public void testWrap_StringIntStringBoolean() { assertEquals(null, WordUtils.wrap(null, 20, "\n", false)); @@ -86,14 +86,14 @@ public class WordUtilsTest { assertEquals(null, WordUtils.wrap(null, 20, null, false)); assertEquals(null, WordUtils.wrap(null, -1, null, true)); assertEquals(null, WordUtils.wrap(null, -1, null, false)); - + assertEquals("", WordUtils.wrap("", 20, "\n", false)); assertEquals("", WordUtils.wrap("", 20, "\n", true)); assertEquals("", WordUtils.wrap("", 20, null, false)); assertEquals("", WordUtils.wrap("", 20, null, true)); assertEquals("", WordUtils.wrap("", -1, null, false)); assertEquals("", WordUtils.wrap("", -1, null, true)); - + // normal String input = "Here is one line of text that is going to be wrapped after 20 columns."; String expected = "Here is one line of\ntext that is going\nto be wrapped after\n20 columns."; @@ -117,7 +117,7 @@ public class WordUtilsTest { // system newline char final String systemNewLine = System.lineSeparator(); input = "Here is one line of text that is going to be wrapped after 20 columns."; - expected = "Here is one line of" + systemNewLine + "text that is going" + systemNewLine + expected = "Here is one line of" + systemNewLine + "text that is going" + systemNewLine + "to be wrapped after" + systemNewLine + "20 columns."; assertEquals(expected, WordUtils.wrap(input, 20, null, false)); assertEquals(expected, WordUtils.wrap(input, 20, null, true)); @@ -127,26 +127,26 @@ public class WordUtilsTest { expected = "Here: is one line\nof text that is \ngoing to be \nwrapped after 20 \ncolumns."; assertEquals(expected, WordUtils.wrap(input, 20, "\n", false)); assertEquals(expected, WordUtils.wrap(input, 20, "\n", true)); - + // with tab input = "Here is\tone line of text that is going to be wrapped after 20 columns."; expected = "Here is\tone line of\ntext that is going\nto be wrapped after\n20 columns."; assertEquals(expected, WordUtils.wrap(input, 20, "\n", false)); assertEquals(expected, WordUtils.wrap(input, 20, "\n", true)); - + // with tab at wrapColumn input = "Here is one line of\ttext that is going to be wrapped after 20 columns."; expected = "Here is one line\nof\ttext that is\ngoing to be wrapped\nafter 20 columns."; assertEquals(expected, WordUtils.wrap(input, 20, "\n", false)); assertEquals(expected, WordUtils.wrap(input, 20, "\n", true)); - + // difference because of long word input = "Click here to jump to the commons website - http://commons.apache.org"; expected = "Click here to jump\nto the commons\nwebsite -\nhttp://commons.apache.org"; assertEquals(expected, WordUtils.wrap(input, 20, "\n", false)); expected = "Click here to jump\nto the commons\nwebsite -\nhttp://commons.apach\ne.org"; assertEquals(expected, WordUtils.wrap(input, 20, "\n", true)); - + // difference because of long word in middle input = "Click here, http://commons.apache.org, to jump to the commons website"; expected = "Click here,\nhttp://commons.apache.org,\nto jump to the\ncommons website"; @@ -187,7 +187,7 @@ public class WordUtilsTest { assertEquals(null, WordUtils.capitalize(null)); assertEquals("", WordUtils.capitalize("")); assertEquals(" ", WordUtils.capitalize(" ")); - + assertEquals("I", WordUtils.capitalize("I") ); assertEquals("I", WordUtils.capitalize("i") ); assertEquals("I Am Here 123", WordUtils.capitalize("i am here 123") ); @@ -195,13 +195,13 @@ public class WordUtilsTest { assertEquals("I Am HERE 123", WordUtils.capitalize("i am HERE 123") ); assertEquals("I AM HERE 123", WordUtils.capitalize("I AM HERE 123") ); } - + @Test public void testCapitalizeWithDelimiters_String() { assertEquals(null, WordUtils.capitalize(null, null)); assertEquals("", WordUtils.capitalize("", new char[0])); assertEquals(" ", WordUtils.capitalize(" ", new char[0])); - + char[] chars = new char[] { '-', '+', ' ', '@' }; assertEquals("I", WordUtils.capitalize("I", chars) ); assertEquals("I", WordUtils.capitalize("i", chars) ); @@ -219,7 +219,7 @@ public class WordUtilsTest { assertEquals(null, WordUtils.capitalizeFully(null)); assertEquals("", WordUtils.capitalizeFully("")); assertEquals(" ", WordUtils.capitalizeFully(" ")); - + assertEquals("I", WordUtils.capitalizeFully("I") ); assertEquals("I", WordUtils.capitalizeFully("i") ); assertEquals("I Am Here 123", WordUtils.capitalizeFully("i am here 123") ); @@ -227,13 +227,13 @@ public class WordUtilsTest { assertEquals("I Am Here 123", WordUtils.capitalizeFully("i am HERE 123") ); assertEquals("I Am Here 123", WordUtils.capitalizeFully("I AM HERE 123") ); } - + @Test public void testCapitalizeFullyWithDelimiters_String() { assertEquals(null, WordUtils.capitalizeFully(null, null)); assertEquals("", WordUtils.capitalizeFully("", new char[0])); assertEquals(" ", WordUtils.capitalizeFully(" ", new char[0])); - + char[] chars = new char[] { '-', '+', ' ', '@' }; assertEquals("I", WordUtils.capitalizeFully("I", chars) ); assertEquals("I", WordUtils.capitalizeFully("i", chars) ); @@ -271,7 +271,7 @@ public class WordUtilsTest { assertEquals(null, WordUtils.uncapitalize(null)); assertEquals("", WordUtils.uncapitalize("")); assertEquals(" ", WordUtils.uncapitalize(" ")); - + assertEquals("i", WordUtils.uncapitalize("I") ); assertEquals("i", WordUtils.uncapitalize("i") ); assertEquals("i am here 123", WordUtils.uncapitalize("i am here 123") ); @@ -279,13 +279,13 @@ public class WordUtilsTest { assertEquals("i am hERE 123", WordUtils.uncapitalize("i am HERE 123") ); assertEquals("i aM hERE 123", WordUtils.uncapitalize("I AM HERE 123") ); } - + @Test public void testUncapitalizeWithDelimiters_String() { assertEquals(null, WordUtils.uncapitalize(null, null)); assertEquals("", WordUtils.uncapitalize("", new char[0])); assertEquals(" ", WordUtils.uncapitalize(" ", new char[0])); - + char[] chars = new char[] { '-', '+', ' ', '@' }; assertEquals("i", WordUtils.uncapitalize("I", chars) ); assertEquals("i", WordUtils.uncapitalize("i", chars) ); @@ -330,7 +330,7 @@ public class WordUtilsTest { assertEquals("BJ.L", WordUtils.initials(" Ben John . Lee", array)); assertEquals("KO", WordUtils.initials("Kay O'Murphy", array)); assertEquals("iah1", WordUtils.initials("i am here 123", array)); - + array = new char[0]; assertEquals(null, WordUtils.initials(null, array)); assertEquals("", WordUtils.initials("", array)); @@ -344,7 +344,7 @@ public class WordUtilsTest { assertEquals("", WordUtils.initials(" Ben John . Lee", array)); assertEquals("", WordUtils.initials("Kay O'Murphy", array)); assertEquals("", WordUtils.initials("i am here 123", array)); - + array = " ".toCharArray(); assertEquals(null, WordUtils.initials(null, array)); assertEquals("", WordUtils.initials("", array)); @@ -358,7 +358,7 @@ public class WordUtilsTest { assertEquals("BJ.L", WordUtils.initials(" Ben John . Lee", array)); assertEquals("KO", WordUtils.initials("Kay O'Murphy", array)); assertEquals("iah1", WordUtils.initials("i am here 123", array)); - + array = " .".toCharArray(); assertEquals(null, WordUtils.initials(null, array)); assertEquals("", WordUtils.initials("", array)); @@ -371,7 +371,7 @@ public class WordUtilsTest { assertEquals("BJL", WordUtils.initials(" Ben John . Lee", array)); assertEquals("KO", WordUtils.initials("Kay O'Murphy", array)); assertEquals("iah1", WordUtils.initials("i am here 123", array)); - + array = " .'".toCharArray(); assertEquals(null, WordUtils.initials(null, array)); assertEquals("", WordUtils.initials("", array)); @@ -384,7 +384,7 @@ public class WordUtilsTest { assertEquals("BJL", WordUtils.initials(" Ben John . Lee", array)); assertEquals("KOM", WordUtils.initials("Kay O'Murphy", array)); assertEquals("iah1", WordUtils.initials("i am here 123", array)); - + array = "SIJo1".toCharArray(); assertEquals(null, WordUtils.initials(null, array)); assertEquals("", WordUtils.initials("", array)); @@ -405,7 +405,7 @@ public class WordUtilsTest { assertEquals(null, WordUtils.swapCase(null)); assertEquals("", WordUtils.swapCase("")); assertEquals(" ", WordUtils.swapCase(" ")); - + assertEquals("i", WordUtils.swapCase("I") ); assertEquals("I", WordUtils.swapCase("i") ); assertEquals("I AM HERE 123", WordUtils.swapCase("i am here 123") ); @@ -417,7 +417,7 @@ public class WordUtilsTest { final String expect = "tHIS sTRING CONTAINS A tITLEcASE CHARACTER: \u01C9"; assertEquals(expect, WordUtils.swapCase(test)); } - + @Test public void testLANG1292() throws Exception { // Prior to fix, this was throwing StringIndexOutOfBoundsException diff --git a/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java b/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java index 74e81d6a8..7cb65f88d 100644 --- a/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java +++ b/src/test/java/org/apache/commons/lang3/text/translate/EntityArraysTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -34,7 +34,7 @@ public class EntityArraysTest { public void testConstructorExists() { new EntityArrays(); } - + // LANG-659 - check arrays for duplicate entries @Test public void testHTML40_EXTENDED_ESCAPE(){ @@ -46,7 +46,7 @@ public class EntityArraysTest { assertTrue("Already added entry 1: "+i+" "+sa[i][1],col1.add(sa[i][1])); } } - + // LANG-658 - check arrays for duplicate entries @Test public void testISO8859_1_ESCAPE(){ @@ -57,7 +57,7 @@ public class EntityArraysTest { 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) { + if (!add0) { success = false; System.out.println("Already added entry 0: "+i+" "+sa[i][0]+" "+sa[i][1]); } @@ -68,6 +68,6 @@ public class EntityArraysTest { } assertTrue("One or more errors detected",success); } - - + + } diff --git a/src/test/java/org/apache/commons/lang3/text/translate/LookupTranslatorTest.java b/src/test/java/org/apache/commons/lang3/text/translate/LookupTranslatorTest.java index a53f77722..e9368780d 100644 --- a/src/test/java/org/apache/commons/lang3/text/translate/LookupTranslatorTest.java +++ b/src/test/java/org/apache/commons/lang3/text/translate/LookupTranslatorTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityEscaperTest.java b/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityEscaperTest.java index 9c0594bbc..7db8fb742 100644 --- a/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityEscaperTest.java +++ b/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityEscaperTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaperTest.java b/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaperTest.java index 07c184156..18f81c635 100644 --- a/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaperTest.java +++ b/src/test/java/org/apache/commons/lang3/text/translate/NumericEntityUnescaperTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java b/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java index cbe80f3c2..c879f5f1a 100644 --- a/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java +++ b/src/test/java/org/apache/commons/lang3/text/translate/OctalUnescaperTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/text/translate/UnicodeEscaperTest.java b/src/test/java/org/apache/commons/lang3/text/translate/UnicodeEscaperTest.java index e5ca40902..700607455 100644 --- a/src/test/java/org/apache/commons/lang3/text/translate/UnicodeEscaperTest.java +++ b/src/test/java/org/apache/commons/lang3/text/translate/UnicodeEscaperTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java b/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java index 5ab67526a..a0ec693b6 100644 --- a/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java +++ b/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnescaperTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnpairedSurrogateRemoverTest.java b/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnpairedSurrogateRemoverTest.java index 457aa9bd8..fc8991166 100644 --- a/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnpairedSurrogateRemoverTest.java +++ b/src/test/java/org/apache/commons/lang3/text/translate/UnicodeUnpairedSurrogateRemoverTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -29,14 +29,14 @@ import org.junit.Test; public class UnicodeUnpairedSurrogateRemoverTest { final UnicodeUnpairedSurrogateRemover subject = new UnicodeUnpairedSurrogateRemover(); final CharArrayWriter writer = new CharArrayWriter(); // nothing is ever written to it - + @Test public void testValidCharacters() throws IOException { assertEquals(false, subject.translate(0xd7ff, writer)); assertEquals(false, subject.translate(0xe000, writer)); assertEquals(0, writer.size()); } - + @Test public void testInvalidCharacters() throws IOException { assertEquals(true, subject.translate(0xd800, writer)); diff --git a/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java index 0ae29ecdf..f19797423 100644 --- a/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/time/DateFormatUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -42,7 +42,7 @@ public class DateFormatUtilsTest { @Rule public SystemDefaultsSwitch defaults = new SystemDefaultsSwitch(); - + //----------------------------------------------------------------------- @Test public void testConstructor() { @@ -53,7 +53,7 @@ public class DateFormatUtilsTest { assertTrue(Modifier.isPublic(DateFormatUtils.class.getModifiers())); assertFalse(Modifier.isFinal(DateFormatUtils.class.getModifiers())); } - + //----------------------------------------------------------------------- @Test public void testFormat() { @@ -70,14 +70,14 @@ public class DateFormatUtilsTest { buffer.append(day); buffer.append(hour); assertEquals(buffer.toString(), DateFormatUtils.format(c.getTime(), "yyyyMdH")); - + assertEquals(buffer.toString(), DateFormatUtils.format(c.getTime().getTime(), "yyyyMdH")); - + assertEquals(buffer.toString(), DateFormatUtils.format(c.getTime(), "yyyyMdH", Locale.US)); - + assertEquals(buffer.toString(), DateFormatUtils.format(c.getTime().getTime(), "yyyyMdH", Locale.US)); } - + //----------------------------------------------------------------------- @Test public void testFormatCalendar() { @@ -94,24 +94,24 @@ public class DateFormatUtilsTest { buffer.append(day); buffer.append(hour); assertEquals(buffer.toString(), DateFormatUtils.format(c, "yyyyMdH")); - + assertEquals(buffer.toString(), DateFormatUtils.format(c.getTime(), "yyyyMdH")); - + assertEquals(buffer.toString(), DateFormatUtils.format(c, "yyyyMdH", Locale.US)); - + assertEquals(buffer.toString(), DateFormatUtils.format(c.getTime(), "yyyyMdH", Locale.US)); } - + @Test public void testFormatUTC() { final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC")); c.set(2005, Calendar.JANUARY, 1, 12, 0, 0); assertEquals ("2005-01-01T12:00:00", DateFormatUtils.formatUTC(c.getTime(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern())); - + assertEquals ("2005-01-01T12:00:00", DateFormatUtils.formatUTC(c.getTime().getTime(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern())); - + assertEquals ("2005-01-01T12:00:00", DateFormatUtils.formatUTC(c.getTime(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern(), Locale.US)); - + assertEquals ("2005-01-01T12:00:00", DateFormatUtils.formatUTC(c.getTime().getTime(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern(), Locale.US)); } @@ -142,7 +142,7 @@ public class DateFormatUtilsTest { final TimeZone timeZone = TimeZone.getTimeZone("UTC"); assertFormats(expectedValue, pattern, timeZone, createFebruaryTestDate(timeZone)); } - + @Test public void testDateTimeISO() throws Exception { testGmtMinus3("2002-02-23T09:11:12", DateFormatUtils.ISO_DATETIME_FORMAT.getPattern()); diff --git a/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java b/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java index 519c9d2d0..7a9e114b5 100644 --- a/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java +++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsFragmentTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -44,7 +44,7 @@ public class DateUtilsFragmentTest { aCalendar.set(Calendar.MILLISECOND, millis); aDate = aCalendar.getTime(); } - + @Test public void testNullDate() { try { @@ -100,7 +100,7 @@ public class DateUtilsFragmentTest { fail(); } catch(final IllegalArgumentException iae) {} } - + @Test public void testInvalidFragmentWithDate() { try { @@ -174,7 +174,7 @@ public class DateUtilsFragmentTest { assertEquals(0, DateUtils.getFragmentInHours(aCalendar, Calendar.MILLISECOND)); assertEquals(0, DateUtils.getFragmentInDays(aCalendar, Calendar.MILLISECOND)); } - + @Test public void testSecondFragmentInLargerUnitWithDate() { assertEquals(0, DateUtils.getFragmentInSeconds(aDate, Calendar.SECOND)); @@ -190,7 +190,7 @@ public class DateUtilsFragmentTest { assertEquals(0, DateUtils.getFragmentInHours(aCalendar, Calendar.SECOND)); assertEquals(0, DateUtils.getFragmentInDays(aCalendar, Calendar.SECOND)); } - + @Test public void testMinuteFragmentInLargerUnitWithDate() { assertEquals(0, DateUtils.getFragmentInMinutes(aDate, Calendar.MINUTE)); @@ -238,7 +238,7 @@ public class DateUtilsFragmentTest { } //Calendar.SECOND as useful fragment - + @Test public void testMillisecondsOfSecondWithDate() { final long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.SECOND); @@ -280,13 +280,13 @@ public class DateUtilsFragmentTest { } //Calendar.HOUR_OF_DAY as useful fragment - + @Test public void testMillisecondsOfHourWithDate() { final long testResult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.HOUR_OF_DAY); assertEquals(millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE), testResult); } - + @Test public void testMillisecondsOfHourWithCalendar() { final long testResult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.HOUR_OF_DAY); @@ -329,16 +329,16 @@ public class DateUtilsFragmentTest { @Test public void testMillisecondsOfDayWithDate() { long testresult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.DATE); - final long expectedValue = millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR); + final long expectedValue = millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR); assertEquals(expectedValue, testresult); testresult = DateUtils.getFragmentInMilliseconds(aDate, Calendar.DAY_OF_YEAR); assertEquals(expectedValue, testresult); } - + @Test public void testMillisecondsOfDayWithCalendar() { long testresult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.DATE); - final long expectedValue = millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR); + final long expectedValue = millis + (seconds * DateUtils.MILLIS_PER_SECOND) + (minutes * DateUtils.MILLIS_PER_MINUTE) + (hours * DateUtils.MILLIS_PER_HOUR); assertEquals(expectedValue, testresult); testresult = DateUtils.getFragmentInMilliseconds(aCalendar, Calendar.DAY_OF_YEAR); assertEquals(expectedValue, testresult); @@ -365,7 +365,7 @@ public class DateUtilsFragmentTest { @Test public void testMinutesOfDayWithDate() { long testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.DATE); - final long expectedValue = minutes + ((hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_MINUTE; + final long expectedValue = minutes + ((hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_MINUTE; assertEquals(expectedValue,testResult); testResult = DateUtils.getFragmentInMinutes(aDate, Calendar.DAY_OF_YEAR); assertEquals(expectedValue,testResult); @@ -374,16 +374,16 @@ public class DateUtilsFragmentTest { @Test public void testMinutesOfDayWithCalendar() { long testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.DATE); - final long expectedValue = minutes + ((hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_MINUTE; + final long expectedValue = minutes + ((hours * DateUtils.MILLIS_PER_HOUR))/ DateUtils.MILLIS_PER_MINUTE; assertEquals(expectedValue, testResult); testResult = DateUtils.getFragmentInMinutes(aCalendar, Calendar.DAY_OF_YEAR); assertEquals(expectedValue, testResult); } - + @Test public void testHoursOfDayWithDate() { long testResult = DateUtils.getFragmentInHours(aDate, Calendar.DATE); - final long expectedValue = hours; + final long expectedValue = hours; assertEquals(expectedValue,testResult); testResult = DateUtils.getFragmentInHours(aDate, Calendar.DAY_OF_YEAR); assertEquals(expectedValue,testResult); @@ -392,13 +392,13 @@ public class DateUtilsFragmentTest { @Test public void testHoursOfDayWithCalendar() { long testResult = DateUtils.getFragmentInHours(aCalendar, Calendar.DATE); - final long expectedValue = hours; + final long expectedValue = hours; assertEquals(expectedValue, testResult); testResult = DateUtils.getFragmentInHours(aCalendar, Calendar.DAY_OF_YEAR); assertEquals(expectedValue, testResult); } - - + + //Calendar.MONTH as useful fragment @Test public void testMillisecondsOfMonthWithDate() { @@ -415,7 +415,7 @@ public class DateUtilsFragmentTest { + (hours * DateUtils.MILLIS_PER_HOUR) + ((days - 1) * DateUtils.MILLIS_PER_DAY), testResult); } - + @Test public void testSecondsOfMonthWithDate() { final long testResult = DateUtils.getFragmentInSeconds(aDate, Calendar.MONTH); @@ -470,7 +470,7 @@ testResult); / DateUtils.MILLIS_PER_HOUR, testResult); } - + //Calendar.YEAR as useful fragment @Test public void testMillisecondsOfYearWithDate() { @@ -489,7 +489,7 @@ testResult); + (hours * DateUtils.MILLIS_PER_HOUR) + ((aCalendar.get(Calendar.DAY_OF_YEAR) - 1) * DateUtils.MILLIS_PER_DAY), testResult); } - + @Test public void testSecondsOfYearWithDate() { final long testResult = DateUtils.getFragmentInSeconds(aDate, Calendar.YEAR); @@ -563,27 +563,27 @@ testResult); / DateUtils.MILLIS_PER_HOUR, testResult); } - + @Test public void testDaysOfMonthWithCalendar() throws Exception { final long testResult = DateUtils.getFragmentInDays(aCalendar, Calendar.MONTH); assertEquals(days, testResult); } - + @Test public void testDaysOfMonthWithDate() throws Exception { final long testResult = DateUtils.getFragmentInDays(aDate, Calendar.MONTH); final Calendar cal = Calendar.getInstance(); cal.setTime(aDate); assertEquals(cal.get(Calendar.DAY_OF_MONTH), testResult); - } - + } + @Test public void testDaysOfYearWithCalendar() throws Exception { final long testResult = DateUtils.getFragmentInDays(aCalendar, Calendar.YEAR); assertEquals(aCalendar.get(Calendar.DAY_OF_YEAR), testResult); } - + @Test public void testDaysOfYearWithDate() throws Exception { final long testResult = DateUtils.getFragmentInDays(aDate, Calendar.YEAR); diff --git a/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java b/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java index b2a169bab..432a57438 100644 --- a/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java +++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsRoundingTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -31,19 +31,19 @@ import java.util.Locale; /** * These Unit-tests will check all possible extremes when using some rounding-methods of DateUtils. * The extremes are tested at the switch-point in milliseconds - * + * * According to the implementation SEMI_MONTH will either round/truncate to the 1st or 16th * When rounding Calendar.MONTH it depends on the number of days within that month. * A month with 28 days will be rounded up from the 15th * A month with 29 or 30 days will be rounded up from the 16th * A month with 31 days will be rounded up from the 17th - * + * * @since 3.0 */ public class DateUtilsRoundingTest { DateFormat dateTimeParser; - + Date januaryOneDate; Date targetYearDate; //No targetMonths, these must be tested for every type of month(28-31 days) @@ -62,7 +62,7 @@ public class DateUtilsRoundingTest { public void setUp() throws Exception { dateTimeParser = new SimpleDateFormat("MMM dd, yyyy H:mm:ss.SSS", Locale.ENGLISH); - + targetYearDate = dateTimeParser.parse("January 1, 2007 0:00:00.000"); targetDateDate = targetDayOfMonthDate = dateTimeParser.parse("June 1, 2008 0:00:00.000"); targetAmDate = dateTimeParser.parse("June 1, 2008 0:00:00.000"); @@ -72,7 +72,7 @@ public class DateUtilsRoundingTest { targetMinuteDate = dateTimeParser.parse("June 1, 2008 8:15:00.000"); targetSecondDate = dateTimeParser.parse("June 1, 2008 8:15:14.000"); targetMilliSecondDate = dateTimeParser.parse("June 1, 2008 8:15:14.231"); - + januaryOneDate = dateTimeParser.parse("January 1, 2008 0:00:00.000"); januaryOneCalendar = Calendar.getInstance(); januaryOneCalendar.setTime(januaryOneDate); @@ -80,7 +80,7 @@ public class DateUtilsRoundingTest { /** * Tests DateUtils.round()-method with Calendar.Year - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -92,12 +92,12 @@ public class DateUtilsRoundingTest { final Date lastRoundedDownDate = dateTimeParser.parse("June 30, 2007 23:59:59.999"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); } - + /** * Tests DateUtils.round()-method with Calendar.MONTH * Includes rounding months with 28, 29, 30 and 31 days * Includes rounding to January 1 - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -106,7 +106,7 @@ public class DateUtilsRoundingTest { final int calendarField = Calendar.MONTH; Date roundedUpDate, roundedDownDate, lastRoundedDownDate; Date minDate, maxDate; - + //month with 28 days roundedUpDate = dateTimeParser.parse("March 1, 2007 0:00:00.000"); roundedDownDate = dateTimeParser.parse("February 1, 2007 0:00:00.000"); @@ -118,30 +118,30 @@ public class DateUtilsRoundingTest { roundedDownDate = dateTimeParser.parse("February 1, 2008 0:00:00.000"); lastRoundedDownDate = dateTimeParser.parse("February 15, 2008 23:59:59.999"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //month with 30 days roundedUpDate = dateTimeParser.parse("May 1, 2008 0:00:00.000"); roundedDownDate = dateTimeParser.parse("April 1, 2008 0:00:00.000"); lastRoundedDownDate = dateTimeParser.parse("April 15, 2008 23:59:59.999"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //month with 31 days roundedUpDate = dateTimeParser.parse("June 1, 2008 0:00:00.000"); roundedDownDate = dateTimeParser.parse("May 1, 2008 0:00:00.000"); lastRoundedDownDate = dateTimeParser.parse("May 16, 2008 23:59:59.999"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //round to January 1 minDate = dateTimeParser.parse("December 17, 2007 00:00:00.000"); maxDate = dateTimeParser.parse("January 16, 2008 23:59:59.999"); roundToJanuaryFirst(minDate, maxDate, calendarField); } - + /** * Tests DateUtils.round()-method with DateUtils.SEMI_MONTH - * Includes rounding months with 28, 29, 30 and 31 days, each with first and second half + * Includes rounding months with 28, 29, 30 and 31 days, each with first and second half * Includes rounding to January 1 - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -150,7 +150,7 @@ public class DateUtilsRoundingTest { final int calendarField = DateUtils.SEMI_MONTH; Date roundedUpDate, roundedDownDate, lastRoundedDownDate; Date minDate, maxDate; - + //month with 28 days (1) roundedUpDate = dateTimeParser.parse("February 16, 2007 0:00:00.000"); roundedDownDate = dateTimeParser.parse("February 1, 2007 0:00:00.000"); @@ -168,7 +168,7 @@ public class DateUtilsRoundingTest { roundedDownDate = dateTimeParser.parse("February 1, 2008 0:00:00.000"); lastRoundedDownDate = dateTimeParser.parse("February 8, 2008 23:59:59.999"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //month with 29 days (2) roundedUpDate = dateTimeParser.parse("March 1, 2008 0:00:00.000"); roundedDownDate = dateTimeParser.parse("February 16, 2008 0:00:00.000"); @@ -186,7 +186,7 @@ public class DateUtilsRoundingTest { roundedDownDate = dateTimeParser.parse("April 16, 2008 0:00:00.000"); lastRoundedDownDate = dateTimeParser.parse("April 23, 2008 23:59:59.999"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //month with 31 days (1) roundedUpDate = dateTimeParser.parse("May 16, 2008 0:00:00.000"); roundedDownDate = dateTimeParser.parse("May 1, 2008 0:00:00.000"); @@ -198,18 +198,18 @@ public class DateUtilsRoundingTest { roundedDownDate = dateTimeParser.parse("May 16, 2008 0:00:00.000"); lastRoundedDownDate = dateTimeParser.parse("May 23, 2008 23:59:59.999"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //round to January 1 minDate = dateTimeParser.parse("December 24, 2007 00:00:00.000"); maxDate = dateTimeParser.parse("January 8, 2008 23:59:59.999"); roundToJanuaryFirst(minDate, maxDate, calendarField); } - + /** * Tests DateUtils.round()-method with Calendar.DATE - * Includes rounding the extremes of one day + * Includes rounding the extremes of one day * Includes rounding to January 1 - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -223,18 +223,18 @@ public class DateUtilsRoundingTest { roundedDownDate = targetDateDate; lastRoundedDownDate = dateTimeParser.parse("June 1, 2008 11:59:59.999"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //round to January 1 minDate = dateTimeParser.parse("December 31, 2007 12:00:00.000"); maxDate = dateTimeParser.parse("January 1, 2008 11:59:59.999"); roundToJanuaryFirst(minDate, maxDate, calendarField); } - + /** * Tests DateUtils.round()-method with Calendar.DAY_OF_MONTH - * Includes rounding the extremes of one day + * Includes rounding the extremes of one day * Includes rounding to January 1 - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -248,18 +248,18 @@ public class DateUtilsRoundingTest { roundedDownDate = targetDayOfMonthDate; lastRoundedDownDate = dateTimeParser.parse("June 1, 2008 11:59:59.999"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //round to January 1 minDate = dateTimeParser.parse("December 31, 2007 12:00:00.000"); maxDate = dateTimeParser.parse("January 1, 2008 11:59:59.999"); roundToJanuaryFirst(minDate, maxDate, calendarField); } - + /** * Tests DateUtils.round()-method with Calendar.AM_PM - * Includes rounding the extremes of both AM and PM of one day + * Includes rounding the extremes of both AM and PM of one day * Includes rounding to January 1 - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -286,12 +286,12 @@ public class DateUtilsRoundingTest { maxDate = dateTimeParser.parse("January 1, 2008 5:59:59.999"); roundToJanuaryFirst(minDate, maxDate, calendarField); } - + /** * Tests DateUtils.round()-method with Calendar.HOUR_OF_DAY - * Includes rounding the extremes of one hour + * Includes rounding the extremes of one hour * Includes rounding to January 1 - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -305,18 +305,18 @@ public class DateUtilsRoundingTest { roundedDownDate = targetHourOfDayDate; lastRoundedDownDate = dateTimeParser.parse("June 1, 2008 8:29:59.999"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //round to January 1 minDate = dateTimeParser.parse("December 31, 2007 23:30:00.000"); maxDate = dateTimeParser.parse("January 1, 2008 0:29:59.999"); roundToJanuaryFirst(minDate, maxDate, calendarField); } - + /** * Tests DateUtils.round()-method with Calendar.HOUR - * Includes rounding the extremes of one hour + * Includes rounding the extremes of one hour * Includes rounding to January 1 - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -330,18 +330,18 @@ public class DateUtilsRoundingTest { roundedDownDate = targetHourDate; lastRoundedDownDate = dateTimeParser.parse("June 1, 2008 8:29:59.999"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //round to January 1 minDate = dateTimeParser.parse("December 31, 2007 23:30:00.000"); maxDate = dateTimeParser.parse("January 1, 2008 0:29:59.999"); roundToJanuaryFirst(minDate, maxDate, calendarField); } - + /** * Tests DateUtils.round()-method with Calendar.MINUTE - * Includes rounding the extremes of one minute + * Includes rounding the extremes of one minute * Includes rounding to January 1 - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -355,18 +355,18 @@ public class DateUtilsRoundingTest { roundedDownDate = targetMinuteDate; lastRoundedDownDate = dateTimeParser.parse("June 1, 2008 8:15:29.999"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //round to January 1 minDate = dateTimeParser.parse("December 31, 2007 23:59:30.000"); maxDate = dateTimeParser.parse("January 1, 2008 0:00:29.999"); roundToJanuaryFirst(minDate, maxDate, calendarField); } - + /** * Tests DateUtils.round()-method with Calendar.SECOND - * Includes rounding the extremes of one second + * Includes rounding the extremes of one second * Includes rounding to January 1 - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -380,18 +380,18 @@ public class DateUtilsRoundingTest { roundedDownDate = targetSecondDate; lastRoundedDownDate = dateTimeParser.parse("June 1, 2008 8:15:14.499"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //round to January 1 minDate = dateTimeParser.parse("December 31, 2007 23:59:59.500"); maxDate = dateTimeParser.parse("January 1, 2008 0:00:00.499"); roundToJanuaryFirst(minDate, maxDate, calendarField); } - + /** * Tests DateUtils.round()-method with Calendar.MILLISECOND - * Includes rounding the extremes of one second + * Includes rounding the extremes of one second * Includes rounding to January 1 - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -404,15 +404,15 @@ public class DateUtilsRoundingTest { roundedDownDate = lastRoundedDownDate = targetMilliSecondDate; roundedUpDate = dateTimeParser.parse("June 1, 2008 8:15:14.232"); baseRoundTest(roundedUpDate, roundedDownDate, lastRoundedDownDate, calendarField); - + //round to January 1 minDate = maxDate = januaryOneDate; roundToJanuaryFirst(minDate, maxDate, calendarField); } - + /** * Test DateUtils.truncate()-method with Calendar.YEAR - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -425,7 +425,7 @@ public class DateUtilsRoundingTest { /** * Test DateUtils.truncate()-method with Calendar.MONTH - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -440,7 +440,7 @@ public class DateUtilsRoundingTest { /** * Test DateUtils.truncate()-method with DateUtils.SEMI_MONTH * Includes truncating months with 28, 29, 30 and 31 days, each with first and second half - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -448,7 +448,7 @@ public class DateUtilsRoundingTest { public void testTruncateSemiMonth() throws Exception { final int calendarField = DateUtils.SEMI_MONTH; Date truncatedDate, lastTruncateDate; - + //month with 28 days (1) truncatedDate = dateTimeParser.parse("February 1, 2007 0:00:00.000"); lastTruncateDate = dateTimeParser.parse("February 15, 2007 23:59:59.999"); @@ -478,7 +478,7 @@ public class DateUtilsRoundingTest { truncatedDate = dateTimeParser.parse("April 16, 2008 0:00:00.000"); lastTruncateDate = dateTimeParser.parse("April 30, 2008 23:59:59.999"); baseTruncateTest(truncatedDate, lastTruncateDate, calendarField); - + //month with 31 days (1) truncatedDate = dateTimeParser.parse("March 1, 2008 0:00:00.000"); lastTruncateDate = dateTimeParser.parse("March 15, 2008 23:59:59.999"); @@ -493,7 +493,7 @@ public class DateUtilsRoundingTest { /** * Test DateUtils.truncate()-method with Calendar.DATE - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -503,10 +503,10 @@ public class DateUtilsRoundingTest { final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 23:59:59.999"); baseTruncateTest(targetDateDate, lastTruncateDate, calendarField); } - + /** * Test DateUtils.truncate()-method with Calendar.DAY_OF_MONTH - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -516,18 +516,18 @@ public class DateUtilsRoundingTest { final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 23:59:59.999"); baseTruncateTest(targetDayOfMonthDate, lastTruncateDate, calendarField); } - + /** * Test DateUtils.truncate()-method with Calendar.AM_PM - * Includes truncating the extremes of both AM and PM of one day - * + * Includes truncating the extremes of both AM and PM of one day + * * @throws Exception so we don't have to catch it * @since 3.0 */ @Test public void testTruncateAmPm() throws Exception { final int calendarField = Calendar.AM_PM; - + //AM Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 11:59:59.999"); baseTruncateTest(targetAmDate, lastTruncateDate, calendarField); @@ -536,10 +536,10 @@ public class DateUtilsRoundingTest { lastTruncateDate = dateTimeParser.parse("June 1, 2008 23:59:59.999"); baseTruncateTest(targetPmDate, lastTruncateDate, calendarField); } - + /** * Test DateUtils.truncate()-method with Calendar.HOUR - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -549,10 +549,10 @@ public class DateUtilsRoundingTest { final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:59:59.999"); baseTruncateTest(targetHourDate, lastTruncateDate, calendarField); } - + /** * Test DateUtils.truncate()-method with Calendar.HOUR_OF_DAY - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -562,10 +562,10 @@ public class DateUtilsRoundingTest { final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:59:59.999"); baseTruncateTest(targetHourOfDayDate, lastTruncateDate, calendarField); } - + /** * Test DateUtils.truncate()-method with Calendar.MINUTE - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -575,10 +575,10 @@ public class DateUtilsRoundingTest { final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:15:59.999"); baseTruncateTest(targetMinuteDate, lastTruncateDate, calendarField); } - + /** * Test DateUtils.truncate()-method with Calendar.SECOND - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -588,10 +588,10 @@ public class DateUtilsRoundingTest { final Date lastTruncateDate = dateTimeParser.parse("June 1, 2008 8:15:14.999"); baseTruncateTest(targetSecondDate, lastTruncateDate, calendarField); } - + /** * Test DateUtils.truncate()-method with Calendar.SECOND - * + * * @throws Exception so we don't have to catch it * @since 3.0 */ @@ -600,13 +600,13 @@ public class DateUtilsRoundingTest { final int calendarField = Calendar.MILLISECOND; baseTruncateTest(targetMilliSecondDate, targetMilliSecondDate, calendarField); } - + /** - * When using this basetest all extremes are tested.<br> + * When using this basetest all extremes are tested.<br> * It will test the Date, Calendar and Object-implementation<br> * lastRoundDownDate should round down to roundedDownDate<br> * lastRoundDownDate + 1 millisecond should round up to roundedUpDate - * + * * @param roundedUpDate the next rounded date after <strong>roundedDownDate</strong> when using <strong>calendarField</strong> * @param roundedDownDate the result if <strong>lastRoundDownDate</strong> was rounded with <strong>calendarField</strong> * @param lastRoundDownDate rounding this value with <strong>calendarField</strong> will result in <strong>roundedDownDate</strong> @@ -615,15 +615,15 @@ public class DateUtilsRoundingTest { */ protected void baseRoundTest(final Date roundedUpDate, final Date roundedDownDate, final Date lastRoundDownDate, final int calendarField) { final Date firstRoundUpDate = DateUtils.addMilliseconds(lastRoundDownDate, 1); - + //Date-comparison assertEquals(roundedDownDate, DateUtils.round(roundedDownDate, calendarField)); assertEquals(roundedUpDate, DateUtils.round(roundedUpDate, calendarField)); assertEquals(roundedDownDate, DateUtils.round(lastRoundDownDate, calendarField)); assertEquals(roundedUpDate, DateUtils.round(firstRoundUpDate, calendarField)); - + //Calendar-initiations - Calendar roundedUpCalendar, roundedDownCalendar, lastRoundDownCalendar, firstRoundUpCalendar; + Calendar roundedUpCalendar, roundedDownCalendar, lastRoundDownCalendar, firstRoundUpCalendar; roundedDownCalendar = Calendar.getInstance(); roundedUpCalendar = Calendar.getInstance(); lastRoundDownCalendar = Calendar.getInstance(); @@ -649,13 +649,13 @@ public class DateUtilsRoundingTest { assertEquals(roundedDownDate, DateUtils.round((Object) lastRoundDownDate, calendarField)); assertEquals(roundedUpDate, DateUtils.round((Object) firstRoundUpDate, calendarField)); } - + /** - * When using this basetest all extremes are tested.<br> + * When using this basetest all extremes are tested.<br> * It will test the Date, Calendar and Object-implementation<br> * lastTruncateDate should round down to truncatedDate<br> * lastTruncateDate + 1 millisecond should never round down to truncatedDate - * + * * @param truncatedDate expected Date when <strong>lastTruncateDate</strong> is truncated with <strong>calendarField</strong> * @param lastTruncateDate the last possible Date which will truncate to <strong>truncatedDate</strong> with <strong>calendarField</strong> * @param calendarField a Calendar.field value @@ -663,14 +663,14 @@ public class DateUtilsRoundingTest { */ protected void baseTruncateTest(final Date truncatedDate, final Date lastTruncateDate, final int calendarField) { final Date nextTruncateDate = DateUtils.addMilliseconds(lastTruncateDate, 1); - + //Date-comparison assertEquals("Truncating "+ fdf.format(truncatedDate) +" as Date with CalendarField-value "+ calendarField +" must return itself", truncatedDate, DateUtils.truncate(truncatedDate, calendarField)); assertEquals(truncatedDate, DateUtils.truncate(lastTruncateDate, calendarField)); assertFalse(fdf.format(lastTruncateDate) +" is not an extreme when truncating as Date with CalendarField-value "+ calendarField, truncatedDate.equals(DateUtils.truncate(nextTruncateDate, calendarField))); - + //Calendar-initiations - Calendar truncatedCalendar, lastTruncateCalendar, nextTruncateCalendar; + Calendar truncatedCalendar, lastTruncateCalendar, nextTruncateCalendar; truncatedCalendar = Calendar.getInstance(); lastTruncateCalendar = Calendar.getInstance(); nextTruncateCalendar = Calendar.getInstance(); @@ -691,12 +691,12 @@ public class DateUtilsRoundingTest { assertEquals(truncatedDate, DateUtils.truncate((Object) lastTruncateCalendar, calendarField)); assertFalse(fdf.format(lastTruncateCalendar) +" is not an extreme when truncating as Calendar cast to Object with CalendarField-value "+ calendarField, truncatedDate.equals(DateUtils.truncate((Object) nextTruncateCalendar, calendarField))); } - + /** - * + * * Any January 1 could be considered as the ultimate extreme. - * Instead of comparing the results if the input has a difference of 1 millisecond we check the output to be exactly January first. - * + * Instead of comparing the results if the input has a difference of 1 millisecond we check the output to be exactly January first. + * * @param minDate the lower bound * @param maxDate the upper bound * @param calendarField a Calendar.field value @@ -706,7 +706,7 @@ public class DateUtilsRoundingTest { assertEquals("Rounding "+ fdf.format(januaryOneDate) +" as Date with CalendarField-value "+ calendarField +" must return itself", januaryOneDate, DateUtils.round(januaryOneDate, calendarField)); assertEquals(januaryOneDate, DateUtils.round(minDate, calendarField)); assertEquals(januaryOneDate, DateUtils.round(maxDate, calendarField)); - + final Calendar minCalendar = Calendar.getInstance(); minCalendar.setTime(minDate); final Calendar maxCalendar = Calendar.getInstance(); @@ -719,7 +719,7 @@ public class DateUtilsRoundingTest { final Date toNextRoundDate = DateUtils.addMilliseconds(maxDate, 1); assertFalse(fdf.format(minDate) +" is not an lower-extreme when rounding as Date with CalendarField-value "+ calendarField, januaryOneDate.equals(DateUtils.round(toPrevRoundDate, calendarField))); assertFalse(fdf.format(maxDate) +" is not an upper-extreme when rounding as Date with CalendarField-value "+ calendarField, januaryOneDate.equals(DateUtils.round(toNextRoundDate, calendarField))); - + final Calendar toPrevRoundCalendar = Calendar.getInstance(); toPrevRoundCalendar.setTime(toPrevRoundDate); final Calendar toNextRoundCalendar = Calendar.getInstance(); diff --git a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java index 964c40b94..77e110110 100644 --- a/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/time/DateUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -59,7 +59,7 @@ public class DateUtilsTest { @Rule public SystemDefaultsSwitch defaults = new SystemDefaultsSwitch(); - + private DateFormat dateParser = null; private DateFormat dateTimeParser = null; private Date dateAmPm1 = null; @@ -152,7 +152,7 @@ public class DateUtilsTest { assertTrue(Modifier.isPublic(DateUtils.class.getModifiers())); assertFalse(Modifier.isFinal(DateUtils.class.getModifiers())); } - + //----------------------------------------------------------------------- @Test public void testIsSameDay_Date() { @@ -250,7 +250,7 @@ public class DateUtilsTest { calb.set(2004, Calendar.JULY, 9, 13, 45, 0); calb.set(Calendar.MILLISECOND, 0); assertFalse(DateUtils.isSameInstant(cala, calb)); - + calb.set(2004, Calendar.JULY, 9, 11, 45, 0); assertTrue(DateUtils.isSameInstant(cala, calb)); } @@ -288,7 +288,7 @@ public class DateUtilsTest { calc.set(Calendar.MILLISECOND, 0); cald.set(Calendar.MILLISECOND, 0); assertFalse("LANG-677", DateUtils.isSameLocalTime(calc, cald)); - + calb.set(2004, Calendar.JULY, 9, 11, 45, 0); assertFalse(DateUtils.isSameLocalTime(cala, calb)); } @@ -316,11 +316,11 @@ public class DateUtilsTest { final String[] parsers = new String[] {"yyyy'-'DDD", "yyyy'-'MM'-'dd", "yyyyMMdd"}; Date date = DateUtils.parseDate(dateStr, parsers); assertEquals(cal.getTime(), date); - + dateStr = "1972-338"; date = DateUtils.parseDate(dateStr, parsers); assertEquals(cal.getTime(), date); - + dateStr = "19721203"; date = DateUtils.parseDate(dateStr, parsers); assertEquals(cal.getTime(), date); @@ -348,7 +348,7 @@ public class DateUtilsTest { public void testParse_NullParsers() throws Exception { DateUtils.parseDate("19721203", (String[]) null); } - + @Test(expected = ParseException.class) public void testParse_EmptyParsers() throws Exception { DateUtils.parseDate("19721203"); @@ -360,10 +360,10 @@ public class DateUtilsTest { final GregorianCalendar cal = new GregorianCalendar(1998, 6, 30); final String dateStr = "02 942, 1996"; final String[] parsers = new String[] {"MM DDD, yyyy"}; - + final Date date = DateUtils.parseDate(dateStr, parsers); assertEquals(cal.getTime(), date); - + try { DateUtils.parseDateStrictly(dateStr, parsers); fail(); @@ -377,12 +377,12 @@ public class DateUtilsTest { assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 4, 3, 2, 1); - + result = DateUtils.addYears(BASE_DATE, 1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2001, 6, 5, 4, 3, 2, 1); - + result = DateUtils.addYears(BASE_DATE, -1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); @@ -396,12 +396,12 @@ public class DateUtilsTest { assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 4, 3, 2, 1); - + result = DateUtils.addMonths(BASE_DATE, 1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 7, 5, 4, 3, 2, 1); - + result = DateUtils.addMonths(BASE_DATE, -1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); @@ -415,12 +415,12 @@ public class DateUtilsTest { assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 4, 3, 2, 1); - + result = DateUtils.addWeeks(BASE_DATE, 1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 12, 4, 3, 2, 1); - + result = DateUtils.addWeeks(BASE_DATE, -1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); // july @@ -434,12 +434,12 @@ public class DateUtilsTest { assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 4, 3, 2, 1); - + result = DateUtils.addDays(BASE_DATE, 1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 6, 4, 3, 2, 1); - + result = DateUtils.addDays(BASE_DATE, -1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); @@ -453,12 +453,12 @@ public class DateUtilsTest { assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 4, 3, 2, 1); - + result = DateUtils.addHours(BASE_DATE, 1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 5, 3, 2, 1); - + result = DateUtils.addHours(BASE_DATE, -1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); @@ -472,12 +472,12 @@ public class DateUtilsTest { assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 4, 3, 2, 1); - + result = DateUtils.addMinutes(BASE_DATE, 1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 4, 4, 2, 1); - + result = DateUtils.addMinutes(BASE_DATE, -1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); @@ -491,12 +491,12 @@ public class DateUtilsTest { assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 4, 3, 2, 1); - + result = DateUtils.addSeconds(BASE_DATE, 1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 4, 3, 3, 1); - + result = DateUtils.addSeconds(BASE_DATE, -1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); @@ -510,12 +510,12 @@ public class DateUtilsTest { assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 4, 3, 2, 1); - + result = DateUtils.addMilliseconds(BASE_DATE, 1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); assertDate(result, 2000, 6, 5, 4, 3, 2, 2); - + result = DateUtils.addMilliseconds(BASE_DATE, -1); assertNotSame(BASE_DATE, result); assertDate(BASE_DATE, 2000, 6, 5, 4, 3, 2, 1); @@ -691,19 +691,19 @@ public class DateUtilsTest { // expected } } - + //----------------------------------------------------------------------- @Test(expected=NullPointerException.class) public void testToCalendarWithDateNull() { DateUtils.toCalendar(null, zone); } - + //----------------------------------------------------------------------- @Test(expected=NullPointerException.class) public void testToCalendarWithTimeZoneNull() { DateUtils.toCalendar(date1, null); } - + //----------------------------------------------------------------------- @Test public void testToCalendarWithDateAndTimeZoneNotNull() { @@ -711,7 +711,7 @@ public class DateUtilsTest { assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the Date back", date2, c.getTime()); assertEquals("Convert Date and TimeZone to a Calendar, but failed to get the TimeZone back", defaultZone, c.getTimeZone()); } - + //----------------------------------------------------------------------- @Test(expected=NullPointerException.class) public void testToCalendarWithDateAndTimeZoneNull() { @@ -748,8 +748,8 @@ public class DateUtilsTest { assertEquals("round semimonth-2 failed", dateParser.parse("November 16, 2001"), DateUtils.round(date2, DateUtils.SEMI_MONTH)); - - + + assertEquals("round date-1 failed", dateParser.parse("February 13, 2002"), DateUtils.round(date1, Calendar.DATE)); @@ -882,7 +882,7 @@ public class DateUtilsTest { assertEquals("round ampm-4 failed", dateTimeParser.parse("February 4, 2002 00:00:00.000"), DateUtils.round((Object) calAmPm4, Calendar.AM_PM)); - + // Fix for http://issues.apache.org/bugzilla/show_bug.cgi?id=25560 / LANG-13 // Test rounding across the beginning of daylight saving time TimeZone.setDefault(zone); @@ -911,7 +911,7 @@ public class DateUtilsTest { assertEquals("round MET date across DST change-over", dateTimeParser.parse("March 30, 2003 00:00:00.000"), DateUtils.round((Object) cal7, Calendar.DATE)); - + assertEquals("round MET date across DST change-over", dateTimeParser.parse("March 30, 2003 01:00:00.000"), DateUtils.round(date4, Calendar.HOUR_OF_DAY)); @@ -1123,14 +1123,14 @@ public class DateUtilsTest { assertEquals("truncate ampm-4 failed", dateTimeParser.parse("February 3, 2002 12:00:00.000"), DateUtils.truncate((Object) dateAmPm4, Calendar.AM_PM)); - + assertEquals("truncate calendar second-1 failed", dateTimeParser.parse("February 12, 2002 12:34:56.000"), DateUtils.truncate((Object) cal1, Calendar.SECOND)); assertEquals("truncate calendar second-2 failed", dateTimeParser.parse("November 18, 2001 1:23:11.000"), DateUtils.truncate((Object) cal2, Calendar.SECOND)); - + assertEquals("truncate ampm-1 failed", dateTimeParser.parse("February 3, 2002 00:00:00.000"), DateUtils.truncate((Object) calAmPm1, Calendar.AM_PM)); @@ -1143,7 +1143,7 @@ public class DateUtilsTest { assertEquals("truncate ampm-4 failed", dateTimeParser.parse("February 3, 2002 12:00:00.000"), DateUtils.truncate((Object) calAmPm4, Calendar.AM_PM)); - + try { DateUtils.truncate((Date) null, Calendar.SECOND); fail(); @@ -1180,7 +1180,7 @@ public class DateUtilsTest { DateUtils.truncate((Object) cal8, Calendar.DATE)); TimeZone.setDefault(defaultZone); dateTimeParser.setTimeZone(defaultZone); - + // Bug 31395, large dates final Date endOfTime = new Date(Long.MAX_VALUE); // fyi: Sun Aug 17 07:12:55 CET 292278994 -- 807 millis final GregorianCalendar endCal = new GregorianCalendar(); @@ -1214,7 +1214,7 @@ public class DateUtilsTest { final DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS z"); format.setTimeZone(MST_MDT); - final Date oct31_01MDT = new Date(1099206000000L); + final Date oct31_01MDT = new Date(1099206000000L); final Date oct31MDT = new Date(oct31_01MDT.getTime() - 3600000L); // - 1 hour final Date oct31_01_02MDT = new Date(oct31_01MDT.getTime() + 120000L); // + 2 minutes @@ -1284,9 +1284,9 @@ public class DateUtilsTest { final String isoDateStr = DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(d); final Date d2 = DateUtils.parseDate(isoDateStr, new String[] { DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.getPattern() }); // the format loses milliseconds so have to reintroduce them - assertEquals("Date not equal to itself ISO formatted and parsed", d.getTime(), d2.getTime() + d.getTime() % 1000); + assertEquals("Date not equal to itself ISO formatted and parsed", d.getTime(), d2.getTime() + d.getTime() % 1000); } - + /** * Tests various values with the ceiling method * @@ -1361,7 +1361,7 @@ public class DateUtilsTest { assertEquals("ceiling ampm-4 failed", dateTimeParser.parse("February 4, 2002 00:00:00.000"), DateUtils.ceiling(dateAmPm4, Calendar.AM_PM)); - + // tests public static Date ceiling(Object date, int field) assertEquals("ceiling year-1 failed", dateParser.parse("January 1, 2003"), @@ -1417,14 +1417,14 @@ public class DateUtilsTest { assertEquals("ceiling ampm-4 failed", dateTimeParser.parse("February 4, 2002 00:00:00.000"), DateUtils.ceiling((Object) dateAmPm4, Calendar.AM_PM)); - + assertEquals("ceiling calendar second-1 failed", dateTimeParser.parse("February 12, 2002 12:34:57.000"), DateUtils.ceiling((Object) cal1, Calendar.SECOND)); assertEquals("ceiling calendar second-2 failed", dateTimeParser.parse("November 18, 2001 1:23:12.000"), DateUtils.ceiling((Object) cal2, Calendar.SECOND)); - + assertEquals("ceiling ampm-1 failed", dateTimeParser.parse("February 3, 2002 12:00:00.000"), DateUtils.ceiling((Object) calAmPm1, Calendar.AM_PM)); @@ -1459,7 +1459,7 @@ public class DateUtilsTest { fail(); } catch(final IllegalArgumentException ex) {} - + // Fix for http://issues.apache.org/bugzilla/show_bug.cgi?id=25560 // Test ceiling across the beginning of daylight saving time TimeZone.setDefault(zone); @@ -1489,7 +1489,7 @@ public class DateUtilsTest { assertEquals("ceiling MET date across DST change-over", dateTimeParser.parse("March 31, 2003 00:00:00.000"), DateUtils.ceiling((Object) cal7, Calendar.DATE)); - + assertEquals("ceiling MET date across DST change-over", dateTimeParser.parse("March 30, 2003 03:00:00.000"), DateUtils.ceiling(date4, Calendar.HOUR_OF_DAY)); @@ -1516,7 +1516,7 @@ public class DateUtilsTest { DateUtils.ceiling((Object) cal7, Calendar.HOUR_OF_DAY)); TimeZone.setDefault(defaultZone); dateTimeParser.setTimeZone(defaultZone); - + // Bug 31395, large dates final Date endOfTime = new Date(Long.MAX_VALUE); // fyi: Sun Aug 17 07:12:55 CET 292278994 -- 807 millis final GregorianCalendar endCal = new GregorianCalendar(); @@ -1584,7 +1584,7 @@ public class DateUtilsTest { } final Calendar centered = DateUtils.truncate(now, Calendar.DATE); centered.add(Calendar.DATE, -3); - + Iterator<?> it = DateUtils.iterator(now, DateUtils.RANGE_WEEK_SUNDAY); assertWeekIterator(it, sunday); it = DateUtils.iterator(now, DateUtils.RANGE_WEEK_MONDAY); @@ -1593,7 +1593,7 @@ public class DateUtilsTest { assertWeekIterator(it, today); it = DateUtils.iterator(now, DateUtils.RANGE_WEEK_CENTER); assertWeekIterator(it, centered); - + it = DateUtils.iterator((Object) now, DateUtils.RANGE_WEEK_CENTER); assertWeekIterator(it, centered); it = DateUtils.iterator((Object) now.getTime(), DateUtils.RANGE_WEEK_CENTER); @@ -1607,11 +1607,11 @@ public class DateUtilsTest { try { it.remove(); } catch( final UnsupportedOperationException ex) {} - + now.add(Calendar.DATE,1); } } - + /** * Tests the calendar iterator for month-based ranges * @@ -1667,14 +1667,14 @@ public class DateUtilsTest { public void testLANG799_DE_FAIL() throws ParseException { DateUtils.parseDate("Wed, 09 Apr 2008 23:55:38 GMT", "EEE, dd MMM yyyy HH:mm:ss zzz"); } - + // Parse German date with English Locale, specifying German Locale override @SystemDefaults(locale="en") @Test public void testLANG799_EN_WITH_DE_LOCALE() throws ParseException { DateUtils.parseDate("Mi, 09 Apr 2008 23:55:38 GMT", Locale.GERMAN, "EEE, dd MMM yyyy HH:mm:ss zzz"); } - + /** * This checks that this is a 7 element iterator of Calendar objects * that are dates (no time), and exactly 1 day spaced after each other. diff --git a/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java b/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java index 2847c6d40..b5eb0fac8 100644 --- a/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java +++ b/src/test/java/org/apache/commons/lang3/time/DurationFormatUtilsTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -409,14 +409,14 @@ public class DurationFormatUtilsTest { // http://issues.apache.org/bugzilla/show_bug.cgi?id=38401 @Test public void testBugzilla38401() { - assertEqualDuration( "0000/00/30 16:00:00 000", new int[] { 2006, 0, 26, 18, 47, 34 }, + assertEqualDuration( "0000/00/30 16:00:00 000", new int[] { 2006, 0, 26, 18, 47, 34 }, new int[] { 2006, 1, 26, 10, 47, 34 }, "yyyy/MM/dd HH:mm:ss SSS"); } // https://issues.apache.org/jira/browse/LANG-281 @Test public void testJiraLang281() { - assertEqualDuration( "09", new int[] { 2005, 11, 31, 0, 0, 0 }, + assertEqualDuration( "09", new int[] { 2005, 11, 31, 0, 0, 0 }, new int[] { 2006, 9, 6, 0, 0, 0 }, "MM"); } @@ -438,7 +438,7 @@ public class DurationFormatUtilsTest { 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, + assertEqualDuration( hr + ":" + min + ":" + sec, new int[] { 2000, 0, 1, 0, 0, 0, 0 }, new int[] { 2000, 0, 1, hr, min, sec }, "H:m:s" @@ -453,92 +453,92 @@ public class DurationFormatUtilsTest { public void testEdgeDurations() { // This test case must use a time zone without DST TimeZone.setDefault(TimeZone.getTimeZone("UTC")); - assertEqualDuration( "01", new int[] { 2006, 0, 15, 0, 0, 0 }, + assertEqualDuration( "01", new int[] { 2006, 0, 15, 0, 0, 0 }, new int[] { 2006, 2, 10, 0, 0, 0 }, "MM"); - assertEqualDuration( "12", new int[] { 2005, 0, 15, 0, 0, 0 }, + assertEqualDuration( "12", new int[] { 2005, 0, 15, 0, 0, 0 }, new int[] { 2006, 0, 15, 0, 0, 0 }, "MM"); - assertEqualDuration( "12", new int[] { 2005, 0, 15, 0, 0, 0 }, + assertEqualDuration( "12", new int[] { 2005, 0, 15, 0, 0, 0 }, new int[] { 2006, 0, 16, 0, 0, 0 }, "MM"); - assertEqualDuration( "11", new int[] { 2005, 0, 15, 0, 0, 0 }, + assertEqualDuration( "11", new int[] { 2005, 0, 15, 0, 0, 0 }, new int[] { 2006, 0, 14, 0, 0, 0 }, "MM"); - + assertEqualDuration( "01 26", new int[] { 2006, 0, 15, 0, 0, 0 }, new int[] { 2006, 2, 10, 0, 0, 0 }, "MM dd"); assertEqualDuration( "54", new int[] { 2006, 0, 15, 0, 0, 0 }, - new int[] { 2006, 2, 10, 0, 0, 0 }, "dd"); - + new int[] { 2006, 2, 10, 0, 0, 0 }, "dd"); + assertEqualDuration( "09 12", new int[] { 2006, 1, 20, 0, 0, 0 }, new int[] { 2006, 11, 4, 0, 0, 0 }, "MM dd"); assertEqualDuration( "287", new int[] { 2006, 1, 20, 0, 0, 0 }, - new int[] { 2006, 11, 4, 0, 0, 0 }, "dd"); + new int[] { 2006, 11, 4, 0, 0, 0 }, "dd"); assertEqualDuration( "11 30", new int[] { 2006, 0, 2, 0, 0, 0 }, - new int[] { 2007, 0, 1, 0, 0, 0 }, "MM dd"); + new int[] { 2007, 0, 1, 0, 0, 0 }, "MM dd"); assertEqualDuration( "364", new int[] { 2006, 0, 2, 0, 0, 0 }, - new int[] { 2007, 0, 1, 0, 0, 0 }, "dd"); + new int[] { 2007, 0, 1, 0, 0, 0 }, "dd"); assertEqualDuration( "12 00", new int[] { 2006, 0, 1, 0, 0, 0 }, - new int[] { 2007, 0, 1, 0, 0, 0 }, "MM dd"); + new int[] { 2007, 0, 1, 0, 0, 0 }, "MM dd"); assertEqualDuration( "365", new int[] { 2006, 0, 1, 0, 0, 0 }, - new int[] { 2007, 0, 1, 0, 0, 0 }, "dd"); - + new int[] { 2007, 0, 1, 0, 0, 0 }, "dd"); + assertEqualDuration( "31", new int[] { 2006, 0, 1, 0, 0, 0 }, - new int[] { 2006, 1, 1, 0, 0, 0 }, "dd"); - + new int[] { 2006, 1, 1, 0, 0, 0 }, "dd"); + assertEqualDuration( "92", new int[] { 2005, 9, 1, 0, 0, 0 }, - new int[] { 2006, 0, 1, 0, 0, 0 }, "dd"); + new int[] { 2006, 0, 1, 0, 0, 0 }, "dd"); assertEqualDuration( "77", new int[] { 2005, 9, 16, 0, 0, 0 }, - new int[] { 2006, 0, 1, 0, 0, 0 }, "dd"); + new int[] { 2006, 0, 1, 0, 0, 0 }, "dd"); // test month larger in start than end assertEqualDuration( "136", new int[] { 2005, 9, 16, 0, 0, 0 }, - new int[] { 2006, 2, 1, 0, 0, 0 }, "dd"); + new int[] { 2006, 2, 1, 0, 0, 0 }, "dd"); // test when start in leap year assertEqualDuration( "136", new int[] { 2004, 9, 16, 0, 0, 0 }, - new int[] { 2005, 2, 1, 0, 0, 0 }, "dd"); + new int[] { 2005, 2, 1, 0, 0, 0 }, "dd"); // test when end in leap year assertEqualDuration( "137", new int[] { 2003, 9, 16, 0, 0, 0 }, - new int[] { 2004, 2, 1, 0, 0, 0 }, "dd"); + new int[] { 2004, 2, 1, 0, 0, 0 }, "dd"); // test when end in leap year but less than end of feb assertEqualDuration( "135", new int[] { 2003, 9, 16, 0, 0, 0 }, - new int[] { 2004, 1, 28, 0, 0, 0 }, "dd"); + new int[] { 2004, 1, 28, 0, 0, 0 }, "dd"); assertEqualDuration( "364", new int[] { 2007, 0, 2, 0, 0, 0 }, - new int[] { 2008, 0, 1, 0, 0, 0 }, "dd"); + new int[] { 2008, 0, 1, 0, 0, 0 }, "dd"); assertEqualDuration( "729", new int[] { 2006, 0, 2, 0, 0, 0 }, - new int[] { 2008, 0, 1, 0, 0, 0 }, "dd"); + new int[] { 2008, 0, 1, 0, 0, 0 }, "dd"); assertEqualDuration( "365", new int[] { 2007, 2, 2, 0, 0, 0 }, - new int[] { 2008, 2, 1, 0, 0, 0 }, "dd"); + new int[] { 2008, 2, 1, 0, 0, 0 }, "dd"); assertEqualDuration( "333", new int[] { 2007, 1, 2, 0, 0, 0 }, - new int[] { 2008, 0, 1, 0, 0, 0 }, "dd"); + new int[] { 2008, 0, 1, 0, 0, 0 }, "dd"); assertEqualDuration( "28", new int[] { 2008, 1, 2, 0, 0, 0 }, - new int[] { 2008, 2, 1, 0, 0, 0 }, "dd"); + new int[] { 2008, 2, 1, 0, 0, 0 }, "dd"); assertEqualDuration( "393", new int[] { 2007, 1, 2, 0, 0, 0 }, - new int[] { 2008, 2, 1, 0, 0, 0 }, "dd"); + new int[] { 2008, 2, 1, 0, 0, 0 }, "dd"); assertEqualDuration( "369", new int[] { 2004, 0, 29, 0, 0, 0 }, - new int[] { 2005, 1, 1, 0, 0, 0 }, "dd"); + new int[] { 2005, 1, 1, 0, 0, 0 }, "dd"); assertEqualDuration( "338", new int[] { 2004, 1, 29, 0, 0, 0 }, - new int[] { 2005, 1, 1, 0, 0, 0 }, "dd"); + new int[] { 2005, 1, 1, 0, 0, 0 }, "dd"); assertEqualDuration( "28", new int[] { 2004, 2, 8, 0, 0, 0 }, - new int[] { 2004, 3, 5, 0, 0, 0 }, "dd"); + new int[] { 2004, 3, 5, 0, 0, 0 }, "dd"); assertEqualDuration( "48", new int[] { 1992, 1, 29, 0, 0, 0 }, - new int[] { 1996, 1, 29, 0, 0, 0 }, "M"); - - - // this seems odd - and will fail if I throw it in as a brute force + new int[] { 1996, 1, 29, 0, 0, 0 }, "M"); + + + // this seems odd - and will fail if I throw it in as a brute force // below as it expects the answer to be 12. It's a tricky edge case assertEqualDuration( "11", new int[] { 1996, 1, 29, 0, 0, 0 }, - new int[] { 1997, 1, 28, 0, 0, 0 }, "M"); + new int[] { 1997, 1, 28, 0, 0, 0 }, "M"); // again - this seems odd assertEqualDuration( "11 28", new int[] { 1996, 1, 29, 0, 0, 0 }, - new int[] { 1997, 1, 28, 0, 0, 0 }, "M d"); - + new int[] { 1997, 1, 28, 0, 0, 0 }, "M d"); + } @Test @@ -581,7 +581,7 @@ public class DurationFormatUtilsTest { } private static final int FOUR_YEARS = 365 * 3 + 366; - + // Takes a minute to run, so generally turned off // public void testBrutally() { // Calendar c = Calendar.getInstance(); @@ -590,8 +590,8 @@ public class DurationFormatUtilsTest { // bruteForce(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DAY_OF_MONTH), "d", Calendar.DAY_OF_MONTH ); // c.add(Calendar.DAY_OF_MONTH, 1); // } -// } - +// } + private void bruteForce(final int year, final int month, final int day, final String format, final int calendarType) { final String msg = year + "-" + month + "-" + day + " to "; final Calendar c = Calendar.getInstance(); diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java index 3de6df86e..7197a980a 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDateFormatTest.java @@ -162,10 +162,10 @@ public class FastDateFormatTest { final FastDateFormat format = FastDateFormat.getInstance(); final FastDateFormat medium = FastDateFormat.getDateTimeInstance(FastDateFormat.SHORT, FastDateFormat.SHORT); assertEquals(medium, format); - + final SimpleDateFormat sdf = new SimpleDateFormat(); assertEquals(sdf.toPattern(), format.getPattern()); - + assertEquals(Locale.getDefault(), format.getLocale()); assertEquals(TimeZone.getDefault(), format.getTimeZone()); } @@ -176,7 +176,7 @@ public class FastDateFormatTest { final FastDateFormat shortLong = FastDateFormat.getDateTimeInstance(FastDateFormat.SHORT, FastDateFormat.LONG, Locale.US); final FastDateFormat longShort = FastDateFormat.getDateTimeInstance(FastDateFormat.LONG, FastDateFormat.SHORT, Locale.US); final FastDateFormat longLong = FastDateFormat.getDateTimeInstance(FastDateFormat.LONG, FastDateFormat.LONG, Locale.US); - + assertFalse(shortShort.equals(shortLong)); assertFalse(shortShort.equals(longShort)); assertFalse(shortShort.equals(longLong)); @@ -187,13 +187,13 @@ public class FastDateFormatTest { @Test public void testDateDefaults() { - assertEquals(FastDateFormat.getDateInstance(FastDateFormat.LONG, Locale.CANADA), + assertEquals(FastDateFormat.getDateInstance(FastDateFormat.LONG, Locale.CANADA), FastDateFormat.getDateInstance(FastDateFormat.LONG, TimeZone.getDefault(), Locale.CANADA)); - - assertEquals(FastDateFormat.getDateInstance(FastDateFormat.LONG, TimeZone.getTimeZone("America/New_York")), + + assertEquals(FastDateFormat.getDateInstance(FastDateFormat.LONG, TimeZone.getTimeZone("America/New_York")), FastDateFormat.getDateInstance(FastDateFormat.LONG, TimeZone.getTimeZone("America/New_York"), Locale.getDefault())); - assertEquals(FastDateFormat.getDateInstance(FastDateFormat.LONG), + assertEquals(FastDateFormat.getDateInstance(FastDateFormat.LONG), FastDateFormat.getDateInstance(FastDateFormat.LONG, TimeZone.getDefault(), Locale.getDefault())); } @@ -255,7 +255,7 @@ public class FastDateFormatTest { final static private int NTHREADS= 10; final static private int NROUNDS= 10000; - + private AtomicLongArray measureTime(final Format printer, final Format parser) throws InterruptedException { final ExecutorService pool = Executors.newFixedThreadPool(NTHREADS); final AtomicInteger failures= new AtomicInteger(0); diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateParserSDFTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateParserSDFTest.java index 78577512e..304332bf7 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDateParserSDFTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDateParserSDFTest.java @@ -36,7 +36,7 @@ import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; /** - * Compare FastDateParser with SimpleDateFormat + * Compare FastDateParser with SimpleDateFormat */ @RunWith(Parameterized.class) public class FastDateParserSDFTest { @@ -184,9 +184,9 @@ public class FastDateParserSDFTest { fdfE = e.getClass(); } if (valid) { - assertEquals(locale.toString()+" "+formattedDate +"\n",expectedTime, actualTime); + assertEquals(locale.toString()+" "+formattedDate +"\n",expectedTime, actualTime); } else { - assertEquals(locale.toString()+" "+formattedDate + " expected same Exception ", sdfE, fdfE); + assertEquals(locale.toString()+" "+formattedDate + " expected same Exception ", sdfE, fdfE); } } private void checkParsePosition(final String formattedDate) { @@ -203,12 +203,12 @@ public class FastDateParserSDFTest { final int length = formattedDate.length(); if (endIndex != length) { // Error in test data - throw new RuntimeException("Test data error: expected SDF parse to consume entire string; endindex " + endIndex + " != " + length); + throw new RuntimeException("Test data error: expected SDF parse to consume entire string; endindex " + endIndex + " != " + length); } } else { final int errorIndex = sdfP.getErrorIndex(); if (errorIndex == -1) { - throw new RuntimeException("Test data error: expected SDF parse to fail, but got " + expectedTime); + throw new RuntimeException("Test data error: expected SDF parse to fail, but got " + expectedTime); } } @@ -225,6 +225,6 @@ public class FastDateParserSDFTest { assertNotEquals("Test data error: expected FDF parse to fail, but got " + actualTime, -1, fdferrorIndex); assertTrue("FDF error index ("+ fdferrorIndex + ") should approximate SDF index (" + sdferrorIndex + ")", sdferrorIndex - fdferrorIndex <= 4); - } + } } } diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java index ed70757ce..c637f79e6 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDateParserTest.java @@ -343,7 +343,7 @@ public class FastDateParserTest { } } } - + @Test public void testJpLocales() { @@ -421,7 +421,7 @@ public class FastDateParserTest { testSdfAndFdp("''yyyyMMdd'A''B'HHmmssSSS''", "'20030210A'B153320989'", false); // OK testSdfAndFdp("''''yyyyMMdd'A''B'HHmmssSSS''", "''20030210A'B153320989'", false); // OK testSdfAndFdp("'$\\Ed'" ,"$\\Ed", false); // OK - + // quoted charaters are case sensitive testSdfAndFdp("'QED'", "QED", false); testSdfAndFdp("'QED'", "qed", true); @@ -429,7 +429,7 @@ public class FastDateParserTest { testSdfAndFdp("yyyy-MM-dd 'QED'", "2003-02-10 QED", false); testSdfAndFdp("yyyy-MM-dd 'QED'", "2003-02-10 qed", true); } - + @Test public void testLANG_832() throws Exception { testSdfAndFdp("'d'd" ,"d3", false); // OK @@ -593,19 +593,19 @@ public class FastDateParserTest { final DateParser parser= getInstance(yMdHmsSZ, REYKJAVIK); assertEquals(REYKJAVIK, parser.getTimeZone()); } - + @Test public void testLang996() throws ParseException { final Calendar expected = Calendar.getInstance(NEW_YORK, Locale.US); expected.clear(); expected.set(2014, Calendar.MAY, 14); - final DateParser fdp = getInstance("ddMMMyyyy", NEW_YORK, Locale.US); + final DateParser fdp = getInstance("ddMMMyyyy", NEW_YORK, Locale.US); assertEquals(expected.getTime(), fdp.parse("14may2014")); assertEquals(expected.getTime(), fdp.parse("14MAY2014")); assertEquals(expected.getTime(), fdp.parse("14May2014")); } - + @Test(expected = IllegalArgumentException.class) public void test1806Argument() { getInstance("XXXX"); @@ -624,8 +624,8 @@ public class FastDateParserTest { } private static enum Expected1806 { - India(INDIA, "+05", "+0530", "+05:30", true), - Greenwich(GMT, "Z", "Z", "Z", false), + India(INDIA, "+05", "+0530", "+05:30", true), + Greenwich(GMT, "Z", "Z", "Z", false), NewYork(NEW_YORK, "-05", "-0500", "-05:00", false); private Expected1806(final TimeZone zone, final String one, final String two, final String three, final boolean hasHalfHourOffset) { @@ -642,17 +642,17 @@ public class FastDateParserTest { final String three; final long offset; } - + @Test public void test1806() throws ParseException { final String formatStub = "yyyy-MM-dd'T'HH:mm:ss.SSS"; final String dateStub = "2001-02-04T12:08:56.235"; - + for (final Expected1806 trial : Expected1806.values()) { final Calendar cal = initializeCalendar(trial.zone); final String message = trial.zone.getDisplayName()+";"; - + DateParser parser = getInstance(formatStub+"X", trial.zone); assertEquals(message+trial.one, cal.getTime().getTime(), parser.parse(dateStub+trial.one).getTime()-trial.offset); diff --git a/src/test/java/org/apache/commons/lang3/time/FastDateParser_MoreOrLessTest.java b/src/test/java/org/apache/commons/lang3/time/FastDateParser_MoreOrLessTest.java index 970deb750..699bac74a 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDateParser_MoreOrLessTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDateParser_MoreOrLessTest.java @@ -28,15 +28,15 @@ import org.junit.Test; public class FastDateParser_MoreOrLessTest { private static final TimeZone NEW_YORK = TimeZone.getTimeZone("America/New_York"); - + @Test public void testInputHasPrecedingCharacters() { final FastDateParser parser = new FastDateParser("MM/dd", TimeZone.getDefault(), Locale.getDefault()); final ParsePosition parsePosition = new ParsePosition(0); final Date date = parser.parse("A 3/23/61", parsePosition); Assert.assertNull(date); - Assert.assertEquals(0, parsePosition.getIndex()); - Assert.assertEquals(0, parsePosition.getErrorIndex()); + Assert.assertEquals(0, parsePosition.getIndex()); + Assert.assertEquals(0, parsePosition.getErrorIndex()); } @Test @@ -51,7 +51,7 @@ public class FastDateParser_MoreOrLessTest { calendar.setTime(date); Assert.assertEquals(1961, calendar.get(Calendar.YEAR)); Assert.assertEquals(2, calendar.get(Calendar.MONTH)); - Assert.assertEquals(23, calendar.get(Calendar.DATE)); + Assert.assertEquals(23, calendar.get(Calendar.DATE)); } @Test @@ -64,9 +64,9 @@ public class FastDateParser_MoreOrLessTest { final Calendar calendar = Calendar.getInstance(); calendar.setTime(date); Assert.assertEquals(2, calendar.get(Calendar.MONTH)); - Assert.assertEquals(23, calendar.get(Calendar.DATE)); + Assert.assertEquals(23, calendar.get(Calendar.DATE)); } - + @Test public void testInputHasWrongCharacters() { final FastDateParser parser = new FastDateParser("MM-dd-yyy", TimeZone.getDefault(), Locale.getDefault()); @@ -74,7 +74,7 @@ public class FastDateParser_MoreOrLessTest { Assert.assertNull(parser.parse("03/23/1961", parsePosition)); Assert.assertEquals(2, parsePosition.getErrorIndex()); } - + @Test public void testInputHasLessCharacters() { final FastDateParser parser = new FastDateParser("MM/dd/yyy", TimeZone.getDefault(), Locale.getDefault()); @@ -82,21 +82,21 @@ public class FastDateParser_MoreOrLessTest { Assert.assertNull(parser.parse("03/23", parsePosition)); Assert.assertEquals(5, parsePosition.getErrorIndex()); } - + @Test public void testInputHasWrongTimeZone() { final FastDateParser parser = new FastDateParser("mm:ss z", NEW_YORK, Locale.US); - + final String input = "11:23 Pacific Standard Time"; final ParsePosition parsePosition = new ParsePosition(0); Assert.assertNotNull(parser.parse(input, parsePosition)); Assert.assertEquals(input.length(), parsePosition.getIndex()); - + parsePosition.setIndex(0); Assert.assertNull(parser.parse( "11:23 Pacific Standard ", parsePosition)); Assert.assertEquals(6, parsePosition.getErrorIndex()); } - + @Test public void testInputHasWrongDay() { final FastDateParser parser = new FastDateParser("EEEE, MM/dd/yyy", NEW_YORK, Locale.US); @@ -104,7 +104,7 @@ public class FastDateParser_MoreOrLessTest { final ParsePosition parsePosition = new ParsePosition(0); Assert.assertNotNull(parser.parse(input, parsePosition)); Assert.assertEquals(input.length(), parsePosition.getIndex()); - + parsePosition.setIndex(0); Assert.assertNull(parser.parse( "Thorsday, 03/23/61", parsePosition)); Assert.assertEquals(0, parsePosition.getErrorIndex()); diff --git a/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java b/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java index fa8836ef6..8d8372677 100644 --- a/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java +++ b/src/test/java/org/apache/commons/lang3/time/FastDatePrinterTest.java @@ -42,7 +42,7 @@ import org.junit.Test; * @since 3.0 */ public class FastDatePrinterTest { - + private static final String YYYY_MM_DD = "yyyy/MM/dd"; private static final TimeZone NEW_YORK = TimeZone.getTimeZone("America/New_York"); private static final TimeZone GMT = TimeZone.getTimeZone("GMT"); @@ -226,36 +226,36 @@ public class FastDatePrinterTest { assertEquals("fredag, week 53", fdf.format(d)); } - + @Test public void testEquals() { final DatePrinter printer1= getInstance(YYYY_MM_DD); final DatePrinter printer2= getInstance(YYYY_MM_DD); assertEquals(printer1, printer2); - assertEquals(printer1.hashCode(), printer2.hashCode()); + assertEquals(printer1.hashCode(), printer2.hashCode()); assertFalse(printer1.equals(new Object())); } - + @Test public void testToStringContainsName() { final DatePrinter printer= getInstance(YYYY_MM_DD); assertTrue(printer.toString().startsWith("FastDate")); } - + @Test public void testPatternMatches() { final DatePrinter printer= getInstance(YYYY_MM_DD); assertEquals(YYYY_MM_DD, printer.getPattern()); } - + @Test public void testLocaleMatches() { final DatePrinter printer= getInstance(YYYY_MM_DD, SWEDEN); assertEquals(SWEDEN, printer.getLocale()); } - + @Test public void testTimeZoneMatches() { final DatePrinter printer= getInstance(YYYY_MM_DD, NEW_YORK); @@ -268,10 +268,10 @@ public class FastDatePrinterTest { final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC")); final FastDateFormat noColonFormat = FastDateFormat.getInstance("Z"); assertEquals("+0000", noColonFormat.format(c)); - + final FastDateFormat isoFormat = FastDateFormat.getInstance("ZZ"); assertEquals("Z", isoFormat.format(c)); - + final FastDateFormat colonFormat = FastDateFormat.getInstance("ZZZ"); assertEquals("+00:00", colonFormat.format(c)); } @@ -325,7 +325,7 @@ public class FastDatePrinterTest { assertEquals(trial.three, printer.format(cal)); } } - + @Test public void testLang1103() throws ParseException { final Calendar cal = Calendar.getInstance(SWEDEN); diff --git a/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java b/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java index eefe2b323..645b680e5 100644 --- a/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java +++ b/src/test/java/org/apache/commons/lang3/time/StopWatchTest.java @@ -5,9 +5,9 @@ * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -41,10 +41,10 @@ public class StopWatchTest { watch.stop(); final long time = watch.getTime(); assertEquals(time, watch.getTime()); - + assertTrue(time >= 500); assertTrue(time < 700); - + watch.reset(); assertEquals(0, watch.getTime()); } @@ -54,13 +54,13 @@ public class StopWatchTest { final StopWatch watch = StopWatch.createStarted(); assertTrue(watch.isStarted()); } - + @Test public void testStopWatchSimpleGet(){ final StopWatch watch = new StopWatch(); assertEquals(0, watch.getTime()); assertEquals("00:00:00.000", watch.toString()); - + watch.start(); try {Thread.sleep(500);} catch (final InterruptedException ex) {} assertTrue(watch.getTime() < 2000); @@ -95,14 +95,14 @@ public class StopWatchTest { watch.stop(); final long totalTime = watch.getTime(); - assertEquals("Formatted split string not the correct length", + assertEquals("Formatted split string not the correct length", splitStr.length(), 12); assertTrue(splitTime >= 500); assertTrue(splitTime < 700); assertTrue(totalTime >= 1500); assertTrue(totalTime < 1900); } - + @Test public void testStopWatchSuspend(){ final StopWatch watch = new StopWatch(); @@ -115,7 +115,7 @@ public class StopWatchTest { try {Thread.sleep(550);} catch (final InterruptedException ex) {} watch.stop(); final long totalTime = watch.getTime(); - + assertTrue(suspendTime >= 500); assertTrue(suspendTime < 700); assertTrue(totalTime >= 1000); @@ -275,7 +275,7 @@ public class StopWatchTest { * Creates a suspended StopWatch object which appears to have elapsed * for the requested amount of time in nanoseconds. * <p> - * + * * <pre> * // Create a mock StopWatch with a time of 2:59:01.999 * final long nanos = TimeUnit.HOURS.toNanos(2) @@ -284,7 +284,7 @@ public class StopWatchTest { * + TimeUnit.MILLISECONDS.toNanos(999); * final StopWatch watch = createMockStopWatch(nanos); * </pre> - * + * * @param nanos Time in nanoseconds to have elapsed on the stop watch * @return StopWatch in a suspended state with the elapsed time */ diff --git a/src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java b/src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java index eaedef3e1..998ab1c6a 100644 --- a/src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java +++ b/src/test/java/org/apache/commons/lang3/tuple/ImmutablePairTest.java @@ -78,37 +78,37 @@ public class ImmutablePairTest { public void testHashCode() throws Exception { assertEquals(ImmutablePair.of(null, "foo").hashCode(), ImmutablePair.of(null, "foo").hashCode()); } - + @Test public void testNullPairEquals() { assertEquals(ImmutablePair.nullPair(), ImmutablePair.nullPair()); } - + @Test public void testNullPairSame() { assertSame(ImmutablePair.nullPair(), ImmutablePair.nullPair()); } - + @Test public void testNullPairLeft() { assertNull(ImmutablePair.nullPair().getLeft()); } - + @Test public void testNullPairKey() { assertNull(ImmutablePair.nullPair().getKey()); } - + @Test public void testNullPairRight() { assertNull(ImmutablePair.nullPair().getRight()); } - + @Test public void testNullPairValue() { assertNull(ImmutablePair.nullPair().getValue()); } - + @Test public void testNullPairTyped() { // No compiler warnings @@ -116,7 +116,7 @@ public class ImmutablePairTest { ImmutablePair<String, String> pair = ImmutablePair.nullPair(); assertNotNull(pair); } - + @Test public void testToString() throws Exception { assertEquals("(null,null)", ImmutablePair.of(null, null).toString()); diff --git a/src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java b/src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java index 3be666069..d126d6e7b 100644 --- a/src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java +++ b/src/test/java/org/apache/commons/lang3/tuple/ImmutableTripleTest.java @@ -91,27 +91,27 @@ public class ImmutableTripleTest { public void testNullTripleEquals() { assertEquals(ImmutableTriple.nullTriple(), ImmutableTriple.nullTriple()); } - + @Test public void testNullTripleSame() { assertSame(ImmutableTriple.nullTriple(), ImmutableTriple.nullTriple()); } - + @Test public void testNullTripleLeft() { assertNull(ImmutableTriple.nullTriple().getLeft()); } - + @Test public void testNullTripleMiddle() { assertNull(ImmutableTriple.nullTriple().getMiddle()); } - + @Test public void testNullTripleRight() { assertNull(ImmutableTriple.nullTriple().getRight()); } - + @Test public void testNullTripleTyped() { // No compiler warnings diff --git a/src/test/java/org/apache/commons/lang3/tuple/MutablePairTest.java b/src/test/java/org/apache/commons/lang3/tuple/MutablePairTest.java index b8eed248e..edd8fe9cd 100644 --- a/src/test/java/org/apache/commons/lang3/tuple/MutablePairTest.java +++ b/src/test/java/org/apache/commons/lang3/tuple/MutablePairTest.java @@ -49,7 +49,7 @@ public class MutablePairTest { assertNull(pair.getLeft()); assertNull(pair.getRight()); } - + @Test public void testMutate() throws Exception { final MutablePair<Integer, String> pair = new MutablePair<>(0, "foo"); diff --git a/src/test/java/org/apache/commons/lang3/tuple/MutableTripleTest.java b/src/test/java/org/apache/commons/lang3/tuple/MutableTripleTest.java index dc18ddb3d..5ca0aaeb3 100644 --- a/src/test/java/org/apache/commons/lang3/tuple/MutableTripleTest.java +++ b/src/test/java/org/apache/commons/lang3/tuple/MutableTripleTest.java @@ -52,7 +52,7 @@ public class MutableTripleTest { assertNull(triple.getMiddle()); assertNull(triple.getRight()); } - + @Test public void testMutate() throws Exception { final MutableTriple<Integer, String, Boolean> triple = new MutableTriple<>(0, "foo", Boolean.TRUE); |