flips the order of conditional expressions and 'if' statements whose conditions were negated

This commit is contained in:
Igor Curdvanovschi 2018-06-20 14:45:54 +03:00
parent b610707cd0
commit 77febcfa8d
9 changed files with 27 additions and 29 deletions

View File

@ -86,12 +86,10 @@ public class ArchUtils {
* @throws IllegalStateException If the key already exists.
*/
private static void addProcessor(final String key, final Processor processor) {
if (!ARCH_TO_PROCESSOR.containsKey(key)) {
ARCH_TO_PROCESSOR.put(key, processor);
} else {
final String msg = "Key " + key + " already exists in processor map";
throw new IllegalStateException(msg);
if (ARCH_TO_PROCESSOR.containsKey(key)) {
throw new IllegalStateException("Key " + key + " already exists in processor map");
}
ARCH_TO_PROCESSOR.put(key, processor);
}
/**

View File

@ -84,7 +84,7 @@ public class BitField {
*/
public BitField(final int mask) {
_mask = mask;
_shift_count = mask != 0 ? Integer.numberOfTrailingZeros(mask) : 0;
_shift_count = mask == 0 ? 0 : Integer.numberOfTrailingZeros(mask);
}
/**

View File

@ -689,14 +689,14 @@ public class ObjectUtils {
final Object result;
if (obj.getClass().isArray()) {
final Class<?> componentType = obj.getClass().getComponentType();
if (!componentType.isPrimitive()) {
result = ((Object[]) obj).clone();
} else {
if (componentType.isPrimitive()) {
int length = Array.getLength(obj);
result = Array.newInstance(componentType, length);
while (length-- > 0) {
Array.set(result, length, Array.get(obj, length));
}
} else {
result = ((Object[]) obj).clone();
}
} else {
try {

View File

@ -8857,15 +8857,15 @@ public class StringUtils {
for (int i = 0; i < size; i++) {
final char actualChar = str.charAt(i);
final boolean isWhitespace = Character.isWhitespace(actualChar);
if (!isWhitespace) {
startWhitespaces = false;
newChars[count++] = (actualChar == 160 ? 32 : actualChar);
whitespacesCount = 0;
} else {
if (isWhitespace) {
if (whitespacesCount == 0 && !startWhitespaces) {
newChars[count++] = SPACE.charAt(0);
}
whitespacesCount++;
} else {
startWhitespaces = false;
newChars[count++] = (actualChar == 160 ? 32 : actualChar);
whitespacesCount = 0;
}
}
if (startWhitespaces) {

View File

@ -600,10 +600,10 @@ public class CompareToBuilder implements Builder<Integer> {
if (lhs == rhs) {
return this;
}
if (!lhs) {
comparison = -1;
} else {
if (lhs) {
comparison = +1;
} else {
comparison = -1;
}
return this;
}

View File

@ -637,17 +637,17 @@ public class EqualsBuilder implements Builder<Boolean> {
return this;
}
final Class<?> lhsClass = lhs.getClass();
if (!lhsClass.isArray()) {
if (lhsClass.isArray()) {
// 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
if (testRecursive && !ClassUtils.isPrimitiveOrWrapper(lhsClass)) {
reflectionAppend(lhs, rhs);
} else {
isEquals = lhs.equals(rhs);
}
} else {
// factor out array case in order to keep method small enough
// to be inlined
appendArray(lhs, rhs);
}
return this;
}

View File

@ -469,8 +469,8 @@ public class EventCountCircuitBreaker extends AbstractCircuitBreaker<Integer> {
* @return the updated instance
*/
public CheckIntervalData increment(final int delta) {
return (delta != 0) ? new CheckIntervalData(getEventCount() + delta,
getCheckIntervalStart()) : this;
return (delta == 0) ? this : new CheckIntervalData(getEventCount() + delta,
getCheckIntervalStart());
}
}

View File

@ -958,7 +958,7 @@ public class FastDateParser implements DateParser, Serializable {
private static final Strategy DAY_OF_WEEK_STRATEGY = new NumberStrategy(Calendar.DAY_OF_WEEK) {
@Override
int modify(final FastDateParser parser, final int iValue) {
return iValue != 7 ? iValue + 1 : Calendar.SUNDAY;
return iValue == 7 ? Calendar.SUNDAY : iValue + 1;
}
};

View File

@ -1266,7 +1266,7 @@ public class FastDatePrinter implements DatePrinter, Serializable {
@Override
public void appendTo(final Appendable buffer, final Calendar calendar) throws IOException {
final int value = calendar.get(Calendar.DAY_OF_WEEK);
mRule.appendTo(buffer, value != Calendar.SUNDAY ? value - 1 : 7);
mRule.appendTo(buffer, value == Calendar.SUNDAY ? 7 : value - 1);
}
@Override
@ -1369,10 +1369,10 @@ public class FastDatePrinter implements DatePrinter, Serializable {
@Override
public void appendTo(final Appendable buffer, final Calendar calendar) throws IOException {
final TimeZone zone = calendar.getTimeZone();
if (calendar.get(Calendar.DST_OFFSET) != 0) {
buffer.append(getTimeZoneDisplay(zone, true, mStyle, mLocale));
} else {
if (calendar.get(Calendar.DST_OFFSET) == 0) {
buffer.append(getTimeZoneDisplay(zone, false, mStyle, mLocale));
} else {
buffer.append(getTimeZoneDisplay(zone, true, mStyle, mLocale));
}
}
}