diff options
author | Ahmed Ashour <asashour@yahoo.com> | 2017-10-12 08:00:02 +0200 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-10-12 09:00:02 +0300 |
commit | 13d406a7086cc1546eac3fa86f6263bfb436de85 (patch) | |
tree | c571de7cc72bdcad1d8473266dbcdd76a2b0487b | |
parent | d0b5741b81d214491c93d4d042c79e10bb4f192e (diff) | |
download | vaadin-framework-13d406a7086cc1546eac3fa86f6263bfb436de85.tar.gz vaadin-framework-13d406a7086cc1546eac3fa86f6263bfb436de85.zip |
Remove redundant null checks before an instanceof (#10173)
11 files changed, 14 insertions, 18 deletions
diff --git a/client/src/main/java/com/vaadin/client/Util.java b/client/src/main/java/com/vaadin/client/Util.java index a27e92bd82..517727e75e 100644 --- a/client/src/main/java/com/vaadin/client/Util.java +++ b/client/src/main/java/com/vaadin/client/Util.java @@ -1249,8 +1249,7 @@ public class Util { private static HasChildMeasurementHintConnector getPossibleChildMeasurementHintParentConnector( ComponentConnector candidate) { ServerConnector parent = candidate.getParent(); - if (parent != null - && parent instanceof HasChildMeasurementHintConnector) { + if (parent instanceof HasChildMeasurementHintConnector) { return (HasChildMeasurementHintConnector) parent; } return null; diff --git a/client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java b/client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java index 3d8aa14862..383d67ce70 100644 --- a/client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java +++ b/client/src/main/java/com/vaadin/client/ui/VAbstractCalendarPanel.java @@ -247,8 +247,7 @@ public abstract class VAbstractCalendarPanel<R extends Enum<R>> int cellCount = days.getCellCount(i); for (int j = 0; j < cellCount; j++) { Widget widget = days.getWidget(i, j); - if (widget != null - && widget instanceof VAbstractCalendarPanel.Day) { + if (widget instanceof VAbstractCalendarPanel.Day) { Day curday = (Day) widget; if (curday.getDate().equals(date)) { curday.addStyleDependentName(CN_FOCUSED); @@ -358,8 +357,7 @@ public abstract class VAbstractCalendarPanel<R extends Enum<R>> int cellCount = days.getCellCount(i); for (int j = 0; j < cellCount; j++) { Widget widget = days.getWidget(i, j); - if (widget != null - && widget instanceof VAbstractCalendarPanel.Day) { + if (widget instanceof VAbstractCalendarPanel.Day) { Day curday = (Day) widget; if (curday.getDate().equals(date)) { curday.addStyleDependentName(CN_SELECTED); diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/FilesystemContainer.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/FilesystemContainer.java index 4ae90a7569..edb46ae4e5 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/FilesystemContainer.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/FilesystemContainer.java @@ -676,7 +676,7 @@ public class FilesystemContainer implements Container.Hierarchical { */ @Override public boolean equals(Object obj) { - if (obj == null || !(obj instanceof FileItem)) { + if (!(obj instanceof FileItem)) { return false; } final FileItem fi = (FileItem) obj; diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/PropertysetItem.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/PropertysetItem.java index d7be9c54e8..a486ec2443 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/PropertysetItem.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/PropertysetItem.java @@ -325,7 +325,7 @@ public class PropertysetItem @Override public boolean equals(Object obj) { - if (obj == null || !(obj instanceof PropertysetItem)) { + if (!(obj instanceof PropertysetItem)) { return false; } diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/RowItem.java b/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/RowItem.java index 78ef1f8d58..425a5c1f60 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/RowItem.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/RowItem.java @@ -65,7 +65,7 @@ public final class RowItem implements Item { @Override public Property getItemProperty(Object id) { - if (id instanceof String && id != null) { + if (id instanceof String) { for (ColumnProperty cp : properties) { if (id.equals(cp.getPropertyId())) { return cp; diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/validator/DoubleValidator.java b/compatibility-server/src/main/java/com/vaadin/v7/data/validator/DoubleValidator.java index ef8dde86f4..c549c18738 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/validator/DoubleValidator.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/validator/DoubleValidator.java @@ -59,7 +59,7 @@ public class DoubleValidator extends AbstractStringValidator { @Override public void validate(Object value) throws InvalidValueException { - if (value != null && value instanceof Double) { + if (value instanceof Double) { // Allow Doubles to pass through the validator for easier // migration. Otherwise a TextField connected to an double property // with a DoubleValidator will fail. diff --git a/compatibility-server/src/main/java/com/vaadin/v7/data/validator/IntegerValidator.java b/compatibility-server/src/main/java/com/vaadin/v7/data/validator/IntegerValidator.java index a65c7884f2..f5a004215e 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/data/validator/IntegerValidator.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/data/validator/IntegerValidator.java @@ -60,7 +60,7 @@ public class IntegerValidator extends AbstractStringValidator { @Override public void validate(Object value) throws InvalidValueException { - if (value != null && value instanceof Integer) { + if (value instanceof Integer) { // Allow Integers to pass through the validator for easier // migration. Otherwise a TextField connected to an integer property // with an IntegerValidator will fail. diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractSelect.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractSelect.java index f23326e4f3..45b16f0381 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractSelect.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractSelect.java @@ -1939,8 +1939,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements if (pids != null) { for (Object id : pids) { Property<?> p = i.getItemProperty(id); - if (p != null - && p instanceof Property.ValueChangeNotifier) { + if (p instanceof Property.ValueChangeNotifier) { ((Property.ValueChangeNotifier) p) .addValueChangeListener( getCaptionChangeListener()); @@ -1953,7 +1952,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements case PROPERTY: final Property<?> p = getContainerProperty(itemId, getItemCaptionPropertyId()); - if (p != null && p instanceof Property.ValueChangeNotifier) { + if (p instanceof Property.ValueChangeNotifier) { ((Property.ValueChangeNotifier) p) .addValueChangeListener(getCaptionChangeListener()); captionChangeNotifiers.add(p); @@ -1964,7 +1963,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements if (getItemIconPropertyId() != null) { final Property p = getContainerProperty(itemId, getItemIconPropertyId()); - if (p != null && p instanceof Property.ValueChangeNotifier) { + if (p instanceof Property.ValueChangeNotifier) { ((Property.ValueChangeNotifier) p) .addValueChangeListener(getCaptionChangeListener()); captionChangeNotifiers.add(p); diff --git a/server/src/main/java/com/vaadin/server/DragAndDropService.java b/server/src/main/java/com/vaadin/server/DragAndDropService.java index 64926c531c..7b56153467 100644 --- a/server/src/main/java/com/vaadin/server/DragAndDropService.java +++ b/server/src/main/java/com/vaadin/server/DragAndDropService.java @@ -215,7 +215,7 @@ public class DragAndDropService implements VariableOwner, ClientConnector { variables = (Map<String, Object>) variables.get("tra"); Transferable transferable = null; - if (sourceComponent != null && sourceComponent instanceof DragSource) { + if (sourceComponent instanceof DragSource) { transferable = ((DragSource) sourceComponent) .getTransferable(variables); } diff --git a/server/src/main/java/com/vaadin/server/communication/PushRequestHandler.java b/server/src/main/java/com/vaadin/server/communication/PushRequestHandler.java index ce3b399973..9e15d5c0fe 100644 --- a/server/src/main/java/com/vaadin/server/communication/PushRequestHandler.java +++ b/server/src/main/java/com/vaadin/server/communication/PushRequestHandler.java @@ -141,7 +141,7 @@ public class PushRequestHandler .getAttributeName(vaadinServletConfig.getServletName()); Object framework = vaadinServletConfig.getServletContext() .getAttribute(attributeName); - if (framework != null && framework instanceof AtmosphereFramework) { + if (framework instanceof AtmosphereFramework) { return (AtmosphereFramework) framework; } diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java index 993a6d3411..2b4723eaaa 100644 --- a/server/src/main/java/com/vaadin/ui/Grid.java +++ b/server/src/main/java/com/vaadin/ui/Grid.java @@ -1966,7 +1966,7 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents, // Remove old renderer Connector oldRenderer = getState().renderer; - if (oldRenderer != null && oldRenderer instanceof Extension) { + if (oldRenderer instanceof Extension) { removeExtension((Extension) oldRenderer); } |