Ticket #8902: instanceofnullcheck.diff

File instanceofnullcheck.diff, 9.0 KB (added by shinigami, 11 years ago)

removed useles null checks before instanceof

  • src/org/openstreetmap/josm/data/osm/Node.java

     
    266266
    267267    @Override
    268268    public boolean hasEqualSemanticAttributes(OsmPrimitive other) {
    269         if (other == null || ! (other instanceof Node) )
     269        if (!(other instanceof Node))
    270270            return false;
    271271        if (! super.hasEqualSemanticAttributes(other))
    272272            return false;
  • src/org/openstreetmap/josm/data/osm/Relation.java

     
    280280
    281281    @Override
    282282    public boolean hasEqualSemanticAttributes(OsmPrimitive other) {
    283         if (other == null || ! (other instanceof Relation) )
     283        if (!(other instanceof Relation))
    284284            return false;
    285285        if (! super.hasEqualSemanticAttributes(other))
    286286            return false;
  • src/org/openstreetmap/josm/data/osm/Way.java

     
    326326
    327327    @Override
    328328    public boolean hasEqualSemanticAttributes(OsmPrimitive other) {
    329         if (other == null || ! (other instanceof Way) )
     329        if (!(other instanceof Way))
    330330            return false;
    331331        if (! super.hasEqualSemanticAttributes(other))
    332332            return false;
  • src/org/openstreetmap/josm/gui/MapMover.java

     
    223223     * @return true if we are currently running on OSX
    224224     */
    225225    public static boolean isPlatformOsx() {
    226         return Main.platform != null && Main.platform instanceof PlatformHookOsx;
     226        return Main.platform instanceof PlatformHookOsx;
    227227    }
    228228
    229229    @Override
  • src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java

     
    227227     * @param layer the layer. May be null.
    228228     */
    229229    protected void initFromLayer(Layer layer) {
    230         if (layer == null || ! (layer instanceof OsmDataLayer)) {
     230        if (!(layer instanceof OsmDataLayer)) {
    231231            model.setRelations(null);
    232232            return;
    233233        }
     
    676676    @Override
    677677    public void tagsChanged(TagsChangedEvent event) {
    678678        OsmPrimitive prim = event.getPrimitive();
    679         if (prim == null || ! (prim instanceof Relation))
     679        if (!(prim instanceof Relation))
    680680            return;
    681681        // trigger a sort of the relation list because the display name may
    682682        // have changed
  • src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java

     
    184184     */
    185185    @Override
    186186    public void layerRemoved(Layer oldLayer) {
    187         if (oldLayer == null || ! (oldLayer instanceof OsmDataLayer))
     187        if (!(oldLayer instanceof OsmDataLayer))
    188188            return;
    189189        OsmDataLayer dataLayer = (OsmDataLayer)oldLayer;
    190190
  • src/org/openstreetmap/josm/gui/help/HelpBrowser.java

     
    580580        protected String getUrlFragment(HyperlinkEvent e) {
    581581            AttributeSet set = e.getSourceElement().getAttributes();
    582582            Object value = set.getAttribute(Tag.A);
    583             if (value == null || ! (value instanceof SimpleAttributeSet)) return null;
     583            if (!(value instanceof SimpleAttributeSet)) return null;
    584584            SimpleAttributeSet atts = (SimpleAttributeSet)value;
    585585            value = atts.getAttribute(javax.swing.text.html.HTML.Attribute.HREF);
    586586            if (value == null) return null;
  • src/org/openstreetmap/josm/gui/history/CoordinateInfoViewer.java

     
    251251        protected void refresh() {
    252252            HistoryOsmPrimitive p = getPrimitive();
    253253            HistoryOsmPrimitive  opposite = getOppositePrimitive();
    254             if (p == null || ! ( p instanceof HistoryNode)) return;
    255             if (opposite == null || ! (opposite instanceof HistoryNode)) return;
     254            if (!(p instanceof HistoryNode)) return;
     255            if (!(opposite instanceof HistoryNode)) return;
    256256            HistoryNode node = (HistoryNode)p;
    257257            HistoryNode oppositeNode = (HistoryNode) opposite;
    258258
     
    324324        protected void refresh() {
    325325            HistoryOsmPrimitive p = getPrimitive();
    326326            HistoryOsmPrimitive opposite = getOppositePrimitive();
    327             if (p == null || ! ( p instanceof HistoryNode)) return;
    328             if (opposite == null || ! (opposite instanceof HistoryNode)) return;
     327            if (!(p instanceof HistoryNode)) return;
     328            if (!(opposite instanceof HistoryNode)) return;
    329329            HistoryNode node = (HistoryNode) p;
    330330            HistoryNode oppositeNode = (HistoryNode) opposite;
    331331
  • src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java

     
    754754    /* ---------------------------------------------------------------------- */
    755755    @Override
    756756    public void activeLayerChange(Layer oldLayer, Layer newLayer) {
    757         if (oldLayer != null && oldLayer instanceof OsmDataLayer) {
     757        if (oldLayer instanceof OsmDataLayer) {
    758758            OsmDataLayer l = (OsmDataLayer)oldLayer;
    759759            l.data.removeDataSetListener(this);
    760760        }
    761         if (newLayer == null || ! (newLayer instanceof OsmDataLayer)) {
     761        if (!(newLayer instanceof OsmDataLayer)) {
    762762            latest = null;
    763763            fireModelChange();
    764764            return;
  • src/org/openstreetmap/josm/gui/mappaint/BoxTextElemStyle.java

     
    6868
    6969        @Override
    7070        public boolean equals(Object obj) {
    71             if (obj == null || !(obj instanceof BoxProvider))
     71            if (!(obj instanceof BoxProvider))
    7272                return false;
    7373            final BoxProvider other = (BoxProvider) obj;
    7474            BoxProviderResult resultOther = other.get();
  • src/org/openstreetmap/josm/gui/mappaint/Environment.java

     
    106106    }
    107107
    108108    public boolean hasParentRelation() {
    109         return parent != null && parent instanceof Relation;
     109        return parent instanceof Relation;
    110110    }
    111111
    112112    /**
     
    122122        if (getContext().equals(Context.PRIMITIVE))
    123123            return null;
    124124
    125         if (parent != null && parent instanceof Relation)
     125        if (parent instanceof Relation)
    126126            return ((Relation) parent).getMember(index).getRole();
    127127        if (child != null && osm instanceof Relation)
    128128            return ((Relation) osm).getMember(index).getRole();
  • src/org/openstreetmap/josm/gui/mappaint/MapImage.java

     
    129129
    130130        @Override
    131131        public boolean equals(Object obj) {
    132             if (obj == null || !(obj instanceof BoxProvider))
     132            if (!(obj instanceof BoxProvider))
    133133                return false;
    134134            if (obj instanceof MapImageBoxProvider) {
    135135                MapImageBoxProvider other = (MapImageBoxProvider) obj;