Ignore:
Timestamp:
2016-12-14T04:19:09+01:00 (9 years ago)
Author:
Don-vip
Message:

simplify preference settings equals handling (already performed by AbstractList.equals / AbstractMap.equals) - fixes squid:S1206 and findbugs HE_EQUALS_NO_HASHCODE warnings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/preferences/MapListSetting.java

    r10235 r11394  
    44import java.util.ArrayList;
    55import java.util.Collections;
    6 import java.util.Iterator;
    76import java.util.LinkedHashMap;
    87import java.util.List;
    98import java.util.Map;
    10 import java.util.Map.Entry;
    11 import java.util.Objects;
    129
    1310/**
     
    2421        super(value);
    2522        consistencyTest();
    26     }
    27 
    28     @Override
    29     public boolean equalVal(List<Map<String, String>> otherVal) {
    30         if (value == null)
    31             return otherVal == null;
    32         if (otherVal == null)
    33             return false;
    34         if (value.size() != otherVal.size())
    35             return false;
    36         Iterator<Map<String, String>> itA = value.iterator();
    37         Iterator<Map<String, String>> itB = otherVal.iterator();
    38         while (itA.hasNext()) {
    39             if (!equalMap(itA.next(), itB.next()))
    40                 return false;
    41         }
    42         return true;
    43     }
    44 
    45     private static boolean equalMap(Map<String, String> a, Map<String, String> b) {
    46         if (a == null)
    47             return b == null;
    48         if (b == null)
    49             return false;
    50         if (a.size() != b.size())
    51             return false;
    52         for (Entry<String, String> e : a.entrySet()) {
    53             if (!Objects.equals(e.getValue(), b.get(e.getKey())))
    54                 return false;
    55         }
    56         return true;
    5723    }
    5824
     
    9157        return new MapListSetting(null);
    9258    }
    93 
    94     @Override
    95     public boolean equals(Object other) {
    96         if (!(other instanceof MapListSetting))
    97             return false;
    98         return equalVal(((MapListSetting) other).getValue());
    99     }
    10059}
Note: See TracChangeset for help on using the changeset viewer.