package com.twosigma.beaker.easyform;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Observable;
import java.util.Set;

public abstract class ObservableMap<K, V> extends Observable implements Map<K, V> {

  protected HashMap<K, V> mapInstance = new HashMap<>();

  @Override
  public int size() {
    return mapInstance.size();
  }

  @Override
  public boolean isEmpty() {
    return mapInstance.isEmpty();
  }

  @Override
  public boolean containsKey(Object key) {
    return mapInstance.containsKey(key);
  }

  @Override
  public boolean containsValue(Object value) {
    return mapInstance.containsValue(value);
  }

  @Override
  public V get(Object key) {
    return mapInstance.get(key);
  }

  @Override
  public V put(K key, V value) {
    return mapInstance.put(key, value);
  }

  @Override
  public V remove(Object key) {
    return mapInstance.remove(key);
  }

  @Override
  public void putAll(Map<? extends K, ? extends V> m) {
    mapInstance.putAll(m);
  }

  @Override
  public void clear() {
    mapInstance.clear();
  }

  @Override
  public Set<K> keySet() {
    return mapInstance.keySet();
  }

  @Override
  public Collection<V> values() {
    return mapInstance.values();
  }

  @Override
  public Set<Entry<K, V>> entrySet() {
    return mapInstance.entrySet();
  }
}

@@ -1,8 +1,631 @@
+/*%0A *  Copyright 2015 TWO SIGMA OPEN SOURCE, LLC%0A *%0A *  Licensed under the Apache License, Version 2.0 (the %22License%22);%0A *  you may not use this file except in compliance with the License.%0A *  You may obtain a copy of the License at%0A *%0A *         http://www.apache.org/licenses/LICENSE-2.0%0A *%0A *  Unless required by applicable law or agreed to in writing, software%0A *  distributed under the License is distributed on an %22AS IS%22 BASIS,%0A *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A *  See the License for the specific language governing permissions and%0A *  limitations under the License.%0A */%0A
 package 
@@ -684,16 +684,48 @@
 ection;%0A
+import java.util.LinkedHashMap;%0A
 import j
@@ -913,16 +913,22 @@
 otected 
+Linked
 HashMap%3C
@@ -951,16 +951,22 @@
 e = new 
+Linked
 HashMap%3C

use a LinkedHashMap so when you iterate over the form, the order of the contents is preserved