Use final consistently.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1606051 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ba8c6f6d6f
commit
96c30e248d
|
@ -1570,7 +1570,7 @@ public static void reverse(final boolean[] array) {
|
|||
* change. Overvalue (>array.length) is demoted to array length.
|
||||
* @since 3.2
|
||||
*/
|
||||
public static void reverse(final boolean[] array, int startIndexInclusive, int endIndexExclusive) {
|
||||
public static void reverse(final boolean[] array, final int startIndexInclusive, final int endIndexExclusive) {
|
||||
if (array == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -1605,7 +1605,7 @@ public static void reverse(final boolean[] array, int startIndexInclusive, int e
|
|||
* change. Overvalue (>array.length) is demoted to array length.
|
||||
* @since 3.2
|
||||
*/
|
||||
public static void reverse(final byte[] array, int startIndexInclusive, int endIndexExclusive) {
|
||||
public static void reverse(final byte[] array, final int startIndexInclusive, final int endIndexExclusive) {
|
||||
if (array == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -1640,7 +1640,7 @@ public static void reverse(final byte[] array, int startIndexInclusive, int endI
|
|||
* change. Overvalue (>array.length) is demoted to array length.
|
||||
* @since 3.2
|
||||
*/
|
||||
public static void reverse(final char[] array, int startIndexInclusive, int endIndexExclusive) {
|
||||
public static void reverse(final char[] array, final int startIndexInclusive, final int endIndexExclusive) {
|
||||
if (array == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -1675,7 +1675,7 @@ public static void reverse(final char[] array, int startIndexInclusive, int endI
|
|||
* change. Overvalue (>array.length) is demoted to array length.
|
||||
* @since 3.2
|
||||
*/
|
||||
public static void reverse(final double[] array, int startIndexInclusive, int endIndexExclusive) {
|
||||
public static void reverse(final double[] array, final int startIndexInclusive, final int endIndexExclusive) {
|
||||
if (array == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -1710,7 +1710,7 @@ public static void reverse(final double[] array, int startIndexInclusive, int en
|
|||
* change. Overvalue (>array.length) is demoted to array length.
|
||||
* @since 3.2
|
||||
*/
|
||||
public static void reverse(final float[] array, int startIndexInclusive, int endIndexExclusive) {
|
||||
public static void reverse(final float[] array, final int startIndexInclusive, final int endIndexExclusive) {
|
||||
if (array == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -1745,7 +1745,7 @@ public static void reverse(final float[] array, int startIndexInclusive, int end
|
|||
* change. Overvalue (>array.length) is demoted to array length.
|
||||
* @since 3.2
|
||||
*/
|
||||
public static void reverse(final int[] array, int startIndexInclusive, int endIndexExclusive) {
|
||||
public static void reverse(final int[] array, final int startIndexInclusive, final int endIndexExclusive) {
|
||||
if (array == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -1780,7 +1780,7 @@ public static void reverse(final int[] array, int startIndexInclusive, int endIn
|
|||
* change. Overvalue (>array.length) is demoted to array length.
|
||||
* @since 3.2
|
||||
*/
|
||||
public static void reverse(final long[] array, int startIndexInclusive, int endIndexExclusive) {
|
||||
public static void reverse(final long[] array, final int startIndexInclusive, final int endIndexExclusive) {
|
||||
if (array == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -1815,7 +1815,7 @@ public static void reverse(final long[] array, int startIndexInclusive, int endI
|
|||
* change. Overvalue (>array.length) is demoted to array length.
|
||||
* @since 3.2
|
||||
*/
|
||||
public static void reverse(final Object[] array, int startIndexInclusive, int endIndexExclusive) {
|
||||
public static void reverse(final Object[] array, final int startIndexInclusive, final int endIndexExclusive) {
|
||||
if (array == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -1850,7 +1850,7 @@ public static void reverse(final Object[] array, int startIndexInclusive, int en
|
|||
* change. Overvalue (>array.length) is demoted to array length.
|
||||
* @since 3.2
|
||||
*/
|
||||
public static void reverse(final short[] array, int startIndexInclusive, int endIndexExclusive) {
|
||||
public static void reverse(final short[] array, final int startIndexInclusive, final int endIndexExclusive) {
|
||||
if (array == null) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -193,8 +193,8 @@ static boolean regionMatches(final CharSequence cs, final boolean ignoreCase, fi
|
|||
int tmpLen = length;
|
||||
|
||||
while (tmpLen-- > 0) {
|
||||
char c1 = cs.charAt(index1++);
|
||||
char c2 = substring.charAt(index2++);
|
||||
final char c1 = cs.charAt(index1++);
|
||||
final char c2 = substring.charAt(index2++);
|
||||
|
||||
if (c1 == c2) {
|
||||
continue;
|
||||
|
|
|
@ -80,7 +80,7 @@ public static String toFullyQualifiedName(final Class<?> context, final String r
|
|||
public static String toFullyQualifiedName(final Package context, final String resourceName) {
|
||||
Validate.notNull(context, "Parameter '%s' must not be null!", "context" );
|
||||
Validate.notNull(resourceName, "Parameter '%s' must not be null!", "resourceName");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(context.getName());
|
||||
sb.append(".");
|
||||
sb.append(resourceName);
|
||||
|
@ -129,7 +129,7 @@ public static String toFullyQualifiedPath(final Class<?> context, final String r
|
|||
public static String toFullyQualifiedPath(final Package context, final String resourceName) {
|
||||
Validate.notNull(context, "Parameter '%s' must not be null!", "context" );
|
||||
Validate.notNull(resourceName, "Parameter '%s' must not be null!", "resourceName");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(context.getName().replace('.', '/'));
|
||||
sb.append("/");
|
||||
sb.append(resourceName);
|
||||
|
|
|
@ -127,7 +127,7 @@ public enum Interfaces {
|
|||
m.put("char", "C");
|
||||
m.put("void", "V");
|
||||
final Map<String, String> r = new HashMap<String, String>();
|
||||
for (Map.Entry<String, String> e : m.entrySet()) {
|
||||
for (final Map.Entry<String, String> e : m.entrySet()) {
|
||||
r.put(e.getValue(), e.getKey());
|
||||
}
|
||||
abbreviationMap = Collections.unmodifiableMap(m);
|
||||
|
@ -1158,7 +1158,7 @@ public static Iterable<Class<?>> hierarchy(final Class<?> type) {
|
|||
* @return Iterable an Iterable over the class hierarchy of the given class
|
||||
* @since 3.2
|
||||
*/
|
||||
public static Iterable<Class<?>> hierarchy(final Class<?> type, Interfaces interfacesBehavior) {
|
||||
public static Iterable<Class<?>> hierarchy(final Class<?> type, final Interfaces interfacesBehavior) {
|
||||
final Iterable<Class<?>> classes = new Iterable<Class<?>>() {
|
||||
|
||||
@Override
|
||||
|
@ -1219,8 +1219,8 @@ public Class<?> next() {
|
|||
return nextSuperclass;
|
||||
}
|
||||
|
||||
private void walkInterfaces(Set<Class<?>> addTo, Class<?> c) {
|
||||
for (Class<?> iface : c.getInterfaces()) {
|
||||
private void walkInterfaces(final Set<Class<?>> addTo, final Class<?> c) {
|
||||
for (final Class<?> iface : c.getInterfaces()) {
|
||||
if (!seenInterfaces.contains(iface)) {
|
||||
addTo.add(iface);
|
||||
}
|
||||
|
|
|
@ -266,7 +266,7 @@ public static <E extends Enum<E>> EnumSet<E> processBitVector(final Class<E> enu
|
|||
*/
|
||||
public static <E extends Enum<E>> EnumSet<E> processBitVectors(final Class<E> enumClass, final long... values) {
|
||||
final EnumSet<E> results = EnumSet.noneOf(asEnum(enumClass));
|
||||
long[] lvalues = ArrayUtils.clone(Validate.notNull(values));
|
||||
final long[] lvalues = ArrayUtils.clone(Validate.notNull(values));
|
||||
ArrayUtils.reverse(lvalues);
|
||||
for (final E constant : enumClass.getEnumConstants()) {
|
||||
final int block = constant.ordinal() / Long.SIZE;
|
||||
|
|
|
@ -123,8 +123,8 @@ public static Locale toLocale(final String str) {
|
|||
return new Locale("", str.substring(1, 3), str.substring(4));
|
||||
}
|
||||
|
||||
String[] split = str.split("_", -1);
|
||||
int occurrences = split.length -1;
|
||||
final String[] split = str.split("_", -1);
|
||||
final int occurrences = split.length -1;
|
||||
switch (occurrences) {
|
||||
case 0:
|
||||
if (StringUtils.isAllLowerCase(str) && (len == 2 || len == 3)) {
|
||||
|
|
|
@ -239,7 +239,7 @@ public static int hashCodeMulti(final Object... objects) {
|
|||
int hash = 1;
|
||||
if (objects != null) {
|
||||
for (final Object object : objects) {
|
||||
int tmpHash = ObjectUtils.hashCode(object);
|
||||
final int tmpHash = ObjectUtils.hashCode(object);
|
||||
hash = hash * 31 + tmpHash;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,10 +59,10 @@ public RandomUtils() {
|
|||
* @return the random byte array
|
||||
* @throws IllegalArgumentException if {@code count} is negative
|
||||
*/
|
||||
public static byte[] nextBytes(int count) {
|
||||
public static byte[] nextBytes(final int count) {
|
||||
Validate.isTrue(count >= 0, "Count cannot be negative.");
|
||||
|
||||
byte[] result = new byte[count];
|
||||
final byte[] result = new byte[count];
|
||||
RANDOM.nextBytes(result);
|
||||
return result;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public static byte[] nextBytes(int count) {
|
|||
* {@code startInclusive} is negative
|
||||
* @return the random integer
|
||||
*/
|
||||
public static int nextInt(int startInclusive, int endExclusive) {
|
||||
public static int nextInt(final int startInclusive, final int endExclusive) {
|
||||
Validate.isTrue(endExclusive >= startInclusive,
|
||||
"Start value must be smaller or equal to end value.");
|
||||
Validate.isTrue(startInclusive >= 0, "Both range values must be non-negative.");
|
||||
|
@ -107,7 +107,7 @@ public static int nextInt(int startInclusive, int endExclusive) {
|
|||
* {@code startInclusive} is negative
|
||||
* @return the random long
|
||||
*/
|
||||
public static long nextLong(long startInclusive, long endExclusive) {
|
||||
public static long nextLong(final long startInclusive, final long endExclusive) {
|
||||
Validate.isTrue(endExclusive >= startInclusive,
|
||||
"Start value must be smaller or equal to end value.");
|
||||
Validate.isTrue(startInclusive >= 0, "Both range values must be non-negative.");
|
||||
|
@ -134,7 +134,7 @@ public static long nextLong(long startInclusive, long endExclusive) {
|
|||
* {@code startInclusive} is negative
|
||||
* @return the random double
|
||||
*/
|
||||
public static double nextDouble(double startInclusive, double endInclusive) {
|
||||
public static double nextDouble(final double startInclusive, final double endInclusive) {
|
||||
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.");
|
||||
|
@ -160,7 +160,7 @@ public static double nextDouble(double startInclusive, double endInclusive) {
|
|||
* {@code startInclusive} is negative
|
||||
* @return the random float
|
||||
*/
|
||||
public static float nextFloat(float startInclusive, float endInclusive) {
|
||||
public static float nextFloat(final float startInclusive, final float endInclusive) {
|
||||
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.");
|
||||
|
|
|
@ -255,11 +255,11 @@ public static boolean isNotEmpty(final CharSequence cs) {
|
|||
* @return {@code true} if any of the CharSequences are empty or null
|
||||
* @since 3.2
|
||||
*/
|
||||
public static boolean isAnyEmpty(CharSequence... css) {
|
||||
public static boolean isAnyEmpty(final CharSequence... css) {
|
||||
if (ArrayUtils.isEmpty(css)) {
|
||||
return true;
|
||||
}
|
||||
for (CharSequence cs : css){
|
||||
for (final CharSequence cs : css){
|
||||
if (isEmpty(cs)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ public static boolean isAnyEmpty(CharSequence... css) {
|
|||
* @return {@code true} if none of the CharSequences are empty or null
|
||||
* @since 3.2
|
||||
*/
|
||||
public static boolean isNoneEmpty(CharSequence... css) {
|
||||
public static boolean isNoneEmpty(final CharSequence... css) {
|
||||
return !isAnyEmpty(css);
|
||||
}
|
||||
/**
|
||||
|
@ -355,11 +355,11 @@ public static boolean isNotBlank(final CharSequence cs) {
|
|||
* @return {@code true} if any of the CharSequences are blank or null or whitespace only
|
||||
* @since 3.2
|
||||
*/
|
||||
public static boolean isAnyBlank(CharSequence... css) {
|
||||
public static boolean isAnyBlank(final CharSequence... css) {
|
||||
if (ArrayUtils.isEmpty(css)) {
|
||||
return true;
|
||||
}
|
||||
for (CharSequence cs : css){
|
||||
for (final CharSequence cs : css){
|
||||
if (isBlank(cs)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -385,7 +385,7 @@ public static boolean isAnyBlank(CharSequence... css) {
|
|||
* @return {@code true} if none of the CharSequences are blank or null or whitespace only
|
||||
* @since 3.2
|
||||
*/
|
||||
public static boolean isNoneBlank(CharSequence... css) {
|
||||
public static boolean isNoneBlank(final CharSequence... css) {
|
||||
return !isAnyBlank(css);
|
||||
}
|
||||
|
||||
|
@ -4041,6 +4041,7 @@ public static String join(final Iterator<?> iterator, final char separator) {
|
|||
final Object first = iterator.next();
|
||||
if (!iterator.hasNext()) {
|
||||
@SuppressWarnings( "deprecation" ) // ObjectUtils.toString(Object) has been deprecated in 3.2
|
||||
final
|
||||
String result = ObjectUtils.toString(first);
|
||||
return result;
|
||||
}
|
||||
|
@ -5689,7 +5690,7 @@ public static String capitalize(final String str) {
|
|||
return str;
|
||||
}
|
||||
|
||||
char firstChar = str.charAt(0);
|
||||
final char firstChar = str.charAt(0);
|
||||
if (Character.isTitleCase(firstChar)) {
|
||||
// already capitalized
|
||||
return str;
|
||||
|
@ -5727,7 +5728,7 @@ public static String uncapitalize(final String str) {
|
|||
return str;
|
||||
}
|
||||
|
||||
char firstChar = str.charAt(0);
|
||||
final char firstChar = str.charAt(0);
|
||||
if (Character.isLowerCase(firstChar)) {
|
||||
// already uncapitalized
|
||||
return str;
|
||||
|
@ -7126,11 +7127,11 @@ public static int getFuzzyDistance(final CharSequence term, final CharSequence q
|
|||
int previousMatchingCharacterIndex = Integer.MIN_VALUE;
|
||||
|
||||
for (int queryIndex = 0; queryIndex < queryLowerCase.length(); queryIndex++) {
|
||||
char queryChar = queryLowerCase.charAt(queryIndex);
|
||||
final char queryChar = queryLowerCase.charAt(queryIndex);
|
||||
|
||||
boolean termCharacterMatchFound = false;
|
||||
for (; termIndex < termLowerCase.length() && !termCharacterMatchFound; termIndex++) {
|
||||
char termChar = termLowerCase.charAt(termIndex);
|
||||
final char termChar = termLowerCase.charAt(termIndex);
|
||||
|
||||
if (queryChar == termChar) {
|
||||
// simple character matches result in one point
|
||||
|
@ -7191,7 +7192,7 @@ private static String getSetOfMatchingCharacterWithin(final CharSequence first,
|
|||
* @param second The second string.
|
||||
* @return The number of transposition between the two strings.
|
||||
*/
|
||||
private static int transpositions(CharSequence first, CharSequence second) {
|
||||
private static int transpositions(final CharSequence first, final CharSequence second) {
|
||||
int transpositions = 0;
|
||||
for (int i = 0; i < first.length(); i++) {
|
||||
if (first.charAt(i) != second.charAt(i)) {
|
||||
|
@ -7208,7 +7209,7 @@ private static int transpositions(CharSequence first, CharSequence second) {
|
|||
* @param second The second string.
|
||||
* @return A number between 0 and 4.
|
||||
*/
|
||||
private static int commonPrefixLength(CharSequence first, CharSequence second) {
|
||||
private static int commonPrefixLength(final CharSequence first, final CharSequence second) {
|
||||
final int result = getCommonPrefix(first.toString(), second.toString()).length();
|
||||
|
||||
// Limit the result to 4.
|
||||
|
@ -7714,7 +7715,7 @@ public static String toString(final byte[] bytes, final String charsetName) thro
|
|||
* @since 3.2
|
||||
* @since 3.3 No longer throws {@link UnsupportedEncodingException}.
|
||||
*/
|
||||
public static String toEncodedString(byte[] bytes, Charset charset) {
|
||||
public static String toEncodedString(final byte[] bytes, final Charset charset) {
|
||||
return new String(bytes, charset != null ? charset : Charset.defaultCharset());
|
||||
}
|
||||
|
||||
|
@ -7739,7 +7740,7 @@ public static String toEncodedString(byte[] bytes, Charset charset) {
|
|||
* @return the wrapped string, or {@code null} if {@code str==null}
|
||||
* @since 3.4
|
||||
*/
|
||||
public static String wrap(String str, char wrapWith) {
|
||||
public static String wrap(final String str, final char wrapWith) {
|
||||
|
||||
if (isEmpty(str) || wrapWith == '\0') {
|
||||
return str;
|
||||
|
@ -7777,7 +7778,7 @@ public static String wrap(String str, char wrapWith) {
|
|||
* @return wrapped String, {@code null} if null String input
|
||||
* @since 3.4
|
||||
*/
|
||||
public static String wrap(String str, String wrapWith) {
|
||||
public static String wrap(final String str, final String wrapWith) {
|
||||
|
||||
if (isEmpty(str) || isEmpty(wrapWith)) {
|
||||
return str;
|
||||
|
|
|
@ -940,7 +940,7 @@ public static <T> void inclusiveBetween(final T start, final T end, final Compar
|
|||
* @since 3.3
|
||||
*/
|
||||
@SuppressWarnings("boxing")
|
||||
public static void inclusiveBetween(long start, long end, long value) {
|
||||
public static void inclusiveBetween(final long start, final long end, final long value) {
|
||||
// TODO when breaking BC, consider returning value
|
||||
if (value < start || value > end) {
|
||||
throw new IllegalArgumentException(String.format(DEFAULT_INCLUSIVE_BETWEEN_EX_MESSAGE, value, start, end));
|
||||
|
@ -963,7 +963,7 @@ public static void inclusiveBetween(long start, long end, long value) {
|
|||
*
|
||||
* @since 3.3
|
||||
*/
|
||||
public static void inclusiveBetween(long start, long end, long value, String message) {
|
||||
public static void inclusiveBetween(final long start, final long end, final long value, final String message) {
|
||||
// TODO when breaking BC, consider returning value
|
||||
if (value < start || value > end) {
|
||||
throw new IllegalArgumentException(String.format(message));
|
||||
|
@ -984,7 +984,7 @@ public static void inclusiveBetween(long start, long end, long value, String mes
|
|||
* @since 3.3
|
||||
*/
|
||||
@SuppressWarnings("boxing")
|
||||
public static void inclusiveBetween(double start, double end, double value) {
|
||||
public static void inclusiveBetween(final double start, final double end, final double value) {
|
||||
// TODO when breaking BC, consider returning value
|
||||
if (value < start || value > end) {
|
||||
throw new IllegalArgumentException(String.format(DEFAULT_INCLUSIVE_BETWEEN_EX_MESSAGE, value, start, end));
|
||||
|
@ -1007,7 +1007,7 @@ public static void inclusiveBetween(double start, double end, double value) {
|
|||
*
|
||||
* @since 3.3
|
||||
*/
|
||||
public static void inclusiveBetween(double start, double end, double value, String message) {
|
||||
public static void inclusiveBetween(final double start, final double end, final double value, final String message) {
|
||||
// TODO when breaking BC, consider returning value
|
||||
if (value < start || value > end) {
|
||||
throw new IllegalArgumentException(String.format(message));
|
||||
|
@ -1078,7 +1078,7 @@ public static <T> void exclusiveBetween(final T start, final T end, final Compar
|
|||
* @since 3.3
|
||||
*/
|
||||
@SuppressWarnings("boxing")
|
||||
public static void exclusiveBetween(long start, long end, long value) {
|
||||
public static void exclusiveBetween(final long start, final long end, final long value) {
|
||||
// TODO when breaking BC, consider returning value
|
||||
if (value <= start || value >= end) {
|
||||
throw new IllegalArgumentException(String.format(DEFAULT_EXCLUSIVE_BETWEEN_EX_MESSAGE, value, start, end));
|
||||
|
@ -1101,7 +1101,7 @@ public static void exclusiveBetween(long start, long end, long value) {
|
|||
*
|
||||
* @since 3.3
|
||||
*/
|
||||
public static void exclusiveBetween(long start, long end, long value, String message) {
|
||||
public static void exclusiveBetween(final long start, final long end, final long value, final String message) {
|
||||
// TODO when breaking BC, consider returning value
|
||||
if (value <= start || value >= end) {
|
||||
throw new IllegalArgumentException(String.format(message));
|
||||
|
@ -1122,7 +1122,7 @@ public static void exclusiveBetween(long start, long end, long value, String mes
|
|||
* @since 3.3
|
||||
*/
|
||||
@SuppressWarnings("boxing")
|
||||
public static void exclusiveBetween(double start, double end, double value) {
|
||||
public static void exclusiveBetween(final double start, final double end, final double value) {
|
||||
// TODO when breaking BC, consider returning value
|
||||
if (value <= start || value >= end) {
|
||||
throw new IllegalArgumentException(String.format(DEFAULT_EXCLUSIVE_BETWEEN_EX_MESSAGE, value, start, end));
|
||||
|
@ -1145,7 +1145,7 @@ public static void exclusiveBetween(double start, double end, double value) {
|
|||
*
|
||||
* @since 3.3
|
||||
*/
|
||||
public static void exclusiveBetween(double start, double end, double value, String message) {
|
||||
public static void exclusiveBetween(final double start, final double end, final double value, final String message) {
|
||||
// TODO when breaking BC, consider returning value
|
||||
if (value <= start || value >= end) {
|
||||
throw new IllegalArgumentException(String.format(message));
|
||||
|
|
|
@ -56,7 +56,7 @@ public abstract class Diff<T> extends Pair<T, T> {
|
|||
* @param fieldName
|
||||
* the name of the field
|
||||
*/
|
||||
protected Diff(String fieldName) {
|
||||
protected Diff(final String fieldName) {
|
||||
this.type = ObjectUtils.defaultIfNull(
|
||||
TypeUtils.getTypeArguments(getClass(), Diff.class).get(
|
||||
Diff.class.getTypeParameters()[0]), Object.class);
|
||||
|
@ -112,7 +112,7 @@ public final String toString() {
|
|||
* @return nothing
|
||||
*/
|
||||
@Override
|
||||
public final T setValue(T value) {
|
||||
public final T setValue(final T value) {
|
||||
throw new UnsupportedOperationException("Cannot alter Diff object.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -177,15 +177,15 @@ public String toString() {
|
|||
*
|
||||
* @return a {@code String} description of the differences.
|
||||
*/
|
||||
public String toString(ToStringStyle style) {
|
||||
public String toString(final ToStringStyle style) {
|
||||
if (diffs.size() == 0) {
|
||||
return OBJECTS_SAME_STRING;
|
||||
}
|
||||
|
||||
ToStringBuilder lhsBuilder = new ToStringBuilder(lhs, style);
|
||||
ToStringBuilder rhsBuilder = new ToStringBuilder(rhs, style);
|
||||
final ToStringBuilder lhsBuilder = new ToStringBuilder(lhs, style);
|
||||
final ToStringBuilder rhsBuilder = new ToStringBuilder(rhs, style);
|
||||
|
||||
for (Diff<?> diff : diffs) {
|
||||
for (final Diff<?> diff : diffs) {
|
||||
lhsBuilder.append(diff.getFieldName(), diff.getLeft());
|
||||
rhsBuilder.append(diff.getFieldName(), diff.getRight());
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public RecursiveToStringStyle() {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void appendDetail(StringBuffer buffer, String fieldName, Object value) {
|
||||
public void appendDetail(final StringBuffer buffer, final String fieldName, final Object value) {
|
||||
if (!ClassUtils.isPrimitiveWrapper(value.getClass()) &&
|
||||
!String.class.equals(value.getClass()) &&
|
||||
accept(value.getClass())) {
|
||||
|
@ -79,7 +79,7 @@ public void appendDetail(StringBuffer buffer, String fieldName, Object value) {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void appendDetail(StringBuffer buffer, String fieldName, Collection<?> coll) {
|
||||
protected void appendDetail(final StringBuffer buffer, final String fieldName, final Collection<?> coll) {
|
||||
appendClassName(buffer, coll);
|
||||
appendIdentityHashCode(buffer, coll);
|
||||
appendDetail(buffer, fieldName, coll.toArray());
|
||||
|
|
|
@ -193,7 +193,7 @@ public static Field getDeclaredField(final Class<?> cls, final String fieldName,
|
|||
* if the class is {@code null}
|
||||
* @since 3.2
|
||||
*/
|
||||
public static Field[] getAllFields(Class<?> cls) {
|
||||
public static Field[] getAllFields(final Class<?> cls) {
|
||||
final List<Field> allFieldsList = getAllFieldsList(cls);
|
||||
return allFieldsList.toArray(new Field[allFieldsList.size()]);
|
||||
}
|
||||
|
@ -208,13 +208,13 @@ public static Field[] getAllFields(Class<?> cls) {
|
|||
* if the class is {@code null}
|
||||
* @since 3.2
|
||||
*/
|
||||
public static List<Field> getAllFieldsList(Class<?> cls) {
|
||||
public static List<Field> getAllFieldsList(final Class<?> cls) {
|
||||
Validate.isTrue(cls != null, "The class must not be null");
|
||||
final List<Field> allFields = new ArrayList<Field>();
|
||||
Class<?> currentClass = cls;
|
||||
while (currentClass != null) {
|
||||
final Field[] declaredFields = currentClass.getDeclaredFields();
|
||||
for (Field field : declaredFields) {
|
||||
for (final Field field : declaredFields) {
|
||||
allFields.add(field);
|
||||
}
|
||||
currentClass = currentClass.getSuperclass();
|
||||
|
@ -658,7 +658,7 @@ public static void writeField(final Field field, final Object target, final Obje
|
|||
* if the field is {@code null}
|
||||
* @since 3.2
|
||||
*/
|
||||
public static void removeFinalModifier(Field field) {
|
||||
public static void removeFinalModifier(final Field field) {
|
||||
removeFinalModifier(field, true);
|
||||
}
|
||||
|
||||
|
@ -675,13 +675,13 @@ public static void removeFinalModifier(Field field) {
|
|||
* if the field is {@code null}
|
||||
* @since 3.3
|
||||
*/
|
||||
public static void removeFinalModifier(Field field, boolean forceAccess) {
|
||||
public static void removeFinalModifier(final Field field, final boolean forceAccess) {
|
||||
Validate.isTrue(field != null, "The field must not be null");
|
||||
|
||||
try {
|
||||
if (Modifier.isFinal(field.getModifiers())) {
|
||||
// Do all JREs implement Field with a private ivar called "modifiers"?
|
||||
Field modifiersField = Field.class.getDeclaredField("modifiers");
|
||||
final Field modifiersField = Field.class.getDeclaredField("modifiers");
|
||||
final boolean doForceAccess = forceAccess && !modifiersField.isAccessible();
|
||||
if (doForceAccess) {
|
||||
modifiersField.setAccessible(true);
|
||||
|
@ -694,9 +694,9 @@ public static void removeFinalModifier(Field field, boolean forceAccess) {
|
|||
}
|
||||
}
|
||||
}
|
||||
} catch (NoSuchFieldException ignored) {
|
||||
} catch (final NoSuchFieldException ignored) {
|
||||
// The field class contains always a modifiers field
|
||||
} catch (IllegalAccessException ignored) {
|
||||
} catch (final IllegalAccessException ignored) {
|
||||
// The modifiers field is made accessible
|
||||
}
|
||||
}
|
||||
|
|
|
@ -439,7 +439,7 @@ private static Method getAccessibleMethodFromInterfaceNest(Class<?> cls,
|
|||
*/
|
||||
}
|
||||
// Recursively check our parent interfaces
|
||||
Method method = getAccessibleMethodFromInterfaceNest(interfaces[i],
|
||||
final Method method = getAccessibleMethodFromInterfaceNest(interfaces[i],
|
||||
methodName, parameterTypes);
|
||||
if (method != null) {
|
||||
return method;
|
||||
|
@ -509,7 +509,7 @@ public static Method getMatchingAccessibleMethod(final Class<?> cls,
|
|||
* @throws NullPointerException if the specified method is {@code null}
|
||||
* @since 3.2
|
||||
*/
|
||||
public static Set<Method> getOverrideHierarchy(final Method method, Interfaces interfacesBehavior) {
|
||||
public static Set<Method> getOverrideHierarchy(final Method method, final Interfaces interfacesBehavior) {
|
||||
Validate.notNull(method);
|
||||
final Set<Method> result = new LinkedHashSet<Method>();
|
||||
result.add(method);
|
||||
|
|
|
@ -96,7 +96,7 @@ protected TypeLiteral() {
|
|||
}
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object obj) {
|
||||
public final boolean equals(final Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ private WildcardTypeBuilder() {
|
|||
* @param bounds to set
|
||||
* @return {@code this}
|
||||
*/
|
||||
public WildcardTypeBuilder withUpperBounds(Type... bounds) {
|
||||
public WildcardTypeBuilder withUpperBounds(final Type... bounds) {
|
||||
this.upperBounds = bounds;
|
||||
return this;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public WildcardTypeBuilder withUpperBounds(Type... bounds) {
|
|||
* @param bounds to set
|
||||
* @return {@code this}
|
||||
*/
|
||||
public WildcardTypeBuilder withLowerBounds(Type... bounds) {
|
||||
public WildcardTypeBuilder withLowerBounds(final Type... bounds) {
|
||||
this.lowerBounds = bounds;
|
||||
return this;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ private static final class GenericArrayTypeImpl implements GenericArrayType {
|
|||
* Constructor
|
||||
* @param componentType of this array type
|
||||
*/
|
||||
private GenericArrayTypeImpl(Type componentType) {
|
||||
private GenericArrayTypeImpl(final Type componentType) {
|
||||
this.componentType = componentType;
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ public String toString() {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(final Object obj) {
|
||||
return obj == this || obj instanceof GenericArrayType && TypeUtils.equals(this, (GenericArrayType) obj);
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ private static final class ParameterizedTypeImpl implements ParameterizedType {
|
|||
* @param useOwner owner type to use, if any
|
||||
* @param typeArguments formal type arguments
|
||||
*/
|
||||
private ParameterizedTypeImpl(Class<?> raw, Type useOwner, Type[] typeArguments) {
|
||||
private ParameterizedTypeImpl(final Class<?> raw, final Type useOwner, final Type[] typeArguments) {
|
||||
this.raw = raw;
|
||||
this.useOwner = useOwner;
|
||||
this.typeArguments = typeArguments;
|
||||
|
@ -196,7 +196,7 @@ public String toString() {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(final Object obj) {
|
||||
return obj == this || obj instanceof ParameterizedType && TypeUtils.equals(this, ((ParameterizedType) obj));
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,7 @@ private static final class WildcardTypeImpl implements WildcardType {
|
|||
* @param upperBounds of this type
|
||||
* @param lowerBounds of this type
|
||||
*/
|
||||
private WildcardTypeImpl(Type[] upperBounds, Type[] lowerBounds) {
|
||||
private WildcardTypeImpl(final Type[] upperBounds, final Type[] lowerBounds) {
|
||||
this.upperBounds = ObjectUtils.defaultIfNull(upperBounds, EMPTY_BOUNDS);
|
||||
this.lowerBounds = ObjectUtils.defaultIfNull(lowerBounds, EMPTY_BOUNDS);
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ public String toString() {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(final Object obj) {
|
||||
return obj == this || obj instanceof WildcardType && TypeUtils.equals(this, (WildcardType) obj);
|
||||
}
|
||||
|
||||
|
@ -1424,7 +1424,7 @@ private static Type[] unrollBounds(final Map<TypeVariable<?>, Type> typeArgument
|
|||
* @return boolean
|
||||
* @since 3.2
|
||||
*/
|
||||
public static boolean containsTypeVariables(Type type) {
|
||||
public static boolean containsTypeVariables(final Type type) {
|
||||
if (type instanceof TypeVariable<?>) {
|
||||
return true;
|
||||
}
|
||||
|
@ -1432,7 +1432,7 @@ public static boolean containsTypeVariables(Type type) {
|
|||
return ((Class<?>) type).getTypeParameters().length > 0;
|
||||
}
|
||||
if (type instanceof ParameterizedType) {
|
||||
for (Type arg : ((ParameterizedType) type).getActualTypeArguments()) {
|
||||
for (final Type arg : ((ParameterizedType) type).getActualTypeArguments()) {
|
||||
if (containsTypeVariables(arg)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -1440,7 +1440,7 @@ public static boolean containsTypeVariables(Type type) {
|
|||
return false;
|
||||
}
|
||||
if (type instanceof WildcardType) {
|
||||
WildcardType wild = (WildcardType) type;
|
||||
final WildcardType wild = (WildcardType) type;
|
||||
return containsTypeVariables(TypeUtils.getImplicitLowerBounds(wild)[0])
|
||||
|| containsTypeVariables(TypeUtils.getImplicitUpperBounds(wild)[0]);
|
||||
}
|
||||
|
@ -1528,10 +1528,10 @@ public static final ParameterizedType parameterizeWithOwner(final Type owner, fi
|
|||
* @param variables expected map keys
|
||||
* @return array of map values corresponding to specified keys
|
||||
*/
|
||||
private static Type[] extractTypeArgumentsFrom(Map<TypeVariable<?>, Type> mappings, TypeVariable<?>[] variables) {
|
||||
private static Type[] extractTypeArgumentsFrom(final Map<TypeVariable<?>, Type> mappings, final TypeVariable<?>[] variables) {
|
||||
final Type[] result = new Type[variables.length];
|
||||
int index = 0;
|
||||
for (TypeVariable<?> var : variables) {
|
||||
for (final TypeVariable<?> var : variables) {
|
||||
Validate.isTrue(mappings.containsKey(var), "missing argument mapping for %s", toString(var));
|
||||
result[index++] = mappings.get(var);
|
||||
}
|
||||
|
@ -1568,7 +1568,7 @@ public static GenericArrayType genericArrayType(final Type componentType) {
|
|||
* @since 3.2
|
||||
*/
|
||||
@SuppressWarnings( "deprecation" ) // ObjectUtils.equals(Object, Object) has been deprecated in 3.2
|
||||
public static boolean equals(Type t1, Type t2) {
|
||||
public static boolean equals(final Type t1, final Type t2) {
|
||||
if (ObjectUtils.equals(t1, t2)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -1591,7 +1591,7 @@ public static boolean equals(Type t1, Type t2) {
|
|||
* @return boolean
|
||||
* @since 3.2
|
||||
*/
|
||||
private static boolean equals(ParameterizedType p, Type t) {
|
||||
private static boolean equals(final ParameterizedType p, final Type t) {
|
||||
if (t instanceof ParameterizedType) {
|
||||
final ParameterizedType other = (ParameterizedType) t;
|
||||
if (equals(p.getRawType(), other.getRawType()) && equals(p.getOwnerType(), other.getOwnerType())) {
|
||||
|
@ -1608,7 +1608,7 @@ private static boolean equals(ParameterizedType p, Type t) {
|
|||
* @return boolean
|
||||
* @since 3.2
|
||||
*/
|
||||
private static boolean equals(GenericArrayType a, Type t) {
|
||||
private static boolean equals(final GenericArrayType a, final Type t) {
|
||||
return t instanceof GenericArrayType
|
||||
&& equals(a.getGenericComponentType(), ((GenericArrayType) t).getGenericComponentType());
|
||||
}
|
||||
|
@ -1620,7 +1620,7 @@ private static boolean equals(GenericArrayType a, Type t) {
|
|||
* @return boolean
|
||||
* @since 3.2
|
||||
*/
|
||||
private static boolean equals(WildcardType w, Type t) {
|
||||
private static boolean equals(final WildcardType w, final Type t) {
|
||||
if (t instanceof WildcardType) {
|
||||
final WildcardType other = (WildcardType) t;
|
||||
return equals(getImplicitLowerBounds(w), getImplicitLowerBounds(other))
|
||||
|
@ -1636,7 +1636,7 @@ private static boolean equals(WildcardType w, Type t) {
|
|||
* @return boolean
|
||||
* @since 3.2
|
||||
*/
|
||||
private static boolean equals(Type[] t1, Type[] t2) {
|
||||
private static boolean equals(final Type[] t1, final Type[] t2) {
|
||||
if (t1.length == t2.length) {
|
||||
for (int i = 0; i < t1.length; i++) {
|
||||
if (!equals(t1[i], t2[i])) {
|
||||
|
@ -1655,7 +1655,7 @@ private static boolean equals(Type[] t1, Type[] t2) {
|
|||
* @return String
|
||||
* @since 3.2
|
||||
*/
|
||||
public static String toString(Type type) {
|
||||
public static String toString(final Type type) {
|
||||
Validate.notNull(type);
|
||||
if (type instanceof Class<?>) {
|
||||
return classToString((Class<?>) type);
|
||||
|
@ -1682,7 +1682,7 @@ public static String toString(Type type) {
|
|||
* @return String
|
||||
* @since 3.2
|
||||
*/
|
||||
public static String toLongString(TypeVariable<?> var) {
|
||||
public static String toLongString(final TypeVariable<?> var) {
|
||||
Validate.notNull(var, "var is null");
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
final GenericDeclaration d = ((TypeVariable<?>) var).getGenericDeclaration();
|
||||
|
@ -1739,7 +1739,7 @@ public static <T> Typed<T> wrap(final Class<T> type) {
|
|||
* @return String
|
||||
* @since 3.2
|
||||
*/
|
||||
private static String classToString(Class<?> c) {
|
||||
private static String classToString(final Class<?> c) {
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
|
||||
if (c.getEnclosingClass() != null) {
|
||||
|
@ -1761,7 +1761,7 @@ private static String classToString(Class<?> c) {
|
|||
* @return String
|
||||
* @since 3.2
|
||||
*/
|
||||
private static String typeVariableToString(TypeVariable<?> v) {
|
||||
private static String typeVariableToString(final TypeVariable<?> v) {
|
||||
final StringBuilder buf = new StringBuilder(v.getName());
|
||||
final Type[] bounds = v.getBounds();
|
||||
if (bounds.length > 0 && !(bounds.length == 1 && Object.class.equals(bounds[0]))) {
|
||||
|
@ -1777,7 +1777,7 @@ private static String typeVariableToString(TypeVariable<?> v) {
|
|||
* @return String
|
||||
* @since 3.2
|
||||
*/
|
||||
private static String parameterizedTypeToString(ParameterizedType p) {
|
||||
private static String parameterizedTypeToString(final ParameterizedType p) {
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
|
||||
final Type useOwner = p.getOwnerType();
|
||||
|
@ -1804,7 +1804,7 @@ private static String parameterizedTypeToString(ParameterizedType p) {
|
|||
* @return String
|
||||
* @since 3.2
|
||||
*/
|
||||
private static String wildcardTypeToString(WildcardType w) {
|
||||
private static String wildcardTypeToString(final WildcardType w) {
|
||||
final StringBuilder buf = new StringBuilder().append('?');
|
||||
final Type[] lowerBounds = w.getLowerBounds();
|
||||
final Type[] upperBounds = w.getUpperBounds();
|
||||
|
@ -1822,7 +1822,7 @@ private static String wildcardTypeToString(WildcardType w) {
|
|||
* @return String
|
||||
* @since 3.2
|
||||
*/
|
||||
private static String genericArrayTypeToString(GenericArrayType g) {
|
||||
private static String genericArrayTypeToString(final GenericArrayType g) {
|
||||
return String.format("%s[]", toString(g.getGenericComponentType()));
|
||||
}
|
||||
|
||||
|
@ -1834,7 +1834,7 @@ private static String genericArrayTypeToString(GenericArrayType g) {
|
|||
* @return {@code buf}
|
||||
* @since 3.2
|
||||
*/
|
||||
private static StringBuilder appendAllTo(StringBuilder buf, String sep, Type... types) {
|
||||
private static StringBuilder appendAllTo(final StringBuilder buf, final String sep, final Type... types) {
|
||||
Validate.notEmpty(Validate.noNullElements(types));
|
||||
if (types.length > 0) {
|
||||
buf.append(toString(types[0]));
|
||||
|
|
|
@ -510,7 +510,7 @@ public String replace(final StringBuffer source, final int offset, final int len
|
|||
* @return the result of the replace operation
|
||||
* @since 3.2
|
||||
*/
|
||||
public String replace(CharSequence source) {
|
||||
public String replace(final CharSequence source) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -531,11 +531,11 @@ public String replace(CharSequence source) {
|
|||
* @return the result of the replace operation
|
||||
* @since 3.2
|
||||
*/
|
||||
public String replace(CharSequence source, int offset, int length) {
|
||||
public String replace(final CharSequence source, final int offset, final int length) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
StrBuilder buf = new StrBuilder(length).append(source, offset, length);
|
||||
final StrBuilder buf = new StrBuilder(length).append(source, offset, length);
|
||||
substitute(buf, 0, length);
|
||||
return buf.toString();
|
||||
}
|
||||
|
@ -649,7 +649,7 @@ public boolean replaceIn(final StringBuffer source, final int offset, final int
|
|||
* @return true if altered
|
||||
* @since 3.2
|
||||
*/
|
||||
public boolean replaceIn(StringBuilder source) {
|
||||
public boolean replaceIn(final StringBuilder source) {
|
||||
if (source == null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -670,11 +670,11 @@ public boolean replaceIn(StringBuilder source) {
|
|||
* @return true if altered
|
||||
* @since 3.2
|
||||
*/
|
||||
public boolean replaceIn(StringBuilder source, int offset, int length) {
|
||||
public boolean replaceIn(final StringBuilder source, final int offset, final int length) {
|
||||
if (source == null) {
|
||||
return false;
|
||||
}
|
||||
StrBuilder buf = new StrBuilder(length).append(source, offset, length);
|
||||
final StrBuilder buf = new StrBuilder(length).append(source, offset, length);
|
||||
if (substitute(buf, 0, length) == false) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -37,12 +37,12 @@ public class OctalUnescaper extends CharSequenceTranslator {
|
|||
*/
|
||||
@Override
|
||||
public int translate(final CharSequence input, final int index, final Writer out) throws IOException {
|
||||
int remaining = input.length() - index - 1; // how many characters left, ignoring the first \
|
||||
StringBuilder builder = new StringBuilder();
|
||||
final int remaining = input.length() - index - 1; // how many characters left, ignoring the first \
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
if(input.charAt(index) == '\\' && remaining > 0 && isOctalDigit(input.charAt(index + 1)) ) {
|
||||
int next = index + 1;
|
||||
int next2 = index + 2;
|
||||
int next3 = index + 3;
|
||||
final int next = index + 1;
|
||||
final int next2 = index + 2;
|
||||
final int next3 = index + 3;
|
||||
|
||||
// we know this is good as we checked it in the if block above
|
||||
builder.append(input.charAt(next));
|
||||
|
@ -65,7 +65,7 @@ public int translate(final CharSequence input, final int index, final Writer out
|
|||
* @param ch the char to check
|
||||
* @return true if the given char is the character representation of one of the digits from 0 to 7
|
||||
*/
|
||||
private boolean isOctalDigit(char ch) {
|
||||
private boolean isOctalDigit(final char ch) {
|
||||
return ch >= '0' && ch <= '7';
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ private boolean isOctalDigit(char ch) {
|
|||
* @param ch the char to check
|
||||
* @return true if the given char is the character representation of one of the digits from 0 to 3
|
||||
*/
|
||||
private boolean isZeroToThree(char ch) {
|
||||
private boolean isZeroToThree(final char ch) {
|
||||
return ch >= '0' && ch <= '3';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class UnicodeUnpairedSurrogateRemover extends CodePointTranslator {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean translate(int codepoint, Writer out) throws IOException {
|
||||
public boolean translate(final int codepoint, final Writer out) throws IOException {
|
||||
if (codepoint >= Character.MIN_SURROGATE && codepoint <= Character.MAX_SURROGATE) {
|
||||
// It's a surrogate. Write nothing and say we've translated.
|
||||
return true;
|
||||
|
|
|
@ -1671,7 +1671,7 @@ private static long getFragment(final Calendar calendar, final int fragment, fin
|
|||
|
||||
long result = 0;
|
||||
|
||||
int offset = (unit == TimeUnit.DAYS) ? 0 : 1;
|
||||
final int offset = (unit == TimeUnit.DAYS) ? 0 : 1;
|
||||
|
||||
// Fragments bigger than a day require a breakdown to days
|
||||
switch (fragment) {
|
||||
|
|
|
@ -424,7 +424,7 @@ public static String formatPeriod(final long startMillis, final long endMillis,
|
|||
* @return the formatted string
|
||||
*/
|
||||
static String format(final Token[] tokens, final long years, final long months, final long days, final long hours, final long minutes, final long seconds,
|
||||
long milliseconds, final boolean padWithZeros) {
|
||||
final long milliseconds, final boolean padWithZeros) {
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
boolean lastOutputSeconds = false;
|
||||
for (final Token token : tokens) {
|
||||
|
@ -454,7 +454,7 @@ static String format(final Token[] tokens, final long years, final long months,
|
|||
} else if (value == S) {
|
||||
if (lastOutputSeconds) {
|
||||
// ensure at least 3 digits are displayed even if padding is not selected
|
||||
int width = padWithZeros ? Math.max(3, count) : 3;
|
||||
final int width = padWithZeros ? Math.max(3, count) : 3;
|
||||
buffer.append(paddedValue(milliseconds, true, width));
|
||||
} else {
|
||||
buffer.append(paddedValue(milliseconds, padWithZeros, count));
|
||||
|
@ -581,7 +581,7 @@ static class Token {
|
|||
* @return boolean <code>true</code> if contained
|
||||
*/
|
||||
static boolean containsTokenWithValue(final Token[] tokens, final Object value) {
|
||||
for (Token token : tokens) {
|
||||
for (final Token token : tokens) {
|
||||
if (token.getValue() == value) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ else if(locale.equals(JAPANESE_IMPERIAL)) {
|
|||
*
|
||||
* @param definingCalendar the {@link java.util.Calendar} instance used to initialize this FastDateParser
|
||||
*/
|
||||
private void init(Calendar definingCalendar) {
|
||||
private void init(final Calendar definingCalendar) {
|
||||
|
||||
final StringBuilder regex= new StringBuilder();
|
||||
final List<Strategy> collector = new ArrayList<Strategy>();
|
||||
|
@ -398,7 +398,7 @@ private static Map<String, Integer> getDisplayNames(final int field, final Calen
|
|||
* @return A value between centuryStart(inclusive) to centuryStart+100(exclusive)
|
||||
*/
|
||||
private int adjustYear(final int twoDigitYear) {
|
||||
int trial= century + twoDigitYear;
|
||||
final int trial= century + twoDigitYear;
|
||||
return twoDigitYear>=startYear ?trial :trial+100;
|
||||
}
|
||||
|
||||
|
@ -606,10 +606,10 @@ private static class CaseInsensitiveTextStrategy extends Strategy {
|
|||
CaseInsensitiveTextStrategy(final int field, final Calendar definingCalendar, final Locale locale) {
|
||||
this.field= field;
|
||||
this.locale= locale;
|
||||
Map<String, Integer> keyValues = getDisplayNames(field, definingCalendar, locale);
|
||||
final Map<String, Integer> keyValues = getDisplayNames(field, definingCalendar, locale);
|
||||
this.lKeyValues= new HashMap<String,Integer>();
|
||||
|
||||
for(Map.Entry<String, Integer> entry : keyValues.entrySet()) {
|
||||
for(final Map.Entry<String, Integer> entry : keyValues.entrySet()) {
|
||||
lKeyValues.put(entry.getKey().toLowerCase(locale), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
@ -751,7 +751,7 @@ private static class TimeZoneStrategy extends Strategy {
|
|||
*/
|
||||
TimeZoneStrategy(final Locale locale) {
|
||||
final String[][] zones = DateFormatSymbols.getInstance(locale).getZoneStrings();
|
||||
for (String[] zone : zones) {
|
||||
for (final String[] zone : zones) {
|
||||
if (zone[ID].startsWith("GMT")) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ private F getDateTimeInstance(final Integer dateStyle, final Integer timeStyle,
|
|||
* pattern defined
|
||||
*/
|
||||
// package protected, for access from FastDateFormat; do not make public or protected
|
||||
F getDateTimeInstance(final int dateStyle, final int timeStyle, final TimeZone timeZone, Locale locale) {
|
||||
F getDateTimeInstance(final int dateStyle, final int timeStyle, final TimeZone timeZone, final Locale locale) {
|
||||
return getDateTimeInstance(Integer.valueOf(dateStyle), Integer.valueOf(timeStyle), timeZone, locale);
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ F getDateTimeInstance(final int dateStyle, final int timeStyle, final TimeZone t
|
|||
* pattern defined
|
||||
*/
|
||||
// package protected, for access from FastDateFormat; do not make public or protected
|
||||
F getDateInstance(final int dateStyle, final TimeZone timeZone, Locale locale) {
|
||||
F getDateInstance(final int dateStyle, final TimeZone timeZone, final Locale locale) {
|
||||
return getDateTimeInstance(Integer.valueOf(dateStyle), null, timeZone, locale);
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,7 @@ F getDateInstance(final int dateStyle, final TimeZone timeZone, Locale locale) {
|
|||
* pattern defined
|
||||
*/
|
||||
// package protected, for access from FastDateFormat; do not make public or protected
|
||||
F getTimeInstance(final int timeStyle, final TimeZone timeZone, Locale locale) {
|
||||
F getTimeInstance(final int timeStyle, final TimeZone timeZone, final Locale locale) {
|
||||
return getDateTimeInstance(null, Integer.valueOf(timeStyle), timeZone, locale);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@ public void testToFullyQualifiedNameClassNull() throws Exception {
|
|||
|
||||
@Test
|
||||
public void testToFullyQualifiedNameClassString() throws Exception {
|
||||
String expected = "org.apache.commons.lang3.Test.properties";
|
||||
String actual = ClassPathUtils.toFullyQualifiedName(ClassPathUtils.class, "Test.properties");
|
||||
final String expected = "org.apache.commons.lang3.Test.properties";
|
||||
final String actual = ClassPathUtils.toFullyQualifiedName(ClassPathUtils.class, "Test.properties");
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
@ -71,8 +71,8 @@ public void testToFullyQualifiedNamePackageNull() throws Exception {
|
|||
|
||||
@Test
|
||||
public void testToFullyQualifiedNamePackageString() throws Exception {
|
||||
String expected = "org.apache.commons.lang3.Test.properties";
|
||||
String actual = ClassPathUtils.toFullyQualifiedName(ClassPathUtils.class.getPackage(), "Test.properties");
|
||||
final String expected = "org.apache.commons.lang3.Test.properties";
|
||||
final String actual = ClassPathUtils.toFullyQualifiedName(ClassPathUtils.class.getPackage(), "Test.properties");
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
@ -89,8 +89,8 @@ public void testToFullyQualifiedPathClassNull() throws Exception {
|
|||
|
||||
@Test
|
||||
public void testToFullyQualifiedPathClass() throws Exception {
|
||||
String expected = "org/apache/commons/lang3/Test.properties";
|
||||
String actual = ClassPathUtils.toFullyQualifiedPath(ClassPathUtils.class, "Test.properties");
|
||||
final String expected = "org/apache/commons/lang3/Test.properties";
|
||||
final String actual = ClassPathUtils.toFullyQualifiedPath(ClassPathUtils.class, "Test.properties");
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
@ -107,8 +107,8 @@ public void testToFullyQualifiedPathPackageNull() throws Exception {
|
|||
|
||||
@Test
|
||||
public void testToFullyQualifiedPathPackage() throws Exception {
|
||||
String expected = "org/apache/commons/lang3/Test.properties";
|
||||
String actual = ClassPathUtils.toFullyQualifiedPath(ClassPathUtils.class.getPackage(), "Test.properties");
|
||||
final String expected = "org/apache/commons/lang3/Test.properties";
|
||||
final String actual = ClassPathUtils.toFullyQualifiedPath(ClassPathUtils.class.getPackage(), "Test.properties");
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
|
|
|
@ -378,8 +378,8 @@ public void testIsAvailableLocale() {
|
|||
*/
|
||||
@Test
|
||||
public void testThreeCharsLocale() {
|
||||
for (String str : Arrays.asList("udm", "tet")) {
|
||||
Locale locale = LocaleUtils.toLocale(str);
|
||||
for (final String str : Arrays.asList("udm", "tet")) {
|
||||
final Locale locale = LocaleUtils.toLocale(str);
|
||||
assertNotNull(locale);
|
||||
assertEquals(str, locale.getLanguage());
|
||||
assertTrue(StringUtils.isBlank(locale.getCountry()));
|
||||
|
@ -554,11 +554,11 @@ public void testLang865() {
|
|||
|
||||
@Test
|
||||
public void testParseAllLocales() {
|
||||
Locale[] locales = Locale.getAvailableLocales();
|
||||
final Locale[] locales = Locale.getAvailableLocales();
|
||||
int failures = 0;
|
||||
for (Locale l : locales) {
|
||||
for (final Locale l : locales) {
|
||||
// Check if it's possible to recreate the Locale using just the standard constructor
|
||||
Locale locale = new Locale(l.getLanguage(), l.getCountry(), l.getVariant());
|
||||
final Locale locale = new Locale(l.getLanguage(), l.getCountry(), l.getVariant());
|
||||
if (l.equals(locale)) { // it is possible for LocaleUtils.toLocale to handle these Locales
|
||||
String str = l.toString();
|
||||
// Look for the script/extension suffix
|
||||
|
@ -572,12 +572,12 @@ public void testParseAllLocales() {
|
|||
System.out.println("Should not have parsed: " + str);
|
||||
failures++;
|
||||
continue; // try next Locale
|
||||
} catch (IllegalArgumentException iae) {
|
||||
} catch (final IllegalArgumentException iae) {
|
||||
// expected; try without suffix
|
||||
str = str.substring(0, suff);
|
||||
}
|
||||
}
|
||||
Locale loc = LocaleUtils.toLocale(str);
|
||||
final Locale loc = LocaleUtils.toLocale(str);
|
||||
if (!l.equals(loc)) {
|
||||
System.out.println("Failed to parse: " + str);
|
||||
failures++;
|
||||
|
|
|
@ -29,9 +29,9 @@ public class NotImplementedExceptionTest {
|
|||
|
||||
@Test
|
||||
public void testConstructors() {
|
||||
Throwable nested = new RuntimeException();
|
||||
String message = "Not Implemented";
|
||||
String code = "CODE";
|
||||
final Throwable nested = new RuntimeException();
|
||||
final String message = "Not Implemented";
|
||||
final String code = "CODE";
|
||||
|
||||
NotImplementedException nie = new NotImplementedException(message);
|
||||
assertCorrect("Issue in (String)", nie, message, null, null);
|
||||
|
@ -47,7 +47,7 @@ public void testConstructors() {
|
|||
assertCorrect("Issue in (String, Throwable, String)", nie, message, nested, code);
|
||||
}
|
||||
|
||||
private void assertCorrect(String assertMessage, NotImplementedException nie, String message, Throwable nested, String code) {
|
||||
private void assertCorrect(final String assertMessage, final NotImplementedException nie, final String message, final Throwable nested, final String code) {
|
||||
assertNotNull(assertMessage + ": target is null", nie);
|
||||
assertEquals(assertMessage + ": Message not equal", message, nie.getMessage());
|
||||
assertEquals(assertMessage + ": Nested throwable not equal", nested, nie.getCause());
|
||||
|
|
|
@ -264,7 +264,7 @@ public void testIdentityToStringAppendable() {
|
|||
final Appendable appendable = new StringBuilder();
|
||||
ObjectUtils.identityToString(appendable, i);
|
||||
assertEquals(expected, appendable.toString());
|
||||
} catch(IOException ex) {
|
||||
} catch(final IOException ex) {
|
||||
fail("IOException unexpected");
|
||||
}
|
||||
|
||||
|
@ -272,14 +272,14 @@ public void testIdentityToStringAppendable() {
|
|||
ObjectUtils.identityToString((Appendable)null, "tmp");
|
||||
fail("NullPointerException expected");
|
||||
} catch(final NullPointerException npe) {
|
||||
} catch (IOException ex) {
|
||||
} catch (final IOException ex) {
|
||||
}
|
||||
|
||||
try {
|
||||
ObjectUtils.identityToString((Appendable)(new StringBuilder()), null);
|
||||
fail("NullPointerException expected");
|
||||
} catch(final NullPointerException npe) {
|
||||
} catch (IOException ex) {
|
||||
} catch (final IOException ex) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ public void testZeroLengthNextBytes() throws Exception {
|
|||
*/
|
||||
@Test
|
||||
public void testNextBytes() throws Exception {
|
||||
byte[] result = RandomUtils.nextBytes(20);
|
||||
final byte[] result = RandomUtils.nextBytes(20);
|
||||
assertEquals(20, result.length);
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ public void testNextIntMinimalRange() throws Exception {
|
|||
*/
|
||||
@Test
|
||||
public void testNextInt() throws Exception {
|
||||
int result = RandomUtils.nextInt(33, 42);
|
||||
final int result = RandomUtils.nextInt(33, 42);
|
||||
assertTrue(result >= 33 && result < 42);
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ public void testNextFloatMinimalRange() throws Exception {
|
|||
*/
|
||||
@Test
|
||||
public void testNextDouble() throws Exception {
|
||||
double result = RandomUtils.nextDouble(33d, 42d);
|
||||
final double result = RandomUtils.nextDouble(33d, 42d);
|
||||
assertTrue(result >= 33d && result <= 42d);
|
||||
}
|
||||
|
||||
|
@ -144,7 +144,7 @@ public void testNextDouble() throws Exception {
|
|||
*/
|
||||
@Test
|
||||
public void testNextFloat() throws Exception {
|
||||
double result = RandomUtils.nextFloat(33f, 42f);
|
||||
final double result = RandomUtils.nextFloat(33f, 42f);
|
||||
assertTrue(result >= 33f && result <= 42f);
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ public void testNextLongMinimalRange() throws Exception {
|
|||
*/
|
||||
@Test
|
||||
public void testNextLong() throws Exception {
|
||||
long result = RandomUtils.nextLong(33L, 42L);
|
||||
final long result = RandomUtils.nextLong(33L, 42L);
|
||||
assertTrue(result >= 33L && result < 42L);
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ public void testNextLong() throws Exception {
|
|||
*/
|
||||
@Test
|
||||
public void testExtremeRangeInt() throws Exception {
|
||||
int result = RandomUtils.nextInt(0, Integer.MAX_VALUE);
|
||||
final int result = RandomUtils.nextInt(0, Integer.MAX_VALUE);
|
||||
assertTrue(result >= 0 && result < Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@ public void testExtremeRangeInt() throws Exception {
|
|||
*/
|
||||
@Test
|
||||
public void testExtremeRangeLong() throws Exception {
|
||||
long result = RandomUtils.nextLong(0, Long.MAX_VALUE);
|
||||
final long result = RandomUtils.nextLong(0, Long.MAX_VALUE);
|
||||
assertTrue(result >= 0 && result < Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ public void testExtremeRangeLong() throws Exception {
|
|||
*/
|
||||
@Test
|
||||
public void testExtremeRangeFloat() throws Exception {
|
||||
float result = RandomUtils.nextFloat(0, Float.MAX_VALUE);
|
||||
final float result = RandomUtils.nextFloat(0, Float.MAX_VALUE);
|
||||
assertTrue(result >= 0f && result <= Float.MAX_VALUE);
|
||||
}
|
||||
|
||||
|
@ -198,7 +198,7 @@ public void testExtremeRangeFloat() throws Exception {
|
|||
*/
|
||||
@Test
|
||||
public void testExtremeRangeDouble() throws Exception {
|
||||
double result = RandomUtils.nextDouble(0, Double.MAX_VALUE);
|
||||
final double result = RandomUtils.nextDouble(0, Double.MAX_VALUE);
|
||||
assertTrue(result >= 0 && result <= Double.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -273,7 +273,7 @@ public void testDeserializeStreamClassNotFound() throws Exception {
|
|||
|
||||
@Test
|
||||
public void testRoundtrip() {
|
||||
HashMap<Object, Object> newMap = SerializationUtils.roundtrip(iMap);
|
||||
final HashMap<Object, Object> newMap = SerializationUtils.roundtrip(iMap);
|
||||
assertEquals(iMap, newMap);
|
||||
}
|
||||
|
||||
|
|
|
@ -219,7 +219,7 @@ public void testEscapeEcmaScript() {
|
|||
|
||||
@Test
|
||||
public void testEscapeHtml() {
|
||||
for (String[] element : HTML_ESCAPES) {
|
||||
for (final String[] element : HTML_ESCAPES) {
|
||||
final String message = element[0];
|
||||
final String expected = element[1];
|
||||
final String original = element[2];
|
||||
|
@ -236,7 +236,7 @@ public void testEscapeHtml() {
|
|||
|
||||
@Test
|
||||
public void testUnescapeHtml4() {
|
||||
for (String[] element : HTML_ESCAPES) {
|
||||
for (final String[] element : HTML_ESCAPES) {
|
||||
final String message = element[0];
|
||||
final String expected = element[2];
|
||||
final String original = element[1];
|
||||
|
@ -584,9 +584,9 @@ public void testLang720() {
|
|||
*/
|
||||
@Test
|
||||
public void testLang911() {
|
||||
String bellsTest = "\ud83d\udc80\ud83d\udd14";
|
||||
String value = StringEscapeUtils.escapeJava(bellsTest);
|
||||
String valueTest = StringEscapeUtils.unescapeJava(value);
|
||||
final String bellsTest = "\ud83d\udc80\ud83d\udd14";
|
||||
final String value = StringEscapeUtils.escapeJava(bellsTest);
|
||||
final String valueTest = StringEscapeUtils.unescapeJava(value);
|
||||
assertEquals(bellsTest, valueTest);
|
||||
}
|
||||
|
||||
|
@ -610,8 +610,8 @@ public void testEscapeJson() {
|
|||
|
||||
assertEquals("He didn't say, \\\"stop!\\\"", StringEscapeUtils.escapeJson("He didn't say, \"stop!\""));
|
||||
|
||||
String expected = "\\\"foo\\\" isn't \\\"bar\\\". specials: \\b\\r\\n\\f\\t\\\\\\/";
|
||||
String input ="\"foo\" isn't \"bar\". specials: \b\r\n\f\t\\/";
|
||||
final String expected = "\\\"foo\\\" isn't \\\"bar\\\". specials: \\b\\r\\n\\f\\t\\\\\\/";
|
||||
final String input ="\"foo\" isn't \"bar\". specials: \b\r\n\f\t\\/";
|
||||
|
||||
assertEquals(expected, StringEscapeUtils.escapeJson(input));
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class StringUtilsTest {
|
|||
static {
|
||||
String ws = "";
|
||||
String nws = "";
|
||||
String hs = String.valueOf(((char) 160));
|
||||
final String hs = String.valueOf(((char) 160));
|
||||
String tr = "";
|
||||
String ntr = "";
|
||||
for (int i = 0; i < Character.MAX_VALUE; i++) {
|
||||
|
|
|
@ -54,7 +54,7 @@ private static class TypeTestClass implements Diffable<TypeTestClass> {
|
|||
private Object[] objectArrayField = {null};
|
||||
|
||||
@Override
|
||||
public DiffResult diff(TypeTestClass obj) {
|
||||
public DiffResult diff(final TypeTestClass obj) {
|
||||
return new DiffBuilder(this, obj, style)
|
||||
.append("boolean", booleanField, obj.booleanField)
|
||||
.append("booleanArray", booleanArrayField, obj.booleanArrayField)
|
||||
|
@ -83,7 +83,7 @@ public int hashCode() {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(final Object obj) {
|
||||
return EqualsBuilder.reflectionEquals(this, obj, false);
|
||||
}
|
||||
}
|
||||
|
@ -91,12 +91,12 @@ public boolean equals(Object obj) {
|
|||
|
||||
@Test
|
||||
public void testBoolean() {
|
||||
TypeTestClass class1 = new TypeTestClass();
|
||||
TypeTestClass class2 = new TypeTestClass();
|
||||
final TypeTestClass class1 = new TypeTestClass();
|
||||
final TypeTestClass class2 = new TypeTestClass();
|
||||
class2.booleanField = false;
|
||||
DiffResult list = class1.diff(class2);
|
||||
final DiffResult list = class1.diff(class2);
|
||||
assertEquals(1, list.getNumberOfDiffs());
|
||||
Diff<?> diff = list.getDiffs().get(0);
|
||||
final Diff<?> diff = list.getDiffs().get(0);
|
||||
assertEquals(Boolean.class, diff.getType());
|
||||
assertEquals(Boolean.TRUE, diff.getLeft());
|
||||
assertEquals(Boolean.FALSE, diff.getRight());
|
||||
|
@ -104,12 +104,12 @@ public void testBoolean() {
|
|||
|
||||
@Test
|
||||
public void testBooleanArray() throws Exception {
|
||||
TypeTestClass class1 = new TypeTestClass();
|
||||
TypeTestClass class2 = new TypeTestClass();
|
||||
final TypeTestClass class1 = new TypeTestClass();
|
||||
final TypeTestClass class2 = new TypeTestClass();
|
||||
class2.booleanArrayField = new boolean[] {false, false};
|
||||
DiffResult list = class1.diff(class2);
|
||||
final DiffResult list = class1.diff(class2);
|
||||
assertEquals(1, list.getNumberOfDiffs());
|
||||
Diff<?> diff = list.getDiffs().get(0);
|
||||
final Diff<?> diff = list.getDiffs().get(0);
|
||||
assertArrayEquals(ArrayUtils.toObject(class1.booleanArrayField),
|
||||
(Object[]) diff.getLeft());
|
||||
assertArrayEquals(ArrayUtils.toObject(class2.booleanArrayField),
|
||||
|
@ -119,24 +119,24 @@ public void testBooleanArray() throws Exception {
|
|||
|
||||
@Test
|
||||
public void testByte() {
|
||||
TypeTestClass class1 = new TypeTestClass();
|
||||
TypeTestClass class2 = new TypeTestClass();
|
||||
final TypeTestClass class1 = new TypeTestClass();
|
||||
final TypeTestClass class2 = new TypeTestClass();
|
||||
class2.byteField = 0x01;
|
||||
DiffResult list = class1.diff(class2);
|
||||
final DiffResult list = class1.diff(class2);
|
||||
assertEquals(1, list.getNumberOfDiffs());
|
||||
Diff<?> diff = list.getDiffs().get(0);
|
||||
final Diff<?> diff = list.getDiffs().get(0);
|
||||
assertEquals(Byte.valueOf(class1.byteField), diff.getLeft());
|
||||
assertEquals(Byte.valueOf(class2.byteField), diff.getRight());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testByteArray() throws Exception {
|
||||
TypeTestClass class1 = new TypeTestClass();
|
||||
TypeTestClass class2 = new TypeTestClass();
|
||||
final TypeTestClass class1 = new TypeTestClass();
|
||||
final TypeTestClass class2 = new TypeTestClass();
|
||||
class2.byteArrayField= new byte[] {0x01, 0x02};
|
||||
DiffResult list = class1.diff(class2);
|
||||
final DiffResult list = class1.diff(class2);
|
||||
assertEquals(1, list.getNumberOfDiffs());
|
||||
Diff<?> diff = list.getDiffs().get(0);
|
||||
final Diff<?> diff = list.getDiffs().get(0);
|
||||
assertArrayEquals(ArrayUtils.toObject(class1.byteArrayField),
|
||||
(Object[]) diff.getLeft());
|
||||
assertArrayEquals(ArrayUtils.toObject(class2.byteArrayField),
|
||||
|
@ -145,12 +145,12 @@ public void testByteArray() throws Exception {
|
|||
|
||||
@Test
|
||||
public void testChar() {
|
||||
TypeTestClass class1 = new TypeTestClass();
|
||||
TypeTestClass class2 = new TypeTestClass();
|
||||
final TypeTestClass class1 = new TypeTestClass();
|
||||
final TypeTestClass class2 = new TypeTestClass();
|
||||
class2.charField = 'z';
|
||||
DiffResult list = class1.diff(class2);
|
||||
final DiffResult list = class1.diff(class2);
|
||||
assertEquals(1, list.getNumberOfDiffs());
|
||||
Diff<?> diff = list.getDiffs().get(0);
|
||||
final Diff<?> diff = list.getDiffs().get(0);
|
||||
assertEquals(Character.valueOf(class1.charField), diff.getLeft());
|
||||
assertEquals(Character.valueOf(class2.charField), diff.getRight());
|
||||
}
|
||||
|
@ -158,12 +158,12 @@ public void testChar() {
|
|||
|
||||
@Test
|
||||
public void testCharArray() throws Exception {
|
||||
TypeTestClass class1 = new TypeTestClass();
|
||||
TypeTestClass class2 = new TypeTestClass();
|
||||
final TypeTestClass class1 = new TypeTestClass();
|
||||
final TypeTestClass class2 = new TypeTestClass();
|
||||
class2.charArrayField = new char[] {'f', 'o', 'o'};
|
||||
DiffResult list = class1.diff(class2);
|
||||
final DiffResult list = class1.diff(class2);
|
||||
assertEquals(1, list.getNumberOfDiffs());
|
||||
Diff<?> diff = list.getDiffs().get(0);
|
||||
final Diff<?> diff = list.getDiffs().get(0);
|
||||
assertArrayEquals(ArrayUtils.toObject(class1.charArrayField),
|
||||
(Object[]) diff.getLeft());
|
||||
assertArrayEquals(ArrayUtils.toObject(class2.charArrayField),
|
||||
|
@ -173,12 +173,12 @@ public void testCharArray() throws Exception {
|
|||
|
||||
@Test
|
||||
public void testDouble() {
|
||||
TypeTestClass class1 = new TypeTestClass();
|
||||
TypeTestClass class2 = new TypeTestClass();
|
||||
final TypeTestClass class1 = new TypeTestClass();
|
||||
final TypeTestClass class2 = new TypeTestClass();
|
||||
class2.doubleField = 99.99;
|
||||
DiffResult list = class1.diff(class2);
|
||||
final DiffResult list = class1.diff(class2);
|
||||
assertEquals(1, list.getNumberOfDiffs());
|
||||
Diff<?> diff = list.getDiffs().get(0);
|
||||
final Diff<?> diff = list.getDiffs().get(0);
|
||||
assertEquals(Double.valueOf(class1.doubleField), diff.getLeft());
|
||||
assertEquals(Double.valueOf(class2.doubleField), diff.getRight());
|
||||
}
|
||||
|
@ -186,12 +186,12 @@ public void testDouble() {
|
|||
|
||||
@Test
|
||||
public void testDoubleArray() throws Exception {
|
||||
TypeTestClass class1 = new TypeTestClass();
|
||||
TypeTestClass class2 = new TypeTestClass();
|
||||
final TypeTestClass class1 = new TypeTestClass();
|
||||
final TypeTestClass class2 = new TypeTestClass();
|
||||
class2.doubleArrayField = new double[] {3.0, 2.9, 2.8};
|
||||
DiffResult list = class1.diff(class2);
|
||||
final DiffResult list = class1.diff(class2);
|
||||
assertEquals(1, list.getNumberOfDiffs());
|
||||
Diff<?> diff = list.getDiffs().get(0);
|
||||
final Diff<?> diff = list.getDiffs().get(0);
|
||||
assertArrayEquals(ArrayUtils.toObject(class1.doubleArrayField),
|
||||
(Object[]) diff.getLeft());
|
||||
assertArrayEquals(ArrayUtils.toObject(class2.doubleArrayField),
|
||||
|
@ -200,12 +200,12 @@ public void testDoubleArray() throws Exception {
|
|||
|
||||
@Test
|
||||
public void testFloat() {
|
||||
TypeTestClass class1 = new TypeTestClass();
|
||||
TypeTestClass class2 = new TypeTestClass();
|
||||
final TypeTestClass class1 = new TypeTestClass();
|
||||
final TypeTestClass class2 = new TypeTestClass();
|
||||
class2.floatField = 99.99F;
|
||||
DiffResult list = class1.diff(class2);
|
||||
final DiffResult list = class1.diff(class2);
|
||||
assertEquals(1, list.getNumberOfDiffs());
|
||||
Diff<?> diff = list.getDiffs().get(0);
|
||||
final Diff<?> diff = list.getDiffs().get(0);
|
||||
assertEquals(Float.valueOf(class1.floatField), diff.getLeft());
|
||||
assertEquals(Float.valueOf(class2.floatField), diff.getRight());
|
||||
}
|
||||
|
@ -213,12 +213,12 @@ public void testFloat() {
|
|||
|
||||
@Test
|
||||
public void testFloatArray() throws Exception {
|
||||
TypeTestClass class1 = new TypeTestClass();
|
||||
TypeTestClass class2 = new TypeTestClass();
|
||||
final TypeTestClass class1 = new TypeTestClass();
|
||||
final TypeTestClass class2 = new TypeTestClass();
|
||||
class2.floatArrayField = new float[] {3.0F, 2.9F, 2.8F};
|
||||
DiffResult list = class1.diff(class2);
|
||||
final DiffResult list = class1.diff(class2);
|
||||
assertEquals(1, list.getNumberOfDiffs());
|
||||
Diff<?> diff = list.getDiffs().get(0);
|
||||
final Diff<?> diff = list.getDiffs().get(0);
|
||||
assertArrayEquals(ArrayUtils.toObject(class1.floatArrayField),
|
||||
(Object[]) diff.getLeft());
|
||||
assertArrayEquals(ArrayUtils.toObject(class2.floatArrayField),
|
||||
|
@ -228,12 +228,12 @@ public void testFloatArray() throws Exception {
|
|||
|
||||
@Test
|
||||
public void testInt() {
|
||||
TypeTestClass class1 = new TypeTestClass();
|
||||
TypeTestClass class2 = new TypeTestClass();
|
||||
final TypeTestClass class1 = new TypeTestClass();
|
||||
final TypeTestClass class2 = new TypeTestClass();
|
||||
class2.intField = 42;
|
||||
DiffResult list = class1.diff(class2);
|
||||
final DiffResult list = class1.diff(class2);
|
||||
assertEquals(1, list.getNumberOfDiffs());
|
||||
Diff<?> diff = list.getDiffs().get(0);
|
||||
final Diff<?> diff = list.getDiffs().get(0);
|
||||
assertEquals(Integer.valueOf(class1.intField), diff.getLeft());
|
||||
assertEquals(Integer.valueOf(class2.intField), diff.getRight());
|
||||
}
|
||||
|
@ -241,12 +241,12 @@ public void testInt() {
|
|||
|
||||
@Test
|
||||
public void testIntArray() throws Exception {
|
||||
TypeTestClass class1 = new TypeTestClass();
|
||||
TypeTestClass class2 = new TypeTestClass();
|
||||
final TypeTestClass class1 = new TypeTestClass();
|
||||
final TypeTestClass class2 = new TypeTestClass();
|
||||
class2.intArrayField = new int[] {3, 2, 1};
|
||||
DiffResult list = class1.diff(class2);
|
||||
final DiffResult list = class1.diff(class2);
|
||||
assertEquals(1, list.getNumberOfDiffs());
|
||||
Diff<?> diff = list.getDiffs().get(0);
|
||||
final Diff<?> diff = list.getDiffs().get(0);
|
||||
assertArrayEquals(ArrayUtils.toObject(class1.intArrayField),
|
||||
(Object[]) diff.getLeft());
|
||||
assertArrayEquals(ArrayUtils.toObject(class2.intArrayField),
|
||||
|
@ -255,12 +255,12 @@ public void testIntArray() throws Exception {
|
|||
|
||||
@Test
|
||||
public void testLong() {
|
||||
TypeTestClass class1 = new TypeTestClass();
|
||||
TypeTestClass class2 = new TypeTestClass();
|
||||
final TypeTestClass class1 = new TypeTestClass();
|
||||
final TypeTestClass class2 = new TypeTestClass();
|
||||
class2.longField = 42L;
|
||||
DiffResult list = class1.diff(class2);
|
||||
final DiffResult list = class1.diff(class2);
|
||||
assertEquals(1, list.getNumberOfDiffs());
|
||||
Diff<?> diff = list.getDiffs().get(0);
|
||||
final Diff<?> diff = list.getDiffs().get(0);
|
||||
assertEquals(Long.valueOf(class1.longField), diff.getLeft());
|
||||
assertEquals(Long.valueOf(class2.longField), diff.getRight());
|
||||
}
|
||||
|
@ -268,12 +268,12 @@ public void testLong() {
|
|||
|
||||
@Test
|
||||
public void testLongArray() throws Exception {
|
||||
TypeTestClass class1 = new TypeTestClass();
|
||||
TypeTestClass class2 = new TypeTestClass();
|
||||
final TypeTestClass class1 = new TypeTestClass();
|
||||
final TypeTestClass class2 = new TypeTestClass();
|
||||
class2.longArrayField = new long[] {3L, 2L, 1L};
|
||||
DiffResult list = class1.diff(class2);
|
||||
final DiffResult list = class1.diff(class2);
|
||||
assertEquals(1, list.getNumberOfDiffs());
|
||||
Diff<?> diff = list.getDiffs().get(0);
|
||||
final Diff<?> diff = list.getDiffs().get(0);
|
||||
assertArrayEquals(ArrayUtils.toObject(class1.longArrayField),
|
||||
(Object[]) diff.getLeft());
|
||||
assertArrayEquals(ArrayUtils.toObject(class2.longArrayField),
|
||||
|
@ -282,12 +282,12 @@ public void testLongArray() throws Exception {
|
|||
|
||||
@Test
|
||||
public void testShort() {
|
||||
TypeTestClass class1 = new TypeTestClass();
|
||||
TypeTestClass class2 = new TypeTestClass();
|
||||
final TypeTestClass class1 = new TypeTestClass();
|
||||
final TypeTestClass class2 = new TypeTestClass();
|
||||
class2.shortField = 42;
|
||||
DiffResult list = class1.diff(class2);
|
||||
final DiffResult list = class1.diff(class2);
|
||||
assertEquals(1, list.getNumberOfDiffs());
|
||||
Diff<?> diff = list.getDiffs().get(0);
|
||||
final Diff<?> diff = list.getDiffs().get(0);
|
||||
assertEquals(Short.valueOf(class1.shortField), diff.getLeft());
|
||||
assertEquals(Short.valueOf(class2.shortField), diff.getRight());
|
||||
}
|
||||
|
@ -295,12 +295,12 @@ public void testShort() {
|
|||
|
||||
@Test
|
||||
public void testShortArray() throws Exception {
|
||||
TypeTestClass class1 = new TypeTestClass();
|
||||
TypeTestClass class2 = new TypeTestClass();
|
||||
final TypeTestClass class1 = new TypeTestClass();
|
||||
final TypeTestClass class2 = new TypeTestClass();
|
||||
class2.shortArrayField = new short[] {3, 2, 1};
|
||||
DiffResult list = class1.diff(class2);
|
||||
final DiffResult list = class1.diff(class2);
|
||||
assertEquals(1, list.getNumberOfDiffs());
|
||||
Diff<?> diff = list.getDiffs().get(0);
|
||||
final Diff<?> diff = list.getDiffs().get(0);
|
||||
assertArrayEquals(ArrayUtils.toObject(class1.shortArrayField),
|
||||
(Object[]) diff.getLeft());
|
||||
assertArrayEquals(ArrayUtils.toObject(class2.shortArrayField),
|
||||
|
@ -309,53 +309,53 @@ public void testShortArray() throws Exception {
|
|||
|
||||
@Test
|
||||
public void testObject() throws Exception {
|
||||
TypeTestClass class1 = new TypeTestClass();
|
||||
TypeTestClass class2 = new TypeTestClass();
|
||||
final TypeTestClass class1 = new TypeTestClass();
|
||||
final TypeTestClass class2 = new TypeTestClass();
|
||||
class2.objectField = "Some string";
|
||||
DiffResult list = class1.diff(class2);
|
||||
final DiffResult list = class1.diff(class2);
|
||||
assertEquals(1, list.getNumberOfDiffs());
|
||||
Diff<?> diff = list.getDiffs().get(0);
|
||||
final Diff<?> diff = list.getDiffs().get(0);
|
||||
assertEquals(class1.objectField, diff.getLeft());
|
||||
assertEquals(class2.objectField, diff.getRight());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testObjectsEqual() throws Exception {
|
||||
TypeTestClass class1 = new TypeTestClass();
|
||||
TypeTestClass class2 = new TypeTestClass();
|
||||
final TypeTestClass class1 = new TypeTestClass();
|
||||
final TypeTestClass class2 = new TypeTestClass();
|
||||
class1.objectField = "Some string";
|
||||
class2.objectField = "Some string";
|
||||
DiffResult list = class1.diff(class2);
|
||||
final DiffResult list = class1.diff(class2);
|
||||
assertEquals(0, list.getNumberOfDiffs());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testObjectArray() throws Exception {
|
||||
TypeTestClass class1 = new TypeTestClass();
|
||||
TypeTestClass class2 = new TypeTestClass();
|
||||
final TypeTestClass class1 = new TypeTestClass();
|
||||
final TypeTestClass class2 = new TypeTestClass();
|
||||
class2.objectArrayField = new Object[] {"string", 1, 2};
|
||||
DiffResult list = class1.diff(class2);
|
||||
final DiffResult list = class1.diff(class2);
|
||||
assertEquals(1, list.getNumberOfDiffs());
|
||||
Diff<?> diff = list.getDiffs().get(0);
|
||||
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 {
|
||||
TypeTestClass class1 = new TypeTestClass();
|
||||
TypeTestClass class2 = new TypeTestClass();
|
||||
final TypeTestClass class1 = new TypeTestClass();
|
||||
final TypeTestClass class2 = new TypeTestClass();
|
||||
class1.objectArrayField = new Object[] {"string", 1, 2};
|
||||
class2.objectArrayField = new Object[] {"string", 1, 2};
|
||||
DiffResult list = class1.diff(class2);
|
||||
final DiffResult list = class1.diff(class2);
|
||||
assertEquals(0, list.getNumberOfDiffs());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testByteArrayEqualAsObject() throws Exception {
|
||||
DiffResult list = new DiffBuilder("String1", "String2", SHORT_STYLE)
|
||||
final DiffResult list = new DiffBuilder("String1", "String2", SHORT_STYLE)
|
||||
.append("foo", (Object) new boolean[] {false}, (Object) new boolean[] {false})
|
||||
.append("foo", (Object) new byte[] {0x01}, (Object) new byte[] {0x01})
|
||||
.append("foo", (Object) new char[] {'a'}, (Object) new char[] {'a'})
|
||||
|
@ -384,8 +384,8 @@ public void testNullRhs() {
|
|||
|
||||
@Test
|
||||
public void testSameObjectIgnoresAppends() {
|
||||
TypeTestClass testClass = new TypeTestClass();
|
||||
DiffResult list = new DiffBuilder(testClass, testClass, SHORT_STYLE)
|
||||
final TypeTestClass testClass = new TypeTestClass();
|
||||
final DiffResult list = new DiffBuilder(testClass, testClass, SHORT_STYLE)
|
||||
.append("ignored", false, true)
|
||||
.build();
|
||||
assertEquals(0, list.getNumberOfDiffs());
|
||||
|
@ -393,9 +393,9 @@ public void testSameObjectIgnoresAppends() {
|
|||
|
||||
@Test
|
||||
public void testSimilarObjectIgnoresAppends() {
|
||||
TypeTestClass testClass1 = new TypeTestClass();
|
||||
TypeTestClass testClass2 = new TypeTestClass();
|
||||
DiffResult list = new DiffBuilder(testClass1, testClass2, SHORT_STYLE)
|
||||
final TypeTestClass testClass1 = new TypeTestClass();
|
||||
final TypeTestClass testClass2 = new TypeTestClass();
|
||||
final DiffResult list = new DiffBuilder(testClass1, testClass2, SHORT_STYLE)
|
||||
.append("ignored", false, true)
|
||||
.build();
|
||||
assertEquals(0, list.getNumberOfDiffs());
|
||||
|
@ -404,7 +404,7 @@ public void testSimilarObjectIgnoresAppends() {
|
|||
|
||||
@Test
|
||||
public void testStylePassedToDiffResult() {
|
||||
TypeTestClass class1 = new TypeTestClass();
|
||||
final TypeTestClass class1 = new TypeTestClass();
|
||||
DiffResult list = class1.diff(class1);
|
||||
assertEquals(SHORT_STYLE, list.getToStringStyle());
|
||||
|
||||
|
|
|
@ -36,9 +36,9 @@ public class DiffResultTest {
|
|||
private static final ToStringStyle SHORT_STYLE = ToStringStyle.SHORT_PREFIX_STYLE;
|
||||
|
||||
private static class SimpleClass implements Diffable<SimpleClass> {
|
||||
private boolean booleanField;
|
||||
private final boolean booleanField;
|
||||
|
||||
public SimpleClass(boolean booleanField) {
|
||||
public SimpleClass(final boolean booleanField) {
|
||||
this.booleanField = booleanField;
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public static String getFieldName() {
|
|||
}
|
||||
|
||||
@Override
|
||||
public DiffResult diff(SimpleClass obj) {
|
||||
public DiffResult diff(final SimpleClass obj) {
|
||||
return new DiffBuilder(this, obj, ToStringStyle.SHORT_PREFIX_STYLE)
|
||||
.append(getFieldName(), booleanField, obj.booleanField)
|
||||
.build();
|
||||
|
@ -59,12 +59,12 @@ private static class EmptyClass {
|
|||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
public void testListIsNonModifiable() {
|
||||
SimpleClass lhs = new SimpleClass(true);
|
||||
SimpleClass rhs = new SimpleClass(false);
|
||||
final SimpleClass lhs = new SimpleClass(true);
|
||||
final SimpleClass rhs = new SimpleClass(false);
|
||||
|
||||
List<Diff<?>> diffs = lhs.diff(rhs).getDiffs();
|
||||
final List<Diff<?>> diffs = lhs.diff(rhs).getDiffs();
|
||||
|
||||
DiffResult list = new DiffResult(lhs, rhs, diffs, SHORT_STYLE);
|
||||
final DiffResult list = new DiffResult(lhs, rhs, diffs, SHORT_STYLE);
|
||||
assertEquals(diffs, list.getDiffs());
|
||||
assertEquals(1, list.getNumberOfDiffs());
|
||||
list.getDiffs().remove(0);
|
||||
|
@ -72,14 +72,14 @@ public void testListIsNonModifiable() {
|
|||
|
||||
@Test
|
||||
public void testIterator() {
|
||||
SimpleClass lhs = new SimpleClass(true);
|
||||
SimpleClass rhs = new SimpleClass(false);
|
||||
final SimpleClass lhs = new SimpleClass(true);
|
||||
final SimpleClass rhs = new SimpleClass(false);
|
||||
|
||||
List<Diff<?>> diffs = lhs.diff(rhs).getDiffs();
|
||||
Iterator<Diff<?>> expectedIterator = diffs.iterator();
|
||||
final List<Diff<?>> diffs = lhs.diff(rhs).getDiffs();
|
||||
final Iterator<Diff<?>> expectedIterator = diffs.iterator();
|
||||
|
||||
DiffResult list = new DiffResult(lhs, rhs, diffs, SHORT_STYLE);
|
||||
Iterator<Diff<?>> iterator = list.iterator();
|
||||
final DiffResult list = new DiffResult(lhs, rhs, diffs, SHORT_STYLE);
|
||||
final Iterator<Diff<?>> iterator = list.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
assertTrue(expectedIterator.hasNext());
|
||||
|
@ -89,7 +89,7 @@ public void testIterator() {
|
|||
|
||||
@Test
|
||||
public void testToStringOutput() {
|
||||
DiffResult list = new DiffBuilder(new EmptyClass(), new EmptyClass(),
|
||||
final DiffResult list = new DiffBuilder(new EmptyClass(), new EmptyClass(),
|
||||
ToStringStyle.SHORT_PREFIX_STYLE).append("test", false, true)
|
||||
.build();
|
||||
assertEquals(
|
||||
|
@ -99,18 +99,18 @@ public void testToStringOutput() {
|
|||
|
||||
@Test
|
||||
public void testToStringSpecifyStyleOutput() {
|
||||
DiffResult list = SIMPLE_FALSE.diff(SIMPLE_TRUE);
|
||||
final DiffResult list = SIMPLE_FALSE.diff(SIMPLE_TRUE);
|
||||
assertTrue(list.getToStringStyle().equals(SHORT_STYLE));
|
||||
|
||||
String lhsString = new ToStringBuilder(SIMPLE_FALSE,
|
||||
final String lhsString = new ToStringBuilder(SIMPLE_FALSE,
|
||||
ToStringStyle.MULTI_LINE_STYLE).append(
|
||||
SimpleClass.getFieldName(), SIMPLE_FALSE.booleanField).build();
|
||||
|
||||
String rhsString = new ToStringBuilder(SIMPLE_TRUE,
|
||||
final String rhsString = new ToStringBuilder(SIMPLE_TRUE,
|
||||
ToStringStyle.MULTI_LINE_STYLE).append(
|
||||
SimpleClass.getFieldName(), SIMPLE_TRUE.booleanField).build();
|
||||
|
||||
String expectedOutput = String.format("%s differs from %s", lhsString,
|
||||
final String expectedOutput = String.format("%s differs from %s", lhsString,
|
||||
rhsString);
|
||||
assertEquals(expectedOutput,
|
||||
list.toString(ToStringStyle.MULTI_LINE_STYLE));
|
||||
|
@ -135,14 +135,14 @@ public void testNullList() {
|
|||
|
||||
@Test
|
||||
public void testNullStyle() {
|
||||
DiffResult diffResult = new DiffResult(SIMPLE_TRUE, SIMPLE_FALSE, SIMPLE_TRUE
|
||||
final DiffResult diffResult = new DiffResult(SIMPLE_TRUE, SIMPLE_FALSE, SIMPLE_TRUE
|
||||
.diff(SIMPLE_FALSE).getDiffs(), null);
|
||||
assertEquals(ToStringStyle.DEFAULT_STYLE, diffResult.getToStringStyle());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoDifferencesString() {
|
||||
DiffResult diffResult = new DiffBuilder(SIMPLE_TRUE, SIMPLE_TRUE,
|
||||
final DiffResult diffResult = new DiffBuilder(SIMPLE_TRUE, SIMPLE_TRUE,
|
||||
SHORT_STYLE).build();
|
||||
assertEquals(DiffResult.OBJECTS_SAME_STRING, diffResult.toString());
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public class DiffTest {
|
|||
private static class BooleanDiff extends Diff<Boolean> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected BooleanDiff(String fieldName) {
|
||||
protected BooleanDiff(final String fieldName) {
|
||||
super(fieldName);
|
||||
}
|
||||
|
||||
|
|
|
@ -1133,17 +1133,17 @@ public void testReflectionArrays() throws Exception {
|
|||
final TestObject one = new TestObject(1);
|
||||
final TestObject two = new TestObject(2);
|
||||
|
||||
Object[] o1 = new Object[] { one };
|
||||
Object[] o2 = new Object[] { two };
|
||||
Object[] o3 = new Object[] { one };
|
||||
final Object[] o1 = new Object[] { one };
|
||||
final Object[] o2 = new Object[] { two };
|
||||
final Object[] o3 = new Object[] { one };
|
||||
|
||||
assertTrue(!EqualsBuilder.reflectionEquals(o1, o2));
|
||||
assertTrue(EqualsBuilder.reflectionEquals(o1, o1));
|
||||
assertTrue(EqualsBuilder.reflectionEquals(o1, o3));
|
||||
|
||||
double[] d1 = { 0, 1 };
|
||||
double[] d2 = { 2, 3 };
|
||||
double[] d3 = { 0, 1 };
|
||||
final double[] d1 = { 0, 1 };
|
||||
final double[] d2 = { 2, 3 };
|
||||
final double[] d3 = { 0, 1 };
|
||||
|
||||
assertTrue(!EqualsBuilder.reflectionEquals(d1, d2));
|
||||
assertTrue(EqualsBuilder.reflectionEquals(d1, d1));
|
||||
|
|
|
@ -121,9 +121,9 @@ public void testToFloatStringF() {
|
|||
*/
|
||||
@Test
|
||||
public void testStringCreateNumberEnsureNoPrecisionLoss(){
|
||||
String shouldBeFloat = "1.23";
|
||||
String shouldBeDouble = "3.40282354e+38";
|
||||
String shouldBeBigDecimal = "1.797693134862315759e+308";
|
||||
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);
|
||||
|
|
|
@ -1255,7 +1255,7 @@ public void testAmbig() {
|
|||
|
||||
@Test
|
||||
public void testRemoveFinalModifier() throws Exception {
|
||||
Field field = StaticContainer.class.getDeclaredField("IMMUTABLE_PRIVATE_2");
|
||||
final Field field = StaticContainer.class.getDeclaredField("IMMUTABLE_PRIVATE_2");
|
||||
assertFalse(field.isAccessible());
|
||||
assertTrue(Modifier.isFinal(field.getModifiers()));
|
||||
FieldUtils.removeFinalModifier(field);
|
||||
|
@ -1266,7 +1266,7 @@ public void testRemoveFinalModifier() throws Exception {
|
|||
|
||||
@Test
|
||||
public void testRemoveFinalModifierWithAccess() throws Exception {
|
||||
Field field = StaticContainer.class.getDeclaredField("IMMUTABLE_PRIVATE_2");
|
||||
final Field field = StaticContainer.class.getDeclaredField("IMMUTABLE_PRIVATE_2");
|
||||
assertFalse(field.isAccessible());
|
||||
assertTrue(Modifier.isFinal(field.getModifiers()));
|
||||
FieldUtils.removeFinalModifier(field, true);
|
||||
|
@ -1277,7 +1277,7 @@ public void testRemoveFinalModifierWithAccess() throws Exception {
|
|||
|
||||
@Test
|
||||
public void testRemoveFinalModifierWithoutAccess() throws Exception {
|
||||
Field field = StaticContainer.class.getDeclaredField("IMMUTABLE_PRIVATE_2");
|
||||
final Field field = StaticContainer.class.getDeclaredField("IMMUTABLE_PRIVATE_2");
|
||||
assertFalse(field.isAccessible());
|
||||
assertTrue(Modifier.isFinal(field.getModifiers()));
|
||||
FieldUtils.removeFinalModifier(field, false);
|
||||
|
@ -1288,7 +1288,7 @@ public void testRemoveFinalModifierWithoutAccess() throws Exception {
|
|||
|
||||
@Test
|
||||
public void testRemoveFinalModifierAccessNotNeeded() throws Exception {
|
||||
Field field = StaticContainer.class.getDeclaredField("IMMUTABLE_PACKAGE");
|
||||
final Field field = StaticContainer.class.getDeclaredField("IMMUTABLE_PACKAGE");
|
||||
assertFalse(field.isAccessible());
|
||||
assertTrue(Modifier.isFinal(field.getModifiers()));
|
||||
FieldUtils.removeFinalModifier(field, false);
|
||||
|
|
|
@ -392,7 +392,7 @@ public void testGetOverrideHierarchyIncludingInterfaces() {
|
|||
new MethodDescriptor(GenericParent.class, "consume", GenericParent.class.getTypeParameters()[0]),
|
||||
new MethodDescriptor(GenericConsumer.class, "consume", GenericConsumer.class.getTypeParameters()[0]))
|
||||
.iterator();
|
||||
for (Method m : MethodUtils.getOverrideHierarchy(method, Interfaces.INCLUDE)) {
|
||||
for (final Method m : MethodUtils.getOverrideHierarchy(method, Interfaces.INCLUDE)) {
|
||||
assertTrue(expected.hasNext());
|
||||
final MethodDescriptor md = expected.next();
|
||||
assertEquals(md.declaringClass, m.getDeclaringClass());
|
||||
|
@ -412,7 +412,7 @@ public void testGetOverrideHierarchyExcludingInterfaces() {
|
|||
Arrays.asList(new MethodDescriptor(StringParameterizedChild.class, "consume", String.class),
|
||||
new MethodDescriptor(GenericParent.class, "consume", GenericParent.class.getTypeParameters()[0]))
|
||||
.iterator();
|
||||
for (Method m : MethodUtils.getOverrideHierarchy(method, Interfaces.EXCLUDE)) {
|
||||
for (final Method m : MethodUtils.getOverrideHierarchy(method, Interfaces.EXCLUDE)) {
|
||||
assertTrue(expected.hasNext());
|
||||
final MethodDescriptor md = expected.next();
|
||||
assertEquals(md.declaringClass, m.getDeclaringClass());
|
||||
|
@ -466,7 +466,7 @@ private static class MethodDescriptor {
|
|||
final String name;
|
||||
final Type[] parameterTypes;
|
||||
|
||||
MethodDescriptor(Class<?> declaringClass, String name, Type... parameterTypes) {
|
||||
MethodDescriptor(final Class<?> declaringClass, final String name, final Type... parameterTypes) {
|
||||
this.declaringClass = declaringClass;
|
||||
this.name = name;
|
||||
this.parameterTypes = parameterTypes;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
public class GenericParent<T> implements GenericConsumer<T> {
|
||||
|
||||
@Override
|
||||
public void consume(T t) {
|
||||
public void consume(final T t) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
*/
|
||||
public class StringParameterizedChild extends GenericParent<String> {
|
||||
@Override
|
||||
public void consume(String t) {
|
||||
public void consume(final String t) {
|
||||
super.consume(t);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1049,8 +1049,8 @@ public void testAppend_FormattedString() {
|
|||
sb = new StrBuilder();
|
||||
sb.append("Hi %s %,d", "Alice", 5000);
|
||||
// group separator depends on system locale
|
||||
char groupingSeparator = DecimalFormatSymbols.getInstance().getGroupingSeparator();
|
||||
String expected = "Hi Alice 5" + groupingSeparator + "000";
|
||||
final char groupingSeparator = DecimalFormatSymbols.getInstance().getGroupingSeparator();
|
||||
final String expected = "Hi Alice 5" + groupingSeparator + "000";
|
||||
assertEquals(expected, sb.toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -101,8 +101,8 @@ public void testChaining() {
|
|||
public void testReadFromReader() throws Exception {
|
||||
String s = "";
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
StrBuilder sb = new StrBuilder();
|
||||
int len = sb.readFrom(new StringReader(s));
|
||||
final StrBuilder sb = new StrBuilder();
|
||||
final int len = sb.readFrom(new StringReader(s));
|
||||
|
||||
assertEquals(s.length(), len);
|
||||
assertEquals(s, sb.toString());
|
||||
|
@ -113,7 +113,7 @@ public void testReadFromReader() throws Exception {
|
|||
|
||||
@Test
|
||||
public void testReadFromReaderAppendsToEnd() throws Exception {
|
||||
StrBuilder sb = new StrBuilder("Test");
|
||||
final StrBuilder sb = new StrBuilder("Test");
|
||||
sb.readFrom(new StringReader(" 123"));
|
||||
assertEquals("Test 123", sb.toString());
|
||||
}
|
||||
|
@ -122,8 +122,8 @@ public void testReadFromReaderAppendsToEnd() throws Exception {
|
|||
public void testReadFromCharBuffer() throws Exception {
|
||||
String s = "";
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
StrBuilder sb = new StrBuilder();
|
||||
int len = sb.readFrom(CharBuffer.wrap(s));
|
||||
final StrBuilder sb = new StrBuilder();
|
||||
final int len = sb.readFrom(CharBuffer.wrap(s));
|
||||
|
||||
assertEquals(s.length(), len);
|
||||
assertEquals(s, sb.toString());
|
||||
|
@ -134,7 +134,7 @@ public void testReadFromCharBuffer() throws Exception {
|
|||
|
||||
@Test
|
||||
public void testReadFromCharBufferAppendsToEnd() throws Exception {
|
||||
StrBuilder sb = new StrBuilder("Test");
|
||||
final StrBuilder sb = new StrBuilder("Test");
|
||||
sb.readFrom(CharBuffer.wrap(" 123"));
|
||||
assertEquals("Test 123", sb.toString());
|
||||
}
|
||||
|
@ -143,8 +143,8 @@ public void testReadFromCharBufferAppendsToEnd() throws Exception {
|
|||
public void testReadFromReadable() throws Exception {
|
||||
String s = "";
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
StrBuilder sb = new StrBuilder();
|
||||
int len = sb.readFrom(new MockReadable(s));
|
||||
final StrBuilder sb = new StrBuilder();
|
||||
final int len = sb.readFrom(new MockReadable(s));
|
||||
|
||||
assertEquals(s.length(), len);
|
||||
assertEquals(s, sb.toString());
|
||||
|
@ -155,7 +155,7 @@ public void testReadFromReadable() throws Exception {
|
|||
|
||||
@Test
|
||||
public void testReadFromReadableAppendsToEnd() throws Exception {
|
||||
StrBuilder sb = new StrBuilder("Test");
|
||||
final StrBuilder sb = new StrBuilder("Test");
|
||||
sb.readFrom(new MockReadable(" 123"));
|
||||
assertEquals("Test 123", sb.toString());
|
||||
}
|
||||
|
|
|
@ -533,7 +533,7 @@ public void testMinutesOfYearWithCalendar() {
|
|||
|
||||
@Test
|
||||
public void testMinutesOfYearWithWrongOffsetBugWithCalendar() {
|
||||
Calendar c = Calendar.getInstance();
|
||||
final Calendar c = Calendar.getInstance();
|
||||
c.set(Calendar.MONTH, Calendar.JANUARY);
|
||||
c.set(Calendar.DAY_OF_YEAR, 1);
|
||||
c.set(Calendar.HOUR_OF_DAY, 0);
|
||||
|
|
|
@ -255,7 +255,7 @@ public void testTimeDateDefaults() {
|
|||
*/
|
||||
@Test
|
||||
public void testLang954() throws Exception {
|
||||
String pattern = "yyyy-MM-dd'T'";
|
||||
final String pattern = "yyyy-MM-dd'T'";
|
||||
FastDateFormat.getInstance(pattern);
|
||||
}
|
||||
|
||||
|
|
|
@ -188,8 +188,8 @@ public void testAmPm() throws ParseException {
|
|||
assertEquals(cal.getTime(), H.parse("2010-08-01 12:33:20"));
|
||||
}
|
||||
|
||||
private Calendar getEraStart(int year, TimeZone zone, Locale locale) {
|
||||
Calendar cal = Calendar.getInstance(zone, locale);
|
||||
private Calendar getEraStart(int year, final TimeZone zone, final Locale locale) {
|
||||
final Calendar cal = Calendar.getInstance(zone, locale);
|
||||
cal.clear();
|
||||
|
||||
// http://docs.oracle.com/javase/6/docs/technotes/guides/intl/calendar.doc.html
|
||||
|
@ -209,7 +209,7 @@ private Calendar getEraStart(int year, TimeZone zone, Locale locale) {
|
|||
return cal;
|
||||
}
|
||||
|
||||
private void validateSdfFormatFdpParseEquality(String format, Locale locale, TimeZone tz, DateParser fdp, Date in, int year, Date cs) throws ParseException {
|
||||
private void validateSdfFormatFdpParseEquality(final String format, final Locale locale, final TimeZone tz, final DateParser fdp, final Date in, final int year, final Date cs) throws ParseException {
|
||||
final SimpleDateFormat sdf = new SimpleDateFormat(format, locale);
|
||||
if (format.equals(SHORT_FORMAT)) {
|
||||
sdf.set2DigitYearStart( cs );
|
||||
|
@ -232,12 +232,12 @@ public void testParses() throws Exception {
|
|||
for(final Locale locale : Locale.getAvailableLocales()) {
|
||||
for(final TimeZone tz : new TimeZone[]{NEW_YORK, REYKJAVIK, GMT}) {
|
||||
for(final int year : new int[]{2003, 1940, 1868, 1867, 1, -1, -1940}) {
|
||||
Calendar cal= getEraStart(year, tz, locale);
|
||||
Date centuryStart= cal.getTime();
|
||||
final Calendar cal= getEraStart(year, tz, locale);
|
||||
final Date centuryStart= cal.getTime();
|
||||
|
||||
cal.set(Calendar.MONTH, 1);
|
||||
cal.set(Calendar.DAY_OF_MONTH, 10);
|
||||
Date in= cal.getTime();
|
||||
final Date in= cal.getTime();
|
||||
|
||||
final FastDateParser fdp= new FastDateParser(format, tz, locale, centuryStart);
|
||||
validateSdfFormatFdpParseEquality(format, locale, tz, fdp, in, year, centuryStart);
|
||||
|
@ -544,7 +544,7 @@ public void testTimeZoneMatches() {
|
|||
|
||||
@Test
|
||||
public void testLang996() throws ParseException {
|
||||
Calendar expected = Calendar.getInstance(NEW_YORK, Locale.US);
|
||||
final Calendar expected = Calendar.getInstance(NEW_YORK, Locale.US);
|
||||
expected.clear();
|
||||
expected.set(2014, 4, 14);
|
||||
|
||||
|
|
Loading…
Reference in New Issue