Remove superfluous parens like:
return (foo + 1); int len = (foo + 1); if ((foo + 1 > 2)) ((String) foo) git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1199894 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
725ca33769
commit
371e866442
|
@ -551,12 +551,12 @@ public class BooleanUtils {
|
|||
switch (str.length()) {
|
||||
case 1: {
|
||||
char ch0 = str.charAt(0);
|
||||
if ((ch0 == 'y' || ch0 == 'Y') ||
|
||||
(ch0 == 't' || ch0 == 'T')) {
|
||||
if (ch0 == 'y' || ch0 == 'Y' ||
|
||||
ch0 == 't' || ch0 == 'T') {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
if ((ch0 == 'n' || ch0 == 'N') ||
|
||||
(ch0 == 'f' || ch0 == 'F')) {
|
||||
if (ch0 == 'n' || ch0 == 'N' ||
|
||||
ch0 == 'f' || ch0 == 'F') {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -187,7 +187,7 @@ public class CharSequenceUtils {
|
|||
static boolean regionMatches(CharSequence cs, boolean ignoreCase, int thisStart,
|
||||
CharSequence substring, int start, int length) {
|
||||
if (cs instanceof String && substring instanceof String) {
|
||||
return ((String) cs).regionMatches(ignoreCase, thisStart, ((String) substring), start, length);
|
||||
return ((String) cs).regionMatches(ignoreCase, thisStart, (String) substring, start, length);
|
||||
} else {
|
||||
// TODO: Implement rather than convert to String
|
||||
return cs.toString().regionMatches(ignoreCase, thisStart, substring.toString(), start, length);
|
||||
|
|
|
@ -178,7 +178,7 @@ public class CharSet implements Serializable {
|
|||
int len = str.length();
|
||||
int pos = 0;
|
||||
while (pos < len) {
|
||||
int remainder = (len - pos);
|
||||
int remainder = len - pos;
|
||||
if (remainder >= 4 && str.charAt(pos) == '^' && str.charAt(pos + 2) == '-') {
|
||||
// negated range
|
||||
set.add(CharRange.isNotIn(str.charAt(pos + 1), str.charAt(pos + 3)));
|
||||
|
|
|
@ -622,7 +622,7 @@ public class ClassUtils {
|
|||
}
|
||||
// have to check for null, as isAssignableFrom doesn't
|
||||
if (cls == null) {
|
||||
return !(toClass.isPrimitive());
|
||||
return !toClass.isPrimitive();
|
||||
}
|
||||
//autoboxing:
|
||||
if (autoboxing) {
|
||||
|
|
|
@ -136,7 +136,7 @@ public class EnumUtils {
|
|||
Validate.notNull(values);
|
||||
long total = 0;
|
||||
for (E constant : values) {
|
||||
total |= (1 << constant.ordinal());
|
||||
total |= 1 << constant.ordinal();
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ public class EnumUtils {
|
|||
final E[] constants = checkBitVectorable(enumClass).getEnumConstants();
|
||||
final EnumSet<E> results = EnumSet.noneOf(enumClass);
|
||||
for (E constant : constants) {
|
||||
if ((value & (1 << constant.ordinal())) != 0) {
|
||||
if ((value & 1 << constant.ordinal()) != 0) {
|
||||
results.add(constant);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ public class ObjectUtils {
|
|||
if (object1 == object2) {
|
||||
return true;
|
||||
}
|
||||
if ((object1 == null) || (object2 == null)) {
|
||||
if (object1 == null || object2 == null) {
|
||||
return false;
|
||||
}
|
||||
return object1.equals(object2);
|
||||
|
@ -196,7 +196,7 @@ public class ObjectUtils {
|
|||
*/
|
||||
public static int hashCode(Object obj) {
|
||||
// hashCode(Object) retained for performance, as hash code is often critical
|
||||
return (obj == null) ? 0 : obj.hashCode();
|
||||
return obj == null ? 0 : obj.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -409,9 +409,9 @@ public class ObjectUtils {
|
|||
if (c1 == c2) {
|
||||
return 0;
|
||||
} else if (c1 == null) {
|
||||
return (nullGreater ? 1 : -1);
|
||||
return nullGreater ? 1 : -1;
|
||||
} else if (c2 == null) {
|
||||
return (nullGreater ? -1 : 1);
|
||||
return nullGreater ? -1 : 1;
|
||||
}
|
||||
return c1.compareTo(c2);
|
||||
}
|
||||
|
|
|
@ -227,7 +227,7 @@ public class RandomStringUtils {
|
|||
} else if (count < 0) {
|
||||
throw new IllegalArgumentException("Requested random string length " + count + " is less than 0.");
|
||||
}
|
||||
if ((start == 0) && (end == 0)) {
|
||||
if (start == 0 && end == 0) {
|
||||
end = 'z' + 1;
|
||||
start = ' ';
|
||||
if (!letters && !numbers) {
|
||||
|
@ -246,9 +246,9 @@ public class RandomStringUtils {
|
|||
} else {
|
||||
ch = chars[random.nextInt(gap) + start];
|
||||
}
|
||||
if ((letters && Character.isLetter(ch))
|
||||
|| (numbers && Character.isDigit(ch))
|
||||
|| (!letters && !numbers)) {
|
||||
if (letters && Character.isLetter(ch)
|
||||
|| numbers && Character.isDigit(ch)
|
||||
|| !letters && !numbers) {
|
||||
if(ch >= 56320 && ch <= 57343) {
|
||||
if(count == 0) {
|
||||
count++;
|
||||
|
|
|
@ -219,7 +219,7 @@ public final class Range<T> implements Serializable {
|
|||
if (element == null) {
|
||||
return false;
|
||||
}
|
||||
return (comparator.compare(element, minimum) > -1) && (comparator.compare(element, maximum) < 1);
|
||||
return comparator.compare(element, minimum) > -1 && comparator.compare(element, maximum) < 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -225,7 +225,7 @@ public class StringUtils {
|
|||
return true;
|
||||
}
|
||||
for (int i = 0; i < strLen; i++) {
|
||||
if ((Character.isWhitespace(cs.charAt(i)) == false)) {
|
||||
if (Character.isWhitespace(cs.charAt(i)) == false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -484,13 +484,13 @@ public class StringUtils {
|
|||
}
|
||||
int start = 0;
|
||||
if (stripChars == null) {
|
||||
while ((start != strLen) && Character.isWhitespace(str.charAt(start))) {
|
||||
while (start != strLen && Character.isWhitespace(str.charAt(start))) {
|
||||
start++;
|
||||
}
|
||||
} else if (stripChars.length() == 0) {
|
||||
return str;
|
||||
} else {
|
||||
while ((start != strLen) && (stripChars.indexOf(str.charAt(start)) != INDEX_NOT_FOUND)) {
|
||||
while (start != strLen && stripChars.indexOf(str.charAt(start)) != INDEX_NOT_FOUND) {
|
||||
start++;
|
||||
}
|
||||
}
|
||||
|
@ -529,13 +529,13 @@ public class StringUtils {
|
|||
}
|
||||
|
||||
if (stripChars == null) {
|
||||
while ((end != 0) && Character.isWhitespace(str.charAt(end - 1))) {
|
||||
while (end != 0 && Character.isWhitespace(str.charAt(end - 1))) {
|
||||
end--;
|
||||
}
|
||||
} else if (stripChars.length() == 0) {
|
||||
return str;
|
||||
} else {
|
||||
while ((end != 0) && (stripChars.indexOf(str.charAt(end - 1)) != INDEX_NOT_FOUND)) {
|
||||
while (end != 0 && stripChars.indexOf(str.charAt(end - 1)) != INDEX_NOT_FOUND) {
|
||||
end--;
|
||||
}
|
||||
}
|
||||
|
@ -1087,7 +1087,7 @@ public class StringUtils {
|
|||
if (startPos < 0) {
|
||||
startPos = 0;
|
||||
}
|
||||
int endLimit = (str.length() - searchStr.length()) + 1;
|
||||
int endLimit = str.length() - searchStr.length() + 1;
|
||||
if (startPos > endLimit) {
|
||||
return INDEX_NOT_FOUND;
|
||||
}
|
||||
|
@ -1333,7 +1333,7 @@ public class StringUtils {
|
|||
if (str == null || searchStr == null) {
|
||||
return INDEX_NOT_FOUND;
|
||||
}
|
||||
if (startPos > (str.length() - searchStr.length())) {
|
||||
if (startPos > str.length() - searchStr.length()) {
|
||||
startPos = str.length() - searchStr.length();
|
||||
}
|
||||
if (startPos < 0) {
|
||||
|
@ -1946,7 +1946,7 @@ public class StringUtils {
|
|||
}
|
||||
}
|
||||
|
||||
return (ret == Integer.MAX_VALUE) ? INDEX_NOT_FOUND : ret;
|
||||
return ret == Integer.MAX_VALUE ? INDEX_NOT_FOUND : ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2212,7 +2212,7 @@ public class StringUtils {
|
|||
if (pos < 0) {
|
||||
pos = 0;
|
||||
}
|
||||
if (str.length() <= (pos + len)) {
|
||||
if (str.length() <= pos + len) {
|
||||
return str.substring(pos);
|
||||
}
|
||||
return str.substring(pos, pos + len);
|
||||
|
@ -2378,7 +2378,7 @@ public class StringUtils {
|
|||
return EMPTY;
|
||||
}
|
||||
int pos = str.lastIndexOf(separator);
|
||||
if (pos == INDEX_NOT_FOUND || pos == (str.length() - separator.length())) {
|
||||
if (pos == INDEX_NOT_FOUND || pos == str.length() - separator.length()) {
|
||||
return EMPTY;
|
||||
}
|
||||
return str.substring(pos + separator.length());
|
||||
|
@ -2486,7 +2486,7 @@ public class StringUtils {
|
|||
int openLen = open.length();
|
||||
List<String> list = new ArrayList<String>();
|
||||
int pos = 0;
|
||||
while (pos < (strLen - closeLen)) {
|
||||
while (pos < strLen - closeLen) {
|
||||
int start = str.indexOf(open, pos);
|
||||
if (start < 0) {
|
||||
break;
|
||||
|
@ -2773,7 +2773,7 @@ public class StringUtils {
|
|||
return ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
}
|
||||
|
||||
if ((separator == null) || (EMPTY.equals(separator))) {
|
||||
if (separator == null || EMPTY.equals(separator)) {
|
||||
// Split on whitespace.
|
||||
return splitWorker(str, null, max, preserveAllTokens);
|
||||
}
|
||||
|
@ -2932,7 +2932,7 @@ public class StringUtils {
|
|||
match = true;
|
||||
i++;
|
||||
}
|
||||
if (match || (preserveAllTokens && lastMatch)) {
|
||||
if (match || preserveAllTokens && lastMatch) {
|
||||
list.add(str.substring(start, i));
|
||||
}
|
||||
return list.toArray(new String[list.size()]);
|
||||
|
@ -3108,7 +3108,7 @@ public class StringUtils {
|
|||
i++;
|
||||
}
|
||||
}
|
||||
if (match || (preserveAllTokens && lastMatch)) {
|
||||
if (match || preserveAllTokens && lastMatch) {
|
||||
list.add(str.substring(start, i));
|
||||
}
|
||||
return list.toArray(new String[list.size()]);
|
||||
|
@ -3299,7 +3299,7 @@ public class StringUtils {
|
|||
if (array == null) {
|
||||
return null;
|
||||
}
|
||||
int noOfItems = (endIndex - startIndex);
|
||||
int noOfItems = endIndex - startIndex;
|
||||
if (noOfItems <= 0) {
|
||||
return EMPTY;
|
||||
}
|
||||
|
@ -3384,7 +3384,7 @@ public class StringUtils {
|
|||
|
||||
// endIndex - startIndex > 0: Len = NofStrings *(len(firstString) + len(separator))
|
||||
// (Assuming that all Strings are roughly equally long)
|
||||
int noOfItems = (endIndex - startIndex);
|
||||
int noOfItems = endIndex - startIndex;
|
||||
if (noOfItems <= 0) {
|
||||
return EMPTY;
|
||||
}
|
||||
|
@ -3867,8 +3867,8 @@ public class StringUtils {
|
|||
}
|
||||
int replLength = searchString.length();
|
||||
int increase = replacement.length() - replLength;
|
||||
increase = (increase < 0 ? 0 : increase);
|
||||
increase *= (max < 0 ? 16 : (max > 64 ? 64 : max));
|
||||
increase = increase < 0 ? 0 : increase;
|
||||
increase *= max < 0 ? 16 : max > 64 ? 64 : max;
|
||||
StringBuilder buf = new StringBuilder(text.length() + increase);
|
||||
while (end != INDEX_NOT_FOUND) {
|
||||
buf.append(text.substring(start, end)).append(replacement);
|
||||
|
@ -5214,7 +5214,7 @@ public class StringUtils {
|
|||
}
|
||||
int sz = cs.length();
|
||||
for (int i = 0; i < sz; i++) {
|
||||
if ((Character.isLetter(cs.charAt(i)) == false) && (cs.charAt(i) != ' ')) {
|
||||
if (Character.isLetter(cs.charAt(i)) == false && cs.charAt(i) != ' ') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -5284,7 +5284,7 @@ public class StringUtils {
|
|||
}
|
||||
int sz = cs.length();
|
||||
for (int i = 0; i < sz; i++) {
|
||||
if ((Character.isLetterOrDigit(cs.charAt(i)) == false) && (cs.charAt(i) != ' ')) {
|
||||
if (Character.isLetterOrDigit(cs.charAt(i)) == false && cs.charAt(i) != ' ') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -5396,7 +5396,7 @@ public class StringUtils {
|
|||
}
|
||||
int sz = cs.length();
|
||||
for (int i = 0; i < sz; i++) {
|
||||
if ((Character.isDigit(cs.charAt(i)) == false) && (cs.charAt(i) != ' ')) {
|
||||
if (Character.isDigit(cs.charAt(i)) == false && cs.charAt(i) != ' ') {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -5429,7 +5429,7 @@ public class StringUtils {
|
|||
}
|
||||
int sz = cs.length();
|
||||
for (int i = 0; i < sz; i++) {
|
||||
if ((Character.isWhitespace(cs.charAt(i)) == false)) {
|
||||
if (Character.isWhitespace(cs.charAt(i)) == false) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -5726,7 +5726,7 @@ public class StringUtils {
|
|||
if (offset > str.length()) {
|
||||
offset = str.length();
|
||||
}
|
||||
if ((str.length() - offset) < (maxWidth - 3)) {
|
||||
if (str.length() - offset < maxWidth - 3) {
|
||||
offset = str.length() - (maxWidth - 3);
|
||||
}
|
||||
final String abrevMarker = "...";
|
||||
|
@ -5736,7 +5736,7 @@ public class StringUtils {
|
|||
if (maxWidth < 7) {
|
||||
throw new IllegalArgumentException("Minimum abbreviation width with offset is 7");
|
||||
}
|
||||
if ((offset + (maxWidth - 3)) < str.length()) {
|
||||
if (offset + maxWidth - 3 < str.length()) {
|
||||
return abrevMarker + abbreviate(str.substring(offset), maxWidth - 3);
|
||||
}
|
||||
return abrevMarker + str.substring(str.length() - (maxWidth - 3));
|
||||
|
@ -5776,7 +5776,7 @@ public class StringUtils {
|
|||
return str;
|
||||
}
|
||||
|
||||
if (length >= str.length() || length < (middle.length()+2)) {
|
||||
if (length >= str.length() || length < middle.length()+2) {
|
||||
return str;
|
||||
}
|
||||
|
||||
|
@ -5934,7 +5934,7 @@ public class StringUtils {
|
|||
}
|
||||
|
||||
// handle lists containing all nulls or all empty strings
|
||||
if (allStringsNull || (longestStrLen == 0 && !anyStringNull)) {
|
||||
if (allStringsNull || longestStrLen == 0 && !anyStringNull) {
|
||||
return INDEX_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
@ -6365,7 +6365,7 @@ public class StringUtils {
|
|||
*/
|
||||
private static boolean startsWith(CharSequence str, CharSequence prefix, boolean ignoreCase) {
|
||||
if (str == null || prefix == null) {
|
||||
return (str == null && prefix == null);
|
||||
return str == null && prefix == null;
|
||||
}
|
||||
if (prefix.length() > str.length()) {
|
||||
return false;
|
||||
|
|
|
@ -181,7 +181,7 @@ public class ConcurrentUtils {
|
|||
*/
|
||||
public static <T> T initialize(ConcurrentInitializer<T> initializer)
|
||||
throws ConcurrentException {
|
||||
return (initializer != null) ? initializer.get() : null;
|
||||
return initializer != null ? initializer.get() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -244,7 +244,7 @@ public class ConcurrentUtils {
|
|||
}
|
||||
|
||||
V result = map.putIfAbsent(key, value);
|
||||
return (result != null) ? result : value;
|
||||
return result != null ? result : value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -88,7 +88,7 @@ public class ConstantInitializer<T> implements ConcurrentInitializer<T> {
|
|||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (getObject() != null) ? getObject().hashCode() : 0;
|
||||
return getObject() != null ? getObject().hashCode() : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -358,7 +358,7 @@ public class TimedSemaphore {
|
|||
* unit
|
||||
*/
|
||||
public synchronized double getAverageCallsPerPeriod() {
|
||||
return (periodCount == 0) ? 0 : (double) totalAcquireCount
|
||||
return periodCount == 0 ? 0 : (double) totalAcquireCount
|
||||
/ (double) periodCount;
|
||||
}
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ public class ExceptionUtils {
|
|||
*/
|
||||
public static Throwable getRootCause(Throwable throwable) {
|
||||
List<Throwable> list = getThrowableList(throwable);
|
||||
return (list.size() < 2 ? null : (Throwable)list.get(list.size() - 1));
|
||||
return list.size() < 2 ? null : (Throwable)list.get(list.size() - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -690,7 +690,7 @@ public class ExceptionUtils {
|
|||
*/
|
||||
public static String getRootCauseMessage(Throwable th) {
|
||||
Throwable root = ExceptionUtils.getRootCause(th);
|
||||
root = (root == null ? th : root);
|
||||
root = root == null ? th : root;
|
||||
return getMessage(root);
|
||||
}
|
||||
|
||||
|
|
|
@ -247,7 +247,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
|
|||
* @throws ArithmeticException if the the algorithm does not converge
|
||||
*/
|
||||
public static Fraction getFraction(double value) {
|
||||
int sign = (value < 0 ? -1 : 1);
|
||||
int sign = value < 0 ? -1 : 1;
|
||||
value = Math.abs(value);
|
||||
if (value > Integer.MAX_VALUE || Double.isNaN(value)) {
|
||||
throw new ArithmeticException
|
||||
|
@ -291,7 +291,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
|
|||
denom1 = denom2;
|
||||
i++;
|
||||
// System.out.println(">>" + delta1 +" "+ delta2+" "+(delta1 > delta2)+" "+i+" "+denom2);
|
||||
} while ((delta1 > delta2) && (denom2 <= 10000) && (denom2 > 0) && (i < 25));
|
||||
} while (delta1 > delta2 && denom2 <= 10000 && denom2 > 0 && i < 25);
|
||||
if (i == 25) {
|
||||
throw new ArithmeticException("Unable to convert double to fraction");
|
||||
}
|
||||
|
@ -440,7 +440,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
|
|||
*/
|
||||
@Override
|
||||
public float floatValue() {
|
||||
return ((float) numerator) / ((float) denominator);
|
||||
return (float) numerator / (float) denominator;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -451,7 +451,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
|
|||
*/
|
||||
@Override
|
||||
public double doubleValue() {
|
||||
return ((double) numerator) / ((double) denominator);
|
||||
return (double) numerator / (double) denominator;
|
||||
}
|
||||
|
||||
// Calculations
|
||||
|
@ -555,7 +555,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
|
|||
return this.invert().pow(-power);
|
||||
} else {
|
||||
Fraction f = this.multiplyBy(this);
|
||||
if ((power % 2) == 0) { // if even...
|
||||
if (power % 2 == 0) { // if even...
|
||||
return f.pow(power/2);
|
||||
} else { // if odd...
|
||||
return f.pow(power/2).multiplyBy(this);
|
||||
|
@ -575,8 +575,8 @@ public final class Fraction extends Number implements Comparable<Fraction> {
|
|||
*/
|
||||
private static int greatestCommonDivisor(int u, int v) {
|
||||
// From Commons Math:
|
||||
if ((u == 0) || (v == 0)) {
|
||||
if ((u == Integer.MIN_VALUE) || (v == Integer.MIN_VALUE)) {
|
||||
if (u == 0 || v == 0) {
|
||||
if (u == Integer.MIN_VALUE || v == Integer.MIN_VALUE) {
|
||||
throw new ArithmeticException("overflow: gcd is 2^31");
|
||||
}
|
||||
return Math.abs(u) + Math.abs(v);
|
||||
|
@ -601,7 +601,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
|
|||
}
|
||||
// B2. Initialize: u and v have been divided by 2^k and at least
|
||||
// one is odd.
|
||||
int t = ((u&1)==1) ? v : -(u/2)/*B3*/;
|
||||
int t = (u&1)==1 ? v : -(u/2)/*B3*/;
|
||||
// t negative: u was odd, v may be even (t replaces v)
|
||||
// t positive: u was even, v is odd (t replaces u)
|
||||
do {
|
||||
|
@ -637,7 +637,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
|
|||
* an int
|
||||
*/
|
||||
private static int mulAndCheck(int x, int y) {
|
||||
long m = ((long)x)*((long)y);
|
||||
long m = (long)x*(long)y;
|
||||
if (m < Integer.MIN_VALUE ||
|
||||
m > Integer.MAX_VALUE) {
|
||||
throw new ArithmeticException("overflow: mul");
|
||||
|
@ -656,7 +656,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
|
|||
*/
|
||||
private static int mulPosAndCheck(int x, int y) {
|
||||
/* assert x>=0 && y>=0; */
|
||||
long m = ((long)x)*((long)y);
|
||||
long m = (long)x*(long)y;
|
||||
if (m > Integer.MAX_VALUE) {
|
||||
throw new ArithmeticException("overflow: mulPos");
|
||||
}
|
||||
|
@ -770,7 +770,7 @@ public final class Fraction extends Number implements Comparable<Fraction> {
|
|||
// but d2 doesn't need extra precision because
|
||||
// d2 = gcd(t,d1) = gcd(t mod d1, d1)
|
||||
int tmodd1 = t.mod(BigInteger.valueOf(d1)).intValue();
|
||||
int d2 = (tmodd1==0)?d1:greatestCommonDivisor(tmodd1, d1);
|
||||
int d2 = tmodd1==0?d1:greatestCommonDivisor(tmodd1, d1);
|
||||
|
||||
// result is (t/d2) / (u'/d1)(v'/d2)
|
||||
BigInteger w = t.divide(BigInteger.valueOf(d2));
|
||||
|
@ -849,8 +849,8 @@ public final class Fraction extends Number implements Comparable<Fraction> {
|
|||
return false;
|
||||
}
|
||||
Fraction other = (Fraction) obj;
|
||||
return (getNumerator() == other.getNumerator() &&
|
||||
getDenominator() == other.getDenominator());
|
||||
return getNumerator() == other.getNumerator() &&
|
||||
getDenominator() == other.getDenominator();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -271,8 +271,8 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>,
|
|||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (obj instanceof MutableDouble)
|
||||
&& (Double.doubleToLongBits(((MutableDouble) obj).value) == Double.doubleToLongBits(value));
|
||||
return obj instanceof MutableDouble
|
||||
&& Double.doubleToLongBits(((MutableDouble) obj).value) == Double.doubleToLongBits(value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -283,7 +283,7 @@ public class MutableDouble extends Number implements Comparable<MutableDouble>,
|
|||
@Override
|
||||
public int hashCode() {
|
||||
long bits = Double.doubleToLongBits(value);
|
||||
return (int) (bits ^ (bits >>> 32));
|
||||
return (int) (bits ^ bits >>> 32);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
@ -273,8 +273,8 @@ public class MutableFloat extends Number implements Comparable<MutableFloat>, Mu
|
|||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return (obj instanceof MutableFloat)
|
||||
&& (Float.floatToIntBits(((MutableFloat) obj).value) == Float.floatToIntBits(value));
|
||||
return obj instanceof MutableFloat
|
||||
&& Float.floatToIntBits(((MutableFloat) obj).value) == Float.floatToIntBits(value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -580,7 +580,7 @@ public class StrSubstitutor {
|
|||
StrMatcher suffixMatcher = getVariableSuffixMatcher();
|
||||
char escape = getEscapeChar();
|
||||
|
||||
boolean top = (priorVariables == null);
|
||||
boolean top = priorVariables == null;
|
||||
boolean altered = false;
|
||||
int lengthChange = 0;
|
||||
char[] chars = buf.buffer;
|
||||
|
@ -656,7 +656,7 @@ public class StrSubstitutor {
|
|||
int change = substitute(buf, startPos,
|
||||
varLen, priorVariables);
|
||||
change = change
|
||||
+ (varLen - (endPos - startPos));
|
||||
+ varLen - (endPos - startPos);
|
||||
pos += change;
|
||||
bufEnd += change;
|
||||
lengthChange += change;
|
||||
|
@ -678,7 +678,7 @@ public class StrSubstitutor {
|
|||
}
|
||||
}
|
||||
if (top) {
|
||||
return (altered ? 1 : 0);
|
||||
return altered ? 1 : 0;
|
||||
}
|
||||
return lengthChange;
|
||||
}
|
||||
|
|
|
@ -728,7 +728,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
|
|||
// string or the end of the input
|
||||
workArea.clear();
|
||||
int pos = start;
|
||||
boolean quoting = (quoteLen > 0);
|
||||
boolean quoting = quoteLen > 0;
|
||||
int trimStart = 0;
|
||||
|
||||
while (pos < len) {
|
||||
|
@ -746,7 +746,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
|
|||
if (isQuote(chars, pos + quoteLen, len, quoteStart, quoteLen)) {
|
||||
// matched pair of quotes, thus an escaped quote
|
||||
workArea.append(chars, pos, quoteLen);
|
||||
pos += (quoteLen * 2);
|
||||
pos += quoteLen * 2;
|
||||
trimStart = workArea.size();
|
||||
continue;
|
||||
}
|
||||
|
@ -820,7 +820,7 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
|
|||
*/
|
||||
private boolean isQuote(char[] chars, int pos, int len, int quoteStart, int quoteLen) {
|
||||
for (int i = 0; i < quoteLen; i++) {
|
||||
if ((pos + i) >= len || chars[pos + i] != chars[quoteStart + i]) {
|
||||
if (pos + i >= len || chars[pos + i] != chars[quoteStart + i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ public class WordUtils {
|
|||
int offset = 0;
|
||||
StringBuilder wrappedLine = new StringBuilder(inputLineLength + 32);
|
||||
|
||||
while ((inputLineLength - offset) > wrapLength) {
|
||||
while (inputLineLength - offset > wrapLength) {
|
||||
if (str.charAt(offset) == ' ') {
|
||||
offset++;
|
||||
continue;
|
||||
|
@ -267,7 +267,7 @@ public class WordUtils {
|
|||
* @since 2.1
|
||||
*/
|
||||
public static String capitalizeFully(String str, char... delimiters) {
|
||||
int delimLen = (delimiters == null ? -1 : delimiters.length);
|
||||
int delimLen = delimiters == null ? -1 : delimiters.length;
|
||||
if (StringUtils.isEmpty(str) || delimLen == 0) {
|
||||
return str;
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ public class WordUtils {
|
|||
* @since 2.1
|
||||
*/
|
||||
public static String uncapitalize(String str, char... delimiters) {
|
||||
int delimLen = (delimiters == null ? -1 : delimiters.length);
|
||||
int delimLen = delimiters == null ? -1 : delimiters.length;
|
||||
if (StringUtils.isEmpty(str) || delimLen == 0) {
|
||||
return str;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public class NumericEntityUnescaper extends CharSequenceTranslator {
|
|||
* @return whether the option is set
|
||||
*/
|
||||
public boolean isSet(OPTION option) {
|
||||
return (options == null) ? false : options.contains(option);
|
||||
return options == null ? false : options.contains(option);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,14 +95,14 @@ public class NumericEntityUnescaper extends CharSequenceTranslator {
|
|||
|
||||
int end = start;
|
||||
// Note that this supports character codes without a ; on the end
|
||||
while(end < seqEnd && ( (input.charAt(end) >= '0' && input.charAt(end) <= '9') ||
|
||||
(input.charAt(end) >= 'a' && input.charAt(end) <= 'f') ||
|
||||
(input.charAt(end) >= 'A' && input.charAt(end) <= 'F') ) )
|
||||
while(end < seqEnd && ( input.charAt(end) >= '0' && input.charAt(end) <= '9' ||
|
||||
input.charAt(end) >= 'a' && input.charAt(end) <= 'f' ||
|
||||
input.charAt(end) >= 'A' && input.charAt(end) <= 'F' ) )
|
||||
{
|
||||
end++;
|
||||
}
|
||||
|
||||
boolean semiNext = (end != seqEnd) && (input.charAt(end) == ';');
|
||||
boolean semiNext = end != seqEnd && input.charAt(end) == ';';
|
||||
|
||||
if(!semiNext) {
|
||||
if(isSet(OPTION.semiColonRequired)) {
|
||||
|
@ -132,7 +132,7 @@ public class NumericEntityUnescaper extends CharSequenceTranslator {
|
|||
out.write(entityValue);
|
||||
}
|
||||
|
||||
return 2 + (end - start) + (isHex ? 1 : 0) + (semiNext ? 1 : 0);
|
||||
return 2 + end - start + (isHex ? 1 : 0) + (semiNext ? 1 : 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -34,18 +34,18 @@ public class UnicodeUnescaper extends CharSequenceTranslator {
|
|||
*/
|
||||
@Override
|
||||
public int translate(CharSequence input, int index, Writer out) throws IOException {
|
||||
if (input.charAt(index) == '\\' && (index + 1 < input.length()) && input.charAt(index + 1) == 'u') {
|
||||
if (input.charAt(index) == '\\' && index + 1 < input.length() && input.charAt(index + 1) == 'u') {
|
||||
// consume optional additional 'u' chars
|
||||
int i = 2;
|
||||
while ((index + i < input.length()) && input.charAt(index + i) == 'u') {
|
||||
while (index + i < input.length() && input.charAt(index + i) == 'u') {
|
||||
i++;
|
||||
}
|
||||
|
||||
if ((index + i < input.length()) && (input.charAt(index + i) == '+')) {
|
||||
if (index + i < input.length() && input.charAt(index + i) == '+') {
|
||||
i++;
|
||||
}
|
||||
|
||||
if ((index + i + 4 <= input.length())) {
|
||||
if (index + i + 4 <= input.length()) {
|
||||
// Get 4 hex digits
|
||||
CharSequence unicode = input.subSequence(index + i, index + i + 4);
|
||||
|
||||
|
|
|
@ -248,7 +248,7 @@ public class StopWatch {
|
|||
if (this.runningState != STATE_SUSPENDED) {
|
||||
throw new IllegalStateException("Stopwatch must be suspended to resume. ");
|
||||
}
|
||||
this.startTime += (System.nanoTime() - this.stopTime);
|
||||
this.startTime += System.nanoTime() - this.stopTime;
|
||||
this.runningState = STATE_RUNNING;
|
||||
}
|
||||
|
||||
|
|
|
@ -197,33 +197,33 @@ public class ArrayUtilsAddTest {
|
|||
|
||||
//show that not casting is okay
|
||||
newArray = ArrayUtils.add((Object[])null, "a");
|
||||
assertTrue(Arrays.equals((new String[]{"a"}), newArray));
|
||||
assertTrue(Arrays.equals((new Object[]{"a"}), newArray));
|
||||
assertTrue(Arrays.equals(new String[]{"a"}, newArray));
|
||||
assertTrue(Arrays.equals(new Object[]{"a"}, newArray));
|
||||
assertEquals(String.class, newArray.getClass().getComponentType());
|
||||
|
||||
//show that not casting to Object[] is okay and will assume String based on "a"
|
||||
String[] newStringArray = ArrayUtils.add(null, "a");
|
||||
assertTrue(Arrays.equals((new String[]{"a"}), newStringArray));
|
||||
assertTrue(Arrays.equals((new Object[]{"a"}), newStringArray));
|
||||
assertTrue(Arrays.equals(new String[]{"a"}, newStringArray));
|
||||
assertTrue(Arrays.equals(new Object[]{"a"}, newStringArray));
|
||||
assertEquals(String.class, newStringArray.getClass().getComponentType());
|
||||
|
||||
String[] stringArray1 = new String[]{"a", "b", "c"};
|
||||
newArray = ArrayUtils.add(stringArray1, null);
|
||||
assertTrue(Arrays.equals((new String[]{"a", "b", "c", null}), newArray));
|
||||
assertTrue(Arrays.equals(new String[]{"a", "b", "c", null}, newArray));
|
||||
assertEquals(String.class, newArray.getClass().getComponentType());
|
||||
|
||||
newArray = ArrayUtils.add(stringArray1, "d");
|
||||
assertTrue(Arrays.equals((new String[]{"a", "b", "c", "d"}), newArray));
|
||||
assertTrue(Arrays.equals(new String[]{"a", "b", "c", "d"}, newArray));
|
||||
assertEquals(String.class, newArray.getClass().getComponentType());
|
||||
|
||||
Number[] numberArray1 = new Number[]{Integer.valueOf(1), Double.valueOf(2)};
|
||||
newArray = ArrayUtils.add(numberArray1, Float.valueOf(3));
|
||||
assertTrue(Arrays.equals((new Number[]{Integer.valueOf(1), Double.valueOf(2), Float.valueOf(3)}), newArray));
|
||||
assertTrue(Arrays.equals(new Number[]{Integer.valueOf(1), Double.valueOf(2), Float.valueOf(3)}, newArray));
|
||||
assertEquals(Number.class, newArray.getClass().getComponentType());
|
||||
|
||||
numberArray1 = null;
|
||||
newArray = ArrayUtils.add(numberArray1, Float.valueOf(3));
|
||||
assertTrue(Arrays.equals((new Float[]{Float.valueOf(3)}), newArray));
|
||||
assertTrue(Arrays.equals(new Float[]{Float.valueOf(3)}, newArray));
|
||||
assertEquals(Float.class, newArray.getClass().getComponentType());
|
||||
}
|
||||
|
||||
|
@ -256,31 +256,31 @@ public class ArrayUtilsAddTest {
|
|||
newArray = ArrayUtils.addAll(stringArray1, (String[]) null);
|
||||
assertNotSame(stringArray1, newArray);
|
||||
assertTrue(Arrays.equals(stringArray1, newArray));
|
||||
assertTrue(Arrays.equals((new String[]{"a", "b", "c"}), newArray));
|
||||
assertTrue(Arrays.equals(new String[]{"a", "b", "c"}, newArray));
|
||||
assertEquals(String.class, newArray.getClass().getComponentType());
|
||||
newArray = ArrayUtils.addAll(null, stringArray2);
|
||||
assertNotSame(stringArray2, newArray);
|
||||
assertTrue(Arrays.equals(stringArray2, newArray));
|
||||
assertTrue(Arrays.equals((new String[]{"1", "2", "3"}), newArray));
|
||||
assertTrue(Arrays.equals(new String[]{"1", "2", "3"}, newArray));
|
||||
assertEquals(String.class, newArray.getClass().getComponentType());
|
||||
newArray = ArrayUtils.addAll(stringArray1, stringArray2);
|
||||
assertTrue(Arrays.equals((new String[]{"a", "b", "c", "1", "2", "3"}), newArray));
|
||||
assertTrue(Arrays.equals(new String[]{"a", "b", "c", "1", "2", "3"}, newArray));
|
||||
assertEquals(String.class, newArray.getClass().getComponentType());
|
||||
newArray = ArrayUtils.addAll(ArrayUtils.EMPTY_STRING_ARRAY, (String[]) null);
|
||||
assertTrue(Arrays.equals(ArrayUtils.EMPTY_STRING_ARRAY, newArray));
|
||||
assertTrue(Arrays.equals((new String[]{}), newArray));
|
||||
assertTrue(Arrays.equals(new String[]{}, newArray));
|
||||
assertEquals(String.class, newArray.getClass().getComponentType());
|
||||
newArray = ArrayUtils.addAll(null, ArrayUtils.EMPTY_STRING_ARRAY);
|
||||
assertTrue(Arrays.equals(ArrayUtils.EMPTY_STRING_ARRAY, newArray));
|
||||
assertTrue(Arrays.equals((new String[]{}), newArray));
|
||||
assertTrue(Arrays.equals(new String[]{}, newArray));
|
||||
assertEquals(String.class, newArray.getClass().getComponentType());
|
||||
newArray = ArrayUtils.addAll(ArrayUtils.EMPTY_STRING_ARRAY, ArrayUtils.EMPTY_STRING_ARRAY);
|
||||
assertTrue(Arrays.equals(ArrayUtils.EMPTY_STRING_ARRAY, newArray));
|
||||
assertTrue(Arrays.equals((new String[]{}), newArray));
|
||||
assertTrue(Arrays.equals(new String[]{}, newArray));
|
||||
assertEquals(String.class, newArray.getClass().getComponentType());
|
||||
String[] stringArrayNull = new String []{null};
|
||||
newArray = ArrayUtils.addAll(stringArrayNull, stringArrayNull);
|
||||
assertTrue(Arrays.equals((new String[]{null, null}), newArray));
|
||||
assertTrue(Arrays.equals(new String[]{null, null}, newArray));
|
||||
assertEquals(String.class, newArray.getClass().getComponentType());
|
||||
|
||||
// boolean
|
||||
|
@ -369,21 +369,21 @@ public class ArrayUtilsAddTest {
|
|||
public void testAddObjectAtIndex() {
|
||||
Object[] newArray;
|
||||
newArray = ArrayUtils.add((Object[])null, 0, "a");
|
||||
assertTrue(Arrays.equals((new String[]{"a"}), newArray));
|
||||
assertTrue(Arrays.equals((new Object[]{"a"}), newArray));
|
||||
assertTrue(Arrays.equals(new String[]{"a"}, newArray));
|
||||
assertTrue(Arrays.equals(new Object[]{"a"}, newArray));
|
||||
assertEquals(String.class, newArray.getClass().getComponentType());
|
||||
String[] stringArray1 = new String[]{"a", "b", "c"};
|
||||
newArray = ArrayUtils.add(stringArray1, 0, null);
|
||||
assertTrue(Arrays.equals((new String[]{null, "a", "b", "c"}), newArray));
|
||||
assertTrue(Arrays.equals(new String[]{null, "a", "b", "c"}, newArray));
|
||||
assertEquals(String.class, newArray.getClass().getComponentType());
|
||||
newArray = ArrayUtils.add(stringArray1, 1, null);
|
||||
assertTrue(Arrays.equals((new String[]{"a", null, "b", "c"}), newArray));
|
||||
assertTrue(Arrays.equals(new String[]{"a", null, "b", "c"}, newArray));
|
||||
assertEquals(String.class, newArray.getClass().getComponentType());
|
||||
newArray = ArrayUtils.add(stringArray1, 3, null);
|
||||
assertTrue(Arrays.equals((new String[]{"a", "b", "c", null}), newArray));
|
||||
assertTrue(Arrays.equals(new String[]{"a", "b", "c", null}, newArray));
|
||||
assertEquals(String.class, newArray.getClass().getComponentType());
|
||||
newArray = ArrayUtils.add(stringArray1, 3, "d");
|
||||
assertTrue(Arrays.equals((new String[]{"a", "b", "c", "d"}), newArray));
|
||||
assertTrue(Arrays.equals(new String[]{"a", "b", "c", "d"}, newArray));
|
||||
assertEquals(String.class, newArray.getClass().getComponentType());
|
||||
assertEquals(String.class, newArray.getClass().getComponentType());
|
||||
|
||||
|
|
|
@ -149,7 +149,7 @@ public class BitFieldTest extends TestCase {
|
|||
}
|
||||
for (int j = 0; j < 128; j++) {
|
||||
assertEquals(bf_zero.getShortValue(bf_zero.setShortValue((short) 0, (short) j)), (short) 0);
|
||||
assertEquals(bf_zero.setShortValue((short) 0, (short) j), (short) (0));
|
||||
assertEquals(bf_zero.setShortValue((short) 0, (short) j), (short) 0);
|
||||
}
|
||||
|
||||
// verify that excess bits are stripped off
|
||||
|
|
|
@ -148,7 +148,7 @@ public class CharUtilsPerfRun {
|
|||
int t = 0;
|
||||
for (int i = 0; i < loopCount; i++) {
|
||||
for (char ch : CHAR_SAMPLES) {
|
||||
boolean b = (ch >= '0' && ch <= '9');
|
||||
boolean b = ch >= '0' && ch <= '9';
|
||||
t += b ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -286,7 +286,7 @@ public class RandomStringUtilsTest extends junit.framework.TestCase {
|
|||
double sumSq = 0.0d;
|
||||
double dev = 0.0d;
|
||||
for (int i = 0; i < observed.length; i++) {
|
||||
dev = (observed[i] - expected[i]);
|
||||
dev = observed[i] - expected[i];
|
||||
sumSq += dev * dev / expected[i];
|
||||
}
|
||||
return sumSq;
|
||||
|
@ -311,8 +311,8 @@ public class RandomStringUtilsTest extends junit.framework.TestCase {
|
|||
for (int i=0; i < orig.length() && i < copy.length(); i++) {
|
||||
char o = orig.charAt(i);
|
||||
char c = copy.charAt(i);
|
||||
assertEquals("differs at " + i + "(" + Integer.toHexString((new Character(o)).hashCode()) + "," +
|
||||
Integer.toHexString((new Character(c)).hashCode()) + ")", o, c);
|
||||
assertEquals("differs at " + i + "(" + Integer.toHexString(new Character(o).hashCode()) + "," +
|
||||
Integer.toHexString(new Character(c).hashCode()) + ")", o, c);
|
||||
}
|
||||
// compare length also
|
||||
assertEquals(orig.length(), copy.length());
|
||||
|
|
|
@ -46,7 +46,7 @@ public class CompareToBuilderTest {
|
|||
return false;
|
||||
}
|
||||
TestObject rhs = (TestObject) o;
|
||||
return (a == rhs.a);
|
||||
return a == rhs.a;
|
||||
}
|
||||
|
||||
public void setA(int a) {
|
||||
|
@ -57,7 +57,7 @@ public class CompareToBuilderTest {
|
|||
return a;
|
||||
}
|
||||
public int compareTo(TestObject rhs) {
|
||||
return (a < rhs.a) ? -1 : (a > rhs.a) ? +1 : 0;
|
||||
return a < rhs.a ? -1 : a > rhs.a ? +1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class CompareToBuilderTest {
|
|||
return false;
|
||||
}
|
||||
TestSubObject rhs = (TestSubObject) o;
|
||||
return super.equals(o) && (b == rhs.b);
|
||||
return super.equals(o) && b == rhs.b;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,7 @@ public class CompareToBuilderTest {
|
|||
}
|
||||
|
||||
// strongly recommended but not strictly required
|
||||
assertTrue((CompareToBuilder.reflectionCompare(x, y, testTransients) ==0 ) == EqualsBuilder.reflectionEquals(x, y, testTransients));
|
||||
assertTrue(CompareToBuilder.reflectionCompare(x, y, testTransients) ==0 == EqualsBuilder.reflectionEquals(x, y, testTransients));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -823,9 +823,9 @@ public class CompareToBuilderTest {
|
|||
float[][] array3 = new float[2][3];
|
||||
for (int i = 0; i < array1.length; ++i) {
|
||||
for (int j = 0; j < array1[0].length; j++) {
|
||||
array1[i][j] = ((i + 1) * (j + 1));
|
||||
array2[i][j] = ((i + 1) * (j + 1));
|
||||
array3[i][j] = ((i + 1) * (j + 1));
|
||||
array1[i][j] = (i + 1) * (j + 1);
|
||||
array2[i][j] = (i + 1) * (j + 1);
|
||||
array3[i][j] = (i + 1) * (j + 1);
|
||||
}
|
||||
}
|
||||
array3[1][2] = 100;
|
||||
|
@ -847,9 +847,9 @@ public class CompareToBuilderTest {
|
|||
double[][] array3 = new double[2][3];
|
||||
for (int i = 0; i < array1.length; ++i) {
|
||||
for (int j = 0; j < array1[0].length; j++) {
|
||||
array1[i][j] = ((i + 1) * (j + 1));
|
||||
array2[i][j] = ((i + 1) * (j + 1));
|
||||
array3[i][j] = ((i + 1) * (j + 1));
|
||||
array1[i][j] = (i + 1) * (j + 1);
|
||||
array2[i][j] = (i + 1) * (j + 1);
|
||||
array3[i][j] = (i + 1) * (j + 1);
|
||||
}
|
||||
}
|
||||
array3[1][2] = 100;
|
||||
|
@ -871,9 +871,9 @@ public class CompareToBuilderTest {
|
|||
boolean[][] array3 = new boolean[2][3];
|
||||
for (int i = 0; i < array1.length; ++i) {
|
||||
for (int j = 0; j < array1[0].length; j++) {
|
||||
array1[i][j] = ((i == 1) ^ (j == 1));
|
||||
array2[i][j] = ((i == 1) ^ (j == 1));
|
||||
array3[i][j] = ((i == 1) ^ (j == 1));
|
||||
array1[i][j] = i == 1 ^ j == 1;
|
||||
array2[i][j] = i == 1 ^ j == 1;
|
||||
array3[i][j] = i == 1 ^ j == 1;
|
||||
}
|
||||
}
|
||||
array3[1][2] = false;
|
||||
|
|
|
@ -50,7 +50,7 @@ public class EqualsBuilderTest {
|
|||
}
|
||||
|
||||
TestObject rhs = (TestObject) o;
|
||||
return (a == rhs.a);
|
||||
return a == rhs.a;
|
||||
}
|
||||
|
||||
public void setA(int a) {
|
||||
|
@ -80,7 +80,7 @@ public class EqualsBuilderTest {
|
|||
}
|
||||
|
||||
TestSubObject rhs = (TestSubObject) o;
|
||||
return super.equals(o) && (b == rhs.b);
|
||||
return super.equals(o) && b == rhs.b;
|
||||
}
|
||||
|
||||
public void setB(int b) {
|
||||
|
@ -712,8 +712,8 @@ public class EqualsBuilderTest {
|
|||
boolean[][] array2 = new boolean[2][2];
|
||||
for (int i = 0; i < array1.length; ++i) {
|
||||
for (int j = 0; j < array1[0].length; j++) {
|
||||
array1[i][j] = (i == 1) || (j == 1);
|
||||
array2[i][j] = (i == 1) || (j == 1);
|
||||
array1[i][j] = i == 1 || j == 1;
|
||||
array2[i][j] = i == 1 || j == 1;
|
||||
}
|
||||
}
|
||||
assertTrue(new EqualsBuilder().append(array1, array1).isEquals());
|
||||
|
|
|
@ -94,7 +94,7 @@ public class HashCodeBuilderTest {
|
|||
return false;
|
||||
}
|
||||
TestObject rhs = (TestObject) o;
|
||||
return (a == rhs.a);
|
||||
return a == rhs.a;
|
||||
}
|
||||
|
||||
public void setA(int a) {
|
||||
|
@ -131,7 +131,7 @@ public class HashCodeBuilderTest {
|
|||
return false;
|
||||
}
|
||||
TestSubObject rhs = (TestSubObject) o;
|
||||
return super.equals(o) && (b == rhs.b);
|
||||
return super.equals(o) && b == rhs.b;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ public class HashCodeBuilderTest {
|
|||
@Test
|
||||
public void testSuper() {
|
||||
Object obj = new Object();
|
||||
assertEquals(17 * 37 + (19 * 41 + obj.hashCode()), new HashCodeBuilder(17, 37).appendSuper(
|
||||
assertEquals(17 * 37 + 19 * 41 + obj.hashCode(), new HashCodeBuilder(17, 37).appendSuper(
|
||||
new HashCodeBuilder(19, 41).append(obj).toHashCode()).toHashCode());
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,7 @@ public class HashCodeBuilderTest {
|
|||
@SuppressWarnings("cast") // cast is not really needed, keep for consistency
|
||||
public void testLong() {
|
||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((long) 0L).toHashCode());
|
||||
assertEquals(17 * 37 + (int) (123456789L ^ (123456789L >> 32)), new HashCodeBuilder(17, 37).append(
|
||||
assertEquals(17 * 37 + (int) (123456789L ^ 123456789L >> 32), new HashCodeBuilder(17, 37).append(
|
||||
(long) 123456789L).toHashCode());
|
||||
}
|
||||
|
||||
|
@ -263,7 +263,7 @@ public class HashCodeBuilderTest {
|
|||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((double) 0d).toHashCode());
|
||||
double d = 1234567.89;
|
||||
long l = Double.doubleToLongBits(d);
|
||||
assertEquals(17 * 37 + (int) (l ^ (l >> 32)), new HashCodeBuilder(17, 37).append(d).toHashCode());
|
||||
assertEquals(17 * 37 + (int) (l ^ l >> 32), new HashCodeBuilder(17, 37).append(d).toHashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -285,7 +285,7 @@ public class HashCodeBuilderTest {
|
|||
public void testObjectArray() {
|
||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((Object[]) null).toHashCode());
|
||||
Object[] obj = new Object[2];
|
||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
obj[0] = new Object();
|
||||
assertEquals((17 * 37 + obj[0].hashCode()) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
obj[1] = new Object();
|
||||
|
@ -296,7 +296,7 @@ public class HashCodeBuilderTest {
|
|||
@Test
|
||||
public void testObjectArrayAsObject() {
|
||||
Object[] obj = new Object[2];
|
||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
obj[0] = new Object();
|
||||
assertEquals((17 * 37 + obj[0].hashCode()) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
obj[1] = new Object();
|
||||
|
@ -308,24 +308,24 @@ public class HashCodeBuilderTest {
|
|||
public void testLongArray() {
|
||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((long[]) null).toHashCode());
|
||||
long[] obj = new long[2];
|
||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
obj[0] = 5L;
|
||||
int h1 = (int) (5L ^ (5L >> 32));
|
||||
int h1 = (int) (5L ^ 5L >> 32);
|
||||
assertEquals((17 * 37 + h1) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
obj[1] = 6L;
|
||||
int h2 = (int) (6L ^ (6L >> 32));
|
||||
int h2 = (int) (6L ^ 6L >> 32);
|
||||
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLongArrayAsObject() {
|
||||
long[] obj = new long[2];
|
||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
obj[0] = 5L;
|
||||
int h1 = (int) (5L ^ (5L >> 32));
|
||||
int h1 = (int) (5L ^ 5L >> 32);
|
||||
assertEquals((17 * 37 + h1) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
obj[1] = 6L;
|
||||
int h2 = (int) (6L ^ (6L >> 32));
|
||||
int h2 = (int) (6L ^ 6L >> 32);
|
||||
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
}
|
||||
|
||||
|
@ -333,7 +333,7 @@ public class HashCodeBuilderTest {
|
|||
public void testIntArray() {
|
||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((int[]) null).toHashCode());
|
||||
int[] obj = new int[2];
|
||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
obj[0] = 5;
|
||||
assertEquals((17 * 37 + 5) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
obj[1] = 6;
|
||||
|
@ -343,7 +343,7 @@ public class HashCodeBuilderTest {
|
|||
@Test
|
||||
public void testIntArrayAsObject() {
|
||||
int[] obj = new int[2];
|
||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
obj[0] = 5;
|
||||
assertEquals((17 * 37 + 5) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
obj[1] = 6;
|
||||
|
@ -354,7 +354,7 @@ public class HashCodeBuilderTest {
|
|||
public void testShortArray() {
|
||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((short[]) null).toHashCode());
|
||||
short[] obj = new short[2];
|
||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
obj[0] = (short) 5;
|
||||
assertEquals((17 * 37 + 5) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
obj[1] = (short) 6;
|
||||
|
@ -364,7 +364,7 @@ public class HashCodeBuilderTest {
|
|||
@Test
|
||||
public void testShortArrayAsObject() {
|
||||
short[] obj = new short[2];
|
||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
obj[0] = (short) 5;
|
||||
assertEquals((17 * 37 + 5) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
obj[1] = (short) 6;
|
||||
|
@ -375,7 +375,7 @@ public class HashCodeBuilderTest {
|
|||
public void testCharArray() {
|
||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((char[]) null).toHashCode());
|
||||
char[] obj = new char[2];
|
||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
obj[0] = (char) 5;
|
||||
assertEquals((17 * 37 + 5) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
obj[1] = (char) 6;
|
||||
|
@ -385,7 +385,7 @@ public class HashCodeBuilderTest {
|
|||
@Test
|
||||
public void testCharArrayAsObject() {
|
||||
char[] obj = new char[2];
|
||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
obj[0] = (char) 5;
|
||||
assertEquals((17 * 37 + 5) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
obj[1] = (char) 6;
|
||||
|
@ -396,7 +396,7 @@ public class HashCodeBuilderTest {
|
|||
public void testByteArray() {
|
||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((byte[]) null).toHashCode());
|
||||
byte[] obj = new byte[2];
|
||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
obj[0] = (byte) 5;
|
||||
assertEquals((17 * 37 + 5) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
obj[1] = (byte) 6;
|
||||
|
@ -406,7 +406,7 @@ public class HashCodeBuilderTest {
|
|||
@Test
|
||||
public void testByteArrayAsObject() {
|
||||
byte[] obj = new byte[2];
|
||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
obj[0] = (byte) 5;
|
||||
assertEquals((17 * 37 + 5) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
obj[1] = (byte) 6;
|
||||
|
@ -417,28 +417,28 @@ public class HashCodeBuilderTest {
|
|||
public void testDoubleArray() {
|
||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((double[]) null).toHashCode());
|
||||
double[] obj = new double[2];
|
||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
obj[0] = 5.4d;
|
||||
long l1 = Double.doubleToLongBits(5.4d);
|
||||
int h1 = (int) (l1 ^ (l1 >> 32));
|
||||
int h1 = (int) (l1 ^ l1 >> 32);
|
||||
assertEquals((17 * 37 + h1) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
obj[1] = 6.3d;
|
||||
long l2 = Double.doubleToLongBits(6.3d);
|
||||
int h2 = (int) (l2 ^ (l2 >> 32));
|
||||
int h2 = (int) (l2 ^ l2 >> 32);
|
||||
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoubleArrayAsObject() {
|
||||
double[] obj = new double[2];
|
||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
obj[0] = 5.4d;
|
||||
long l1 = Double.doubleToLongBits(5.4d);
|
||||
int h1 = (int) (l1 ^ (l1 >> 32));
|
||||
int h1 = (int) (l1 ^ l1 >> 32);
|
||||
assertEquals((17 * 37 + h1) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
obj[1] = 6.3d;
|
||||
long l2 = Double.doubleToLongBits(6.3d);
|
||||
int h2 = (int) (l2 ^ (l2 >> 32));
|
||||
int h2 = (int) (l2 ^ l2 >> 32);
|
||||
assertEquals((17 * 37 + h1) * 37 + h2, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
}
|
||||
|
||||
|
@ -446,7 +446,7 @@ public class HashCodeBuilderTest {
|
|||
public void testFloatArray() {
|
||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append((float[]) null).toHashCode());
|
||||
float[] obj = new float[2];
|
||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
obj[0] = 5.4f;
|
||||
int h1 = Float.floatToIntBits(5.4f);
|
||||
assertEquals((17 * 37 + h1) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
|
@ -458,7 +458,7 @@ public class HashCodeBuilderTest {
|
|||
@Test
|
||||
public void testFloatArrayAsObject() {
|
||||
float[] obj = new float[2];
|
||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
obj[0] = 5.4f;
|
||||
int h1 = Float.floatToIntBits(5.4f);
|
||||
assertEquals((17 * 37 + h1) * 37, new HashCodeBuilder(17, 37).append((Object) obj).toHashCode());
|
||||
|
@ -491,7 +491,7 @@ public class HashCodeBuilderTest {
|
|||
@Test
|
||||
public void testBooleanMultiArray() {
|
||||
boolean[][] obj = new boolean[2][];
|
||||
assertEquals((17 * 37) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
assertEquals(17 * 37 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
obj[0] = new boolean[0];
|
||||
assertEquals(17 * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
obj[0] = new boolean[1];
|
||||
|
@ -501,23 +501,23 @@ public class HashCodeBuilderTest {
|
|||
obj[0][0] = true;
|
||||
assertEquals(((17 * 37 + 0) * 37 + 1) * 37, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
obj[1] = new boolean[1];
|
||||
assertEquals((((17 * 37 + 0) * 37 + 1) * 37 + 1), new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
assertEquals(((17 * 37 + 0) * 37 + 1) * 37 + 1, new HashCodeBuilder(17, 37).append(obj).toHashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReflectionHashCodeExcludeFields() throws Exception {
|
||||
TestObjectWithMultipleFields x = new TestObjectWithMultipleFields(1, 2, 3);
|
||||
|
||||
assertEquals((((17 * 37 + 1) * 37 + 2) * 37 + 3), HashCodeBuilder.reflectionHashCode(x));
|
||||
assertEquals(((17 * 37 + 1) * 37 + 2) * 37 + 3, HashCodeBuilder.reflectionHashCode(x));
|
||||
|
||||
assertEquals((((17 * 37 + 1) * 37 + 2) * 37 + 3), HashCodeBuilder.reflectionHashCode(x, (String[]) null));
|
||||
assertEquals((((17 * 37 + 1) * 37 + 2) * 37 + 3), HashCodeBuilder.reflectionHashCode(x, new String[]{}));
|
||||
assertEquals((((17 * 37 + 1) * 37 + 2) * 37 + 3), HashCodeBuilder.reflectionHashCode(x, new String[]{"xxx"}));
|
||||
assertEquals(((17 * 37 + 1) * 37 + 2) * 37 + 3, HashCodeBuilder.reflectionHashCode(x, (String[]) null));
|
||||
assertEquals(((17 * 37 + 1) * 37 + 2) * 37 + 3, HashCodeBuilder.reflectionHashCode(x, new String[]{}));
|
||||
assertEquals(((17 * 37 + 1) * 37 + 2) * 37 + 3, HashCodeBuilder.reflectionHashCode(x, new String[]{"xxx"}));
|
||||
|
||||
assertEquals(((17 * 37 + 1) * 37 + 3), HashCodeBuilder.reflectionHashCode(x, new String[]{"two"}));
|
||||
assertEquals(((17 * 37 + 1) * 37 + 2), HashCodeBuilder.reflectionHashCode(x, new String[]{"three"}));
|
||||
assertEquals((17 * 37 + 1) * 37 + 3, HashCodeBuilder.reflectionHashCode(x, new String[]{"two"}));
|
||||
assertEquals((17 * 37 + 1) * 37 + 2, HashCodeBuilder.reflectionHashCode(x, new String[]{"three"}));
|
||||
|
||||
assertEquals((17 * 37 + 1), HashCodeBuilder.reflectionHashCode(x, new String[]{"two", "three"}));
|
||||
assertEquals(17 * 37 + 1, HashCodeBuilder.reflectionHashCode(x, new String[]{"two", "three"}));
|
||||
|
||||
assertEquals(17, HashCodeBuilder.reflectionHashCode(x, new String[]{"one", "two", "three"}));
|
||||
assertEquals(17, HashCodeBuilder.reflectionHashCode(x, new String[]{"one", "two", "three", "xxx"}));
|
||||
|
|
|
@ -428,7 +428,7 @@ public class TimedSemaphoreTest {
|
|||
*/
|
||||
@Override
|
||||
protected ScheduledFuture<?> startTimer() {
|
||||
return (schedFuture != null) ? schedFuture : super.startTimer();
|
||||
return schedFuture != null ? schedFuture : super.startTimer();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -551,12 +551,12 @@ public class StrTokenizerTest extends TestCase {
|
|||
* <code>null</code>.
|
||||
*/
|
||||
public void testCloneNotSupportedException() {
|
||||
Object notCloned = (new StrTokenizer() {
|
||||
Object notCloned = new StrTokenizer() {
|
||||
@Override
|
||||
Object cloneReset() throws CloneNotSupportedException {
|
||||
throw new CloneNotSupportedException("test");
|
||||
}
|
||||
}).clone();
|
||||
}.clone();
|
||||
assertNull(notCloned);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue