@Test public void put() { Options<Integer> opt = new Options<Integer>(); opt.put(1, "one"); assertEquals("opt.size()", 1, opt.size()); assertEquals("opt.get(1)", "one", opt.get(1)); }
public String put(K key, String value) { if (value == null) { throw new IllegalArgumentException("value==null"); } boolean noChange = equals(map.get(key), value); if (noChange) { return value; } if (values.contains(value)) { throw new IllegalArgumentException("duplicate value='" + value + "' "); } String result = map.put(key, value); values.add(value); if (result != null) { values.remove(result); } this.fireChanged(); return result; }
Options { public String put(K key, String value) { if (value == null) { throw new IllegalArgumentException("value==null"); } boolean noChange = equals(map.get(key), value); if (noChange) { return value; } if (values.contains(value)) { throw new IllegalArgumentException("duplicate value='" + value + "' "); } String result = map.put(key, value); values.add(value); if (result != null) { values.remove(result); } this.fireChanged(); return result; } }
Options { public String put(K key, String value) { if (value == null) { throw new IllegalArgumentException("value==null"); } boolean noChange = equals(map.get(key), value); if (noChange) { return value; } if (values.contains(value)) { throw new IllegalArgumentException("duplicate value='" + value + "' "); } String result = map.put(key, value); values.add(value); if (result != null) { values.remove(result); } this.fireChanged(); return result; }  }
Options { public String put(K key, String value) { if (value == null) { throw new IllegalArgumentException("value==null"); } boolean noChange = equals(map.get(key), value); if (noChange) { return value; } if (values.contains(value)) { throw new IllegalArgumentException("duplicate value='" + value + "' "); } String result = map.put(key, value); values.add(value); if (result != null) { values.remove(result); } this.fireChanged(); return result; }  Map<K, String> toMap(); void clear(); boolean containsKey(Object key); boolean containsValue(Object value); String get(Object key); K getKey(String value); boolean isEmpty(); Set<K> keySet(); String put(K key, String value); void putAll(Options other); void putAll(Map<K, String> aMap); String remove(Object key); Set<String> removeAll(Set<K> keys); int size(); Set<String> values(); String[] getValues(); int indexOf(String value); String getValue(int index); void addOptionsListener(OptionsListener l); void removeOptionsListener(OptionsListener l); static Options<T> create(T... values); }
Options { public String put(K key, String value) { if (value == null) { throw new IllegalArgumentException("value==null"); } boolean noChange = equals(map.get(key), value); if (noChange) { return value; } if (values.contains(value)) { throw new IllegalArgumentException("duplicate value='" + value + "' "); } String result = map.put(key, value); values.add(value); if (result != null) { values.remove(result); } this.fireChanged(); return result; }  Map<K, String> toMap(); void clear(); boolean containsKey(Object key); boolean containsValue(Object value); String get(Object key); K getKey(String value); boolean isEmpty(); Set<K> keySet(); String put(K key, String value); void putAll(Options other); void putAll(Map<K, String> aMap); String remove(Object key); Set<String> removeAll(Set<K> keys); int size(); Set<String> values(); String[] getValues(); int indexOf(String value); String getValue(int index); void addOptionsListener(OptionsListener l); void removeOptionsListener(OptionsListener l); static Options<T> create(T... values);  }