Ignore:
Timestamp:
2017-04-01T01:23:56+02:00 (3 years ago)
Author:
Don-vip
Message:

findbugs - BC_UNCONFIRMED_CAST

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/template_engine/ContextSwitchTemplate.java

    r10659 r11809  
    2323public class ContextSwitchTemplate implements TemplateEntry {
    2424
    25     private static final TemplateEngineDataProvider EMTPY_PROVIDER = new TemplateEngineDataProvider() {
     25    private static final TemplateEngineDataProvider EMPTY_PROVIDER = new TemplateEngineDataProvider() {
    2626        @Override
    2727        public Object getTemplateValue(String name, boolean special) {
     
    258258    @Override
    259259    public void appendText(StringBuilder result, TemplateEngineDataProvider dataProvider) {
    260         List<OsmPrimitive> primitives = context.getPrimitives((OsmPrimitive) dataProvider);
    261         if (primitives != null && !primitives.isEmpty()) {
    262             template.appendText(result, primitives.get(0));
    263         } else {
    264             template.appendText(result, EMTPY_PROVIDER);
    265         }
     260        if (dataProvider instanceof OsmPrimitive) {
     261            List<OsmPrimitive> primitives = context.getPrimitives((OsmPrimitive) dataProvider);
     262            if (primitives != null && !primitives.isEmpty()) {
     263                template.appendText(result, primitives.get(0));
     264            }
     265        }
     266        template.appendText(result, EMPTY_PROVIDER);
    266267    }
    267268
    268269    @Override
    269270    public boolean isValid(TemplateEngineDataProvider dataProvider) {
    270         List<OsmPrimitive> primitives = context.getPrimitives((OsmPrimitive) dataProvider);
    271         if (primitives != null && !primitives.isEmpty())
    272             return template.isValid(primitives.get(0));
    273         else
    274             return false;
    275     }
    276 
     271        if (dataProvider instanceof OsmPrimitive) {
     272            List<OsmPrimitive> primitives = context.getPrimitives((OsmPrimitive) dataProvider);
     273            if (primitives != null && !primitives.isEmpty()) {
     274                return template.isValid(primitives.get(0));
     275            }
     276        }
     277        return false;
     278    }
    277279}
Note: See TracChangeset for help on using the changeset viewer.