PMD: Remove useless parentheses
This commit is contained in:
parent
3421e6adb4
commit
9c5b6cdc71
|
@ -76,10 +76,10 @@ public static String squeeze(final String str, final String... set) {
|
|||
for (int i = 1; i < sz; i++) {
|
||||
ch = chrs[i];
|
||||
if (ch == lastChar) {
|
||||
if ((inChars != null) && (ch == inChars)) {
|
||||
if (inChars != null && ch == inChars) {
|
||||
continue;
|
||||
} else {
|
||||
if ((notInChars == null) || (ch != notInChars)) {
|
||||
if (notInChars == null || ch != notInChars) {
|
||||
if (chars.contains(ch)) {
|
||||
inChars = ch;
|
||||
continue;
|
||||
|
|
|
@ -142,7 +142,7 @@ public static Locale toLocale(final String str) {
|
|||
case 2:
|
||||
if (StringUtils.isAllLowerCase(split[0]) &&
|
||||
(split[0].length() == 2 || split[0].length() == 3) &&
|
||||
(split[1].length() == 0 || (split[1].length() == 2 && StringUtils.isAllUpperCase(split[1]))) &&
|
||||
(split[1].length() == 0 || split[1].length() == 2 && StringUtils.isAllUpperCase(split[1])) &&
|
||||
split[2].length() > 0) {
|
||||
return new Locale(split[0], split[1], split[2]);
|
||||
}
|
||||
|
|
|
@ -322,9 +322,9 @@ private static void reflectionAppend(
|
|||
for (int i = 0; i < fields.length && builder.comparison == 0; i++) {
|
||||
final Field f = fields[i];
|
||||
if (!ArrayUtils.contains(excludeFields, f.getName())
|
||||
&& (!f.getName().contains("$"))
|
||||
&& !f.getName().contains("$")
|
||||
&& (useTransients || !Modifier.isTransient(f.getModifiers()))
|
||||
&& (!Modifier.isStatic(f.getModifiers()))) {
|
||||
&& !Modifier.isStatic(f.getModifiers())) {
|
||||
try {
|
||||
builder.append(f.get(lhs), f.get(rhs));
|
||||
} catch (final IllegalAccessException e) {
|
||||
|
@ -475,7 +475,7 @@ public CompareToBuilder append(final long lhs, final long rhs) {
|
|||
if (comparison != 0) {
|
||||
return this;
|
||||
}
|
||||
comparison = ((lhs < rhs) ? -1 : ((lhs > rhs) ? 1 : 0));
|
||||
comparison = lhs < rhs ? -1 : lhs > rhs ? 1 : 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -491,7 +491,7 @@ public CompareToBuilder append(final int lhs, final int rhs) {
|
|||
if (comparison != 0) {
|
||||
return this;
|
||||
}
|
||||
comparison = ((lhs < rhs) ? -1 : ((lhs > rhs) ? 1 : 0));
|
||||
comparison = lhs < rhs ? -1 : lhs > rhs ? 1 : 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -507,7 +507,7 @@ public CompareToBuilder append(final short lhs, final short rhs) {
|
|||
if (comparison != 0) {
|
||||
return this;
|
||||
}
|
||||
comparison = ((lhs < rhs) ? -1 : ((lhs > rhs) ? 1 : 0));
|
||||
comparison = lhs < rhs ? -1 : lhs > rhs ? 1 : 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -523,7 +523,7 @@ public CompareToBuilder append(final char lhs, final char rhs) {
|
|||
if (comparison != 0) {
|
||||
return this;
|
||||
}
|
||||
comparison = ((lhs < rhs) ? -1 : ((lhs > rhs) ? 1 : 0));
|
||||
comparison = lhs < rhs ? -1 : lhs > rhs ? 1 : 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -539,7 +539,7 @@ public CompareToBuilder append(final byte lhs, final byte rhs) {
|
|||
if (comparison != 0) {
|
||||
return this;
|
||||
}
|
||||
comparison = ((lhs < rhs) ? -1 : ((lhs > rhs) ? 1 : 0));
|
||||
comparison = lhs < rhs ? -1 : lhs > rhs ? 1 : 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -672,7 +672,7 @@ public CompareToBuilder append(final Object[] lhs, final Object[] rhs, final Com
|
|||
return this;
|
||||
}
|
||||
if (lhs.length != rhs.length) {
|
||||
comparison = (lhs.length < rhs.length) ? -1 : +1;
|
||||
comparison = lhs.length < rhs.length ? -1 : +1;
|
||||
return this;
|
||||
}
|
||||
for (int i = 0; i < lhs.length && comparison == 0; i++) {
|
||||
|
@ -712,7 +712,7 @@ public CompareToBuilder append(final long[] lhs, final long[] rhs) {
|
|||
return this;
|
||||
}
|
||||
if (lhs.length != rhs.length) {
|
||||
comparison = (lhs.length < rhs.length) ? -1 : +1;
|
||||
comparison = lhs.length < rhs.length ? -1 : +1;
|
||||
return this;
|
||||
}
|
||||
for (int i = 0; i < lhs.length && comparison == 0; i++) {
|
||||
|
@ -752,7 +752,7 @@ public CompareToBuilder append(final int[] lhs, final int[] rhs) {
|
|||
return this;
|
||||
}
|
||||
if (lhs.length != rhs.length) {
|
||||
comparison = (lhs.length < rhs.length) ? -1 : +1;
|
||||
comparison = lhs.length < rhs.length ? -1 : +1;
|
||||
return this;
|
||||
}
|
||||
for (int i = 0; i < lhs.length && comparison == 0; i++) {
|
||||
|
@ -792,7 +792,7 @@ public CompareToBuilder append(final short[] lhs, final short[] rhs) {
|
|||
return this;
|
||||
}
|
||||
if (lhs.length != rhs.length) {
|
||||
comparison = (lhs.length < rhs.length) ? -1 : +1;
|
||||
comparison = lhs.length < rhs.length ? -1 : +1;
|
||||
return this;
|
||||
}
|
||||
for (int i = 0; i < lhs.length && comparison == 0; i++) {
|
||||
|
@ -832,7 +832,7 @@ public CompareToBuilder append(final char[] lhs, final char[] rhs) {
|
|||
return this;
|
||||
}
|
||||
if (lhs.length != rhs.length) {
|
||||
comparison = (lhs.length < rhs.length) ? -1 : +1;
|
||||
comparison = lhs.length < rhs.length ? -1 : +1;
|
||||
return this;
|
||||
}
|
||||
for (int i = 0; i < lhs.length && comparison == 0; i++) {
|
||||
|
@ -872,7 +872,7 @@ public CompareToBuilder append(final byte[] lhs, final byte[] rhs) {
|
|||
return this;
|
||||
}
|
||||
if (lhs.length != rhs.length) {
|
||||
comparison = (lhs.length < rhs.length) ? -1 : +1;
|
||||
comparison = lhs.length < rhs.length ? -1 : +1;
|
||||
return this;
|
||||
}
|
||||
for (int i = 0; i < lhs.length && comparison == 0; i++) {
|
||||
|
@ -912,7 +912,7 @@ public CompareToBuilder append(final double[] lhs, final double[] rhs) {
|
|||
return this;
|
||||
}
|
||||
if (lhs.length != rhs.length) {
|
||||
comparison = (lhs.length < rhs.length) ? -1 : +1;
|
||||
comparison = lhs.length < rhs.length ? -1 : +1;
|
||||
return this;
|
||||
}
|
||||
for (int i = 0; i < lhs.length && comparison == 0; i++) {
|
||||
|
@ -952,7 +952,7 @@ public CompareToBuilder append(final float[] lhs, final float[] rhs) {
|
|||
return this;
|
||||
}
|
||||
if (lhs.length != rhs.length) {
|
||||
comparison = (lhs.length < rhs.length) ? -1 : +1;
|
||||
comparison = lhs.length < rhs.length ? -1 : +1;
|
||||
return this;
|
||||
}
|
||||
for (int i = 0; i < lhs.length && comparison == 0; i++) {
|
||||
|
@ -992,7 +992,7 @@ public CompareToBuilder append(final boolean[] lhs, final boolean[] rhs) {
|
|||
return this;
|
||||
}
|
||||
if (lhs.length != rhs.length) {
|
||||
comparison = (lhs.length < rhs.length) ? -1 : +1;
|
||||
comparison = lhs.length < rhs.length ? -1 : +1;
|
||||
return this;
|
||||
}
|
||||
for (int i = 0; i < lhs.length && comparison == 0; i++) {
|
||||
|
|
|
@ -415,8 +415,8 @@ private static void reflectionAppend(
|
|||
if (!ArrayUtils.contains(excludeFields, f.getName())
|
||||
&& !f.getName().contains("$")
|
||||
&& (useTransients || !Modifier.isTransient(f.getModifiers()))
|
||||
&& (!Modifier.isStatic(f.getModifiers()))
|
||||
&& (!f.isAnnotationPresent(EqualsExclude.class))) {
|
||||
&& !Modifier.isStatic(f.getModifiers())
|
||||
&& !f.isAnnotationPresent(EqualsExclude.class)) {
|
||||
try {
|
||||
builder.append(f.get(lhs), f.get(rhs));
|
||||
} catch (final IllegalAccessException e) {
|
||||
|
|
|
@ -194,8 +194,8 @@ private static void reflectionAppend(final Object object, final Class<?> clazz,
|
|||
if (!ArrayUtils.contains(excludeFields, field.getName())
|
||||
&& !field.getName().contains("$")
|
||||
&& (useTransients || !Modifier.isTransient(field.getModifiers()))
|
||||
&& (!Modifier.isStatic(field.getModifiers()))
|
||||
&& (!field.isAnnotationPresent(HashCodeExclude.class))) {
|
||||
&& !Modifier.isStatic(field.getModifiers())
|
||||
&& !field.isAnnotationPresent(HashCodeExclude.class)) {
|
||||
try {
|
||||
final Object fieldValue = field.get(object);
|
||||
builder.append(fieldValue);
|
||||
|
|
|
@ -475,10 +475,10 @@ public static Number createNumber(final String str) throws NumberFormatException
|
|||
}
|
||||
}
|
||||
final int hexDigits = str.length() - pfxLen;
|
||||
if (hexDigits > 16 || (hexDigits == 16 && firstSigDigit > '7')) { // too many for Long
|
||||
if (hexDigits > 16 || hexDigits == 16 && firstSigDigit > '7') { // too many for Long
|
||||
return createBigInteger(str);
|
||||
}
|
||||
if (hexDigits > 8 || (hexDigits == 8 && firstSigDigit > '7')) { // too many for an int
|
||||
if (hexDigits > 8 || hexDigits == 8 && firstSigDigit > '7') { // too many for an int
|
||||
return createLong(str);
|
||||
}
|
||||
return createInteger(str);
|
||||
|
@ -541,7 +541,7 @@ public static Number createNumber(final String str) throws NumberFormatException
|
|||
case 'F' :
|
||||
try {
|
||||
final Float f = NumberUtils.createFloat(str);
|
||||
if (!(f.isInfinite() || (f.floatValue() == 0.0F && !allZeros))) {
|
||||
if (!(f.isInfinite() || f.floatValue() == 0.0F && !allZeros)) {
|
||||
//If it's too big for a float or the float value = 0 and the string
|
||||
//has non-zeros in it, then float does not have the precision we want
|
||||
return f;
|
||||
|
@ -555,7 +555,7 @@ public static Number createNumber(final String str) throws NumberFormatException
|
|||
case 'D' :
|
||||
try {
|
||||
final Double d = NumberUtils.createDouble(str);
|
||||
if (!(d.isInfinite() || (d.floatValue() == 0.0D && !allZeros))) {
|
||||
if (!(d.isInfinite() || d.floatValue() == 0.0D && !allZeros)) {
|
||||
return d;
|
||||
}
|
||||
} catch (final NumberFormatException nfe) { // NOPMD
|
||||
|
@ -640,7 +640,7 @@ private static String getMantissa(final String str) {
|
|||
*/
|
||||
private static String getMantissa(final String str, final int stopPos) {
|
||||
final char firstChar = str.charAt(0);
|
||||
final boolean hasSign = (firstChar == '-' || firstChar == '+');
|
||||
final boolean hasSign = firstChar == '-' || firstChar == '+';
|
||||
|
||||
return hasSign ? str.substring(1, stopPos) : str.substring(0, stopPos);
|
||||
}
|
||||
|
@ -1409,13 +1409,10 @@ public static boolean isCreatable(final String str) {
|
|||
boolean allowSigns = false;
|
||||
boolean foundDigit = false;
|
||||
// deal with any possible sign up front
|
||||
final int start = (chars[0] == '-' || chars[0] == '+') ? 1 : 0;
|
||||
final boolean hasLeadingPlusSign = (start == 1 && chars[0] == '+');
|
||||
final int start = chars[0] == '-' || chars[0] == '+' ? 1 : 0;
|
||||
final boolean hasLeadingPlusSign = start == 1 && chars[0] == '+';
|
||||
if (sz > start + 1 && chars[start] == '0') { // leading 0
|
||||
if (
|
||||
(chars[start + 1] == 'x') ||
|
||||
(chars[start + 1] == 'X')
|
||||
) { // leading 0x/0X
|
||||
if (chars[start + 1] == 'x' || chars[start + 1] == 'X') { // leading 0x/0X
|
||||
int i = start + 2;
|
||||
if (i == sz) {
|
||||
return false; // str == "0x"
|
||||
|
@ -1445,7 +1442,7 @@ public static boolean isCreatable(final String str) {
|
|||
int i = start;
|
||||
// loop to the next to last char or to the last char if we need another digit to
|
||||
// make a valid number (e.g. chars[0..5] = "1234E")
|
||||
while (i < sz || (i < sz + 1 && allowSigns && !foundDigit)) {
|
||||
while (i < sz || i < sz + 1 && allowSigns && !foundDigit) {
|
||||
if (chars[i] >= '0' && chars[i] <= '9') {
|
||||
foundDigit = true;
|
||||
allowSigns = false;
|
||||
|
|
|
@ -163,7 +163,7 @@ private static float getTotalTransformationCost(final Class<?>[] srcArgs, final
|
|||
// When isVarArgs is true, srcArgs and dstArgs may differ in length.
|
||||
// There are two special cases to consider:
|
||||
final boolean noVarArgsPassed = srcArgs.length < destArgs.length;
|
||||
final boolean explicitArrayForVarags = (srcArgs.length == destArgs.length) && srcArgs[srcArgs.length-1].isArray();
|
||||
final boolean explicitArrayForVarags = srcArgs.length == destArgs.length && srcArgs[srcArgs.length-1].isArray();
|
||||
|
||||
final float varArgsCost = 0.001f;
|
||||
Class<?> destClass = destArgs[destArgs.length-1].getComponentType();
|
||||
|
|
Loading…
Reference in New Issue