From 03349e8c6697d668e675e628783b52eef39b877b Mon Sep 17 00:00:00 2001 From: Ahmed Ashour Date: Wed, 13 Sep 2017 12:35:24 +0200 Subject: Simplify boolean expressions --- client/src/main/java/com/vaadin/client/DateTimeService.java | 2 +- client/src/main/java/com/vaadin/client/VTooltip.java | 2 +- client/src/main/java/com/vaadin/client/ui/dd/VOr.java | 2 +- client/src/main/java/com/vaadin/client/widgets/Grid.java | 4 ++-- .../src/main/java/com/vaadin/v7/client/widgets/Grid.java | 4 ++-- .../src/main/java/com/vaadin/v7/data/util/MethodProperty.java | 10 +++++----- .../src/main/java/com/vaadin/v7/ui/NativeSelect.java | 4 ++-- server/src/main/java/com/vaadin/server/JsonPaintTarget.java | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/client/src/main/java/com/vaadin/client/DateTimeService.java b/client/src/main/java/com/vaadin/client/DateTimeService.java index ec7c18e94d..88cc0923e6 100644 --- a/client/src/main/java/com/vaadin/client/DateTimeService.java +++ b/client/src/main/java/com/vaadin/client/DateTimeService.java @@ -177,7 +177,7 @@ public class DateTimeService { public static int getNumberOfDaysInMonth(Date date) { final int month = date.getMonth(); - if (month == 1 && true == isLeapYear(date)) { + if (month == 1 && isLeapYear(date)) { return 29; } return maxDaysInMonth[month]; diff --git a/client/src/main/java/com/vaadin/client/VTooltip.java b/client/src/main/java/com/vaadin/client/VTooltip.java index 7cbd951114..0804e67666 100644 --- a/client/src/main/java/com/vaadin/client/VTooltip.java +++ b/client/src/main/java/com/vaadin/client/VTooltip.java @@ -617,7 +617,7 @@ public class VTooltip extends VOverlay { Element element = Element.as(event.getEventTarget()); // We can ignore move event if it's handled by move or over already - if (currentElement == element && handledByFocus == true) { + if (currentElement == element && handledByFocus) { return; } diff --git a/client/src/main/java/com/vaadin/client/ui/dd/VOr.java b/client/src/main/java/com/vaadin/client/ui/dd/VOr.java index 2856f692dc..43a9db0524 100644 --- a/client/src/main/java/com/vaadin/client/ui/dd/VOr.java +++ b/client/src/main/java/com/vaadin/client/ui/dd/VOr.java @@ -39,7 +39,7 @@ public final class VOr extends VAcceptCriterion implements VAcceptCallback { for (int i = 0; i < childCount; i++) { VAcceptCriterion crit = VAnd.getCriteria(drag, configuration, i); crit.accept(drag, configuration.getChildUIDL(i), this); - if (accepted == true) { + if (accepted) { callback.accepted(drag); return; } diff --git a/client/src/main/java/com/vaadin/client/widgets/Grid.java b/client/src/main/java/com/vaadin/client/widgets/Grid.java index dd9353155e..92765eec89 100755 --- a/client/src/main/java/com/vaadin/client/widgets/Grid.java +++ b/client/src/main/java/com/vaadin/client/widgets/Grid.java @@ -1753,10 +1753,10 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, * if the editor handler is not set */ public void setEnabled(boolean enabled) { - if (enabled == false && state != State.INACTIVE) { + if (!enabled && state != State.INACTIVE) { throw new IllegalStateException( "Cannot disable: editor is in edit mode"); - } else if (enabled == true && getHandler() == null) { + } else if (enabled && getHandler() == null) { throw new IllegalStateException( "Cannot enable: EditorHandler not set"); } diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java index 73898de0b1..a59e61d9dc 100644 --- a/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java +++ b/compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java @@ -1750,10 +1750,10 @@ public class Grid extends ResizeComposite implements HasSelectionHandlers, * if the editor handler is not set */ public void setEnabled(boolean enabled) { - if (enabled == false && state != State.INACTIVE) { + if (!enabled && state != State.INACTIVE) { throw new IllegalStateException( "Cannot disable: editor is in edit mode"); - } else if (enabled == true && getHandler() == null) { + } else if (enabled && getHandler() == null) { throw new IllegalStateException( "Cannot enable: EditorHandler not set"); } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/MethodProperty.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/MethodProperty.java index 9d225c831a..0e564087bf 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/MethodProperty.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/MethodProperty.java @@ -386,8 +386,8 @@ public class MethodProperty extends AbstractProperty { } if (j == c.length) { - // all paramteters matched - if (found == true) { + // all parameters matched + if (found) { throw new MethodException(this, "Could not uniquely identify " + getMethodName + "-method"); @@ -397,7 +397,7 @@ public class MethodProperty extends AbstractProperty { } } } - if (found != true) { + if (!found) { throw new MethodException(this, "Could not find " + getMethodName + "-method"); } @@ -440,7 +440,7 @@ public class MethodProperty extends AbstractProperty { if (j == c.length) { // all parameters match - if (found == true) { + if (found) { throw new MethodException(this, "Could not identify unique " + setMethodName + "-method"); @@ -450,7 +450,7 @@ public class MethodProperty extends AbstractProperty { } } } - if (found != true) { + if (!found) { throw new MethodException(this, "Could not identify " + setMethodName + "-method"); } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/NativeSelect.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/NativeSelect.java index e69f7c620b..4696e6c707 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/NativeSelect.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/NativeSelect.java @@ -119,7 +119,7 @@ public class NativeSelect extends AbstractSelect @Override public void setMultiSelect(boolean multiSelect) throws UnsupportedOperationException { - if (multiSelect == true) { + if (multiSelect) { throw new UnsupportedOperationException( "Multiselect not supported"); } @@ -128,7 +128,7 @@ public class NativeSelect extends AbstractSelect @Override public void setNewItemsAllowed(boolean allowNewOptions) throws UnsupportedOperationException { - if (allowNewOptions == true) { + if (allowNewOptions) { throw new UnsupportedOperationException( "newItemsAllowed not supported"); } diff --git a/server/src/main/java/com/vaadin/server/JsonPaintTarget.java b/server/src/main/java/com/vaadin/server/JsonPaintTarget.java index 905dc03246..f7669ef135 100644 --- a/server/src/main/java/com/vaadin/server/JsonPaintTarget.java +++ b/server/src/main/java/com/vaadin/server/JsonPaintTarget.java @@ -876,7 +876,7 @@ public class JsonPaintTarget implements PaintTarget { @Override public String getJsonPresentation() { - return "\"" + name + "\":" + (value == true ? "true" : "false"); + return "\"" + name + "\":" + (value ? "true" : "false"); } } -- cgit v1.2.3