Changeset 11388 in josm


Ignore:
Timestamp:
2016-12-13T12:30:54+01:00 (7 years ago)
Author:
Don-vip
Message:

findbugs - BC_BAD_CAST_TO_CONCRETE_COLLECTION - remove Cloneable interface, use simpler copy constructor

Location:
trunk/src/org/openstreetmap/josm/gui/mappaint
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/Cascade.java

    r10309 r11388  
    1919 * Simple map of properties with dynamic typing.
    2020 */
    21 public final class Cascade implements Cloneable {
    22 
    23     private Map<String, Object> prop = new HashMap<>();
     21public final class Cascade {
     22
     23    private final Map<String, Object> prop;
    2424
    2525    private boolean defaultSelectedHandling = true;
    2626
    2727    private static final Pattern HEX_COLOR_PATTERN = Pattern.compile("#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})");
     28
     29    /**
     30     * Constructs a new {@code Cascade}.
     31     */
     32    public Cascade() {
     33        this.prop = new HashMap<>();
     34    }
     35
     36    /**
     37     * Constructs a new {@code Cascade} from existing one.
     38     * @param other other Cascade
     39     */
     40    public Cascade(Cascade other) {
     41        this.prop = new HashMap<>(other.prop);
     42    }
    2843
    2944    public <T> T get(String key, T def, Class<T> klass) {
     
    196211
    197212    @Override
    198     public Cascade clone() {
    199         try {
    200             Cascade c = (Cascade) super.clone();
    201             @SuppressWarnings({ "unchecked", "rawtypes" })
    202             Map<String, Object> clonedProp = (Map<String, Object>) ((HashMap) this.prop).clone();
    203             c.prop = clonedProp;
    204             return c;
    205         } catch (CloneNotSupportedException e) {
    206             throw new IllegalStateException(e);
    207         }
    208     }
    209 
    210     @Override
    211213    public String toString() {
    212214        StringBuilder res = new StringBuilder("Cascade{ ");
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MultiCascade.java

    r9239 r11388  
    3939        if (c == null) {
    4040            if (layers.containsKey("*")) {
    41                 c = layers.get("*").clone();
     41                c = new Cascade(layers.get("*"));
    4242            } else {
    4343                c = new Cascade();
Note: See TracChangeset for help on using the changeset viewer.