Combine nested 'if' statement in 'else' block to 'else if'.
This commit is contained in:
parent
7e5be1cf84
commit
91928eed34
|
@ -1458,11 +1458,9 @@ public class ClassUtils {
|
|||
className.endsWith(";")
|
||||
? className.length() - 1
|
||||
: className.length());
|
||||
} else {
|
||||
if (!className.isEmpty()) {
|
||||
} else if (!className.isEmpty()) {
|
||||
className = reverseAbbreviationMap.get(className.substring(0, 1));
|
||||
}
|
||||
}
|
||||
final StringBuilder canonicalClassNameBuffer = new StringBuilder(className);
|
||||
for (int i = 0; i < dim; i++) {
|
||||
canonicalClassNameBuffer.append("[]");
|
||||
|
|
|
@ -372,19 +372,15 @@ public class RandomStringUtils {
|
|||
if (start == 0 && end == 0) {
|
||||
if (chars != null) {
|
||||
end = chars.length;
|
||||
} else {
|
||||
if (!letters && !numbers) {
|
||||
} else if (!letters && !numbers) {
|
||||
end = Character.MAX_CODE_POINT;
|
||||
} else {
|
||||
end = 'z' + 1;
|
||||
start = ' ';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (end <= start) {
|
||||
} else if (end <= start) {
|
||||
throw new IllegalArgumentException("Parameter end (" + end + ") must be greater than start (" + start + ")");
|
||||
}
|
||||
}
|
||||
|
||||
final int zero_digit_ascii = 48;
|
||||
final int first_letter_ascii = 65;
|
||||
|
|
|
@ -2946,12 +2946,10 @@ public class StringUtils {
|
|||
if (chFound && CharSequenceUtils.indexOf(searchChars, ch2, 0) < 0) {
|
||||
return i;
|
||||
}
|
||||
} else {
|
||||
if (!chFound) {
|
||||
} else if (!chFound) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return INDEX_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
@ -6747,13 +6745,11 @@ public class StringUtils {
|
|||
// see if we need to keep searching for this
|
||||
if (tempIndex == -1) {
|
||||
noMoreMatchesForReplIndex[i] = true;
|
||||
} else {
|
||||
if (textIndex == -1 || tempIndex < textIndex) {
|
||||
} else if (textIndex == -1 || tempIndex < textIndex) {
|
||||
textIndex = tempIndex;
|
||||
replaceIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
// NOTE: logic mostly below END
|
||||
|
||||
// no search strings found, we are done
|
||||
|
@ -6804,13 +6800,11 @@ public class StringUtils {
|
|||
// see if we need to keep searching for this
|
||||
if (tempIndex == -1) {
|
||||
noMoreMatchesForReplIndex[i] = true;
|
||||
} else {
|
||||
if (textIndex == -1 || tempIndex < textIndex) {
|
||||
} else if (textIndex == -1 || tempIndex < textIndex) {
|
||||
textIndex = tempIndex;
|
||||
replaceIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
// NOTE: logic duplicated above END
|
||||
|
||||
}
|
||||
|
|
|
@ -420,8 +420,7 @@ public class CompareToBuilder implements Builder<Integer> {
|
|||
if (lhs.getClass().isArray()) {
|
||||
// factor out array case in order to keep method small enough to be inlined
|
||||
appendArray(lhs, rhs, comparator);
|
||||
} else {
|
||||
// the simple case, not an array, just test the element
|
||||
} else // the simple case, not an array, just test the element
|
||||
if (comparator == null) {
|
||||
@SuppressWarnings("unchecked") // assume this can be done; if not throw CCE as per Javadoc
|
||||
final Comparable<Object> comparable = (Comparable<Object>) lhs;
|
||||
|
@ -431,7 +430,6 @@ public class CompareToBuilder implements Builder<Integer> {
|
|||
final Comparator<Object> comparator2 = (Comparator<Object>) comparator;
|
||||
comparison = comparator2.compare(lhs, rhs);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -532,8 +532,7 @@ public class EqualsBuilder implements Builder<Boolean> {
|
|||
try {
|
||||
if (testClass.isArray()) {
|
||||
append(lhs, rhs);
|
||||
} else {
|
||||
//If either class is being excluded, call normal object equals method on lhsClass.
|
||||
} else //If either class is being excluded, call normal object equals method on lhsClass.
|
||||
if (bypassReflectionClasses != null
|
||||
&& (bypassReflectionClasses.contains(lhsClass) || bypassReflectionClasses.contains(rhsClass))) {
|
||||
isEquals = lhs.equals(rhs);
|
||||
|
@ -544,7 +543,6 @@ public class EqualsBuilder implements Builder<Boolean> {
|
|||
reflectionAppend(lhs, rhs, testClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final IllegalArgumentException e) {
|
||||
// In this case, we tried to test a subclass vs. a superclass and
|
||||
// the subclass has ivars or the ivars are transient and
|
||||
|
@ -644,14 +642,12 @@ public class EqualsBuilder implements Builder<Boolean> {
|
|||
// factor out array case in order to keep method small enough
|
||||
// to be inlined
|
||||
appendArray(lhs, rhs);
|
||||
} else {
|
||||
// The simple case, not an array, just test the element
|
||||
} else // The simple case, not an array, just test the element
|
||||
if (testRecursive && !ClassUtils.isPrimitiveOrWrapper(lhsClass)) {
|
||||
reflectionAppend(lhs, rhs);
|
||||
} else {
|
||||
isEquals = lhs.equals(rhs);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -842,15 +842,13 @@ public class HashCodeBuilder implements Builder<Integer> {
|
|||
if (object == null) {
|
||||
iTotal = iTotal * iConstant;
|
||||
|
||||
} else {
|
||||
if (object.getClass().isArray()) {
|
||||
} else if (object.getClass().isArray()) {
|
||||
// factor out array case in order to keep method small enough
|
||||
// to be inlined
|
||||
appendArray(object);
|
||||
} else {
|
||||
iTotal = iTotal * iConstant + object.hashCode();
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -575,13 +575,11 @@ public abstract class ToStringStyle implements Serializable {
|
|||
appendSummary(buffer, fieldName, (Object[]) value);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (detail) {
|
||||
} else if (detail) {
|
||||
appendDetail(buffer, fieldName, value);
|
||||
} else {
|
||||
appendSummary(buffer, fieldName, value);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
unregister(value);
|
||||
}
|
||||
|
|
|
@ -773,8 +773,7 @@ public class StrSubstitutor {
|
|||
bufEnd);
|
||||
if (startMatchLen == 0) {
|
||||
pos++;
|
||||
} else {
|
||||
// found variable start marker
|
||||
} else // found variable start marker
|
||||
if (pos > offset && chars[pos - 1] == escape) {
|
||||
// escaped
|
||||
if (preserveEscapes) {
|
||||
|
@ -884,7 +883,6 @@ public class StrSubstitutor {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (top) {
|
||||
return altered ? 1 : 0;
|
||||
}
|
||||
|
|
|
@ -315,8 +315,7 @@ public class WordUtils {
|
|||
wrappedLine.append(newLineStr);
|
||||
offset = spaceToWrapAt + 1;
|
||||
|
||||
} else {
|
||||
// really long word or URL
|
||||
} else // really long word or URL
|
||||
if (wrapLongWords) {
|
||||
// wrap really long word one line at a time
|
||||
wrappedLine.append(str, offset, wrapLength + offset);
|
||||
|
@ -339,7 +338,6 @@ public class WordUtils {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Whatever is left in line is short enough to just pass through
|
||||
wrappedLine.append(str, offset, str.length());
|
||||
|
|
|
@ -108,11 +108,9 @@ public class NumericEntityEscaper extends CodePointTranslator {
|
|||
if (codepoint < below || codepoint > above) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (codepoint >= below && codepoint <= above) {
|
||||
} else if (codepoint >= below && codepoint <= above) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
out.write("&#");
|
||||
out.write(Integer.toString(codepoint, 10));
|
||||
|
|
|
@ -108,11 +108,9 @@ public class UnicodeEscaper extends CodePointTranslator {
|
|||
if (codepoint < below || codepoint > above) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (codepoint >= below && codepoint <= above) {
|
||||
} else if (codepoint >= below && codepoint <= above) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Handle potential + sign per various Unicode escape implementations
|
||||
if (codepoint > 0xffff) {
|
||||
|
|
|
@ -431,8 +431,7 @@ public class DurationFormatUtils {
|
|||
final int count = token.getCount();
|
||||
if (value instanceof StringBuilder) {
|
||||
buffer.append(value.toString());
|
||||
} else {
|
||||
if (value.equals(y)) {
|
||||
} else if (value.equals(y)) {
|
||||
buffer.append(paddedValue(years, padWithZeros, count));
|
||||
lastOutputSeconds = false;
|
||||
} else if (value.equals(M)) {
|
||||
|
@ -461,7 +460,6 @@ public class DurationFormatUtils {
|
|||
lastOutputSeconds = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue