persistable sclass SynchronizedNavigableMap extends SynchronizedSortedMap implements NavigableMap { // not final because persistence private /*final*/ NavigableMap nm; SynchronizedNavigableMap(NavigableMap m) { super(m); nm = m; } SynchronizedNavigableMap(NavigableMap m, Object mutex) { super(m, mutex); nm = m; } public Entry lowerEntry(K key) { synchronized (mutex) { return nm.lowerEntry(key); } } public K lowerKey(K key) { synchronized (mutex) { return nm.lowerKey(key); } } public Entry floorEntry(K key) { synchronized (mutex) { return nm.floorEntry(key); } } public K floorKey(K key) { synchronized (mutex) { return nm.floorKey(key); } } public Entry ceilingEntry(K key) { synchronized (mutex) { return nm.ceilingEntry(key); } } public K ceilingKey(K key) { synchronized (mutex) { return nm.ceilingKey(key); } } public Entry higherEntry(K key) { synchronized (mutex) { return nm.higherEntry(key); } } public K higherKey(K key) { synchronized (mutex) { return nm.higherKey(key); } } public Entry firstEntry() { synchronized (mutex) { return nm.firstEntry(); } } public Entry lastEntry() { synchronized (mutex) { return nm.lastEntry(); } } public Entry pollFirstEntry() { synchronized (mutex) { return nm.pollFirstEntry(); } } public Entry pollLastEntry() { synchronized (mutex) { return nm.pollLastEntry(); } } public NavigableMap descendingMap() { synchronized (mutex) { return new SynchronizedNavigableMap<>(nm.descendingMap(), mutex); } } public NavigableSet keySet() { return navigableKeySet(); } public NavigableSet navigableKeySet() { synchronized (mutex) { return new SynchronizedNavigableSet<>(nm.navigableKeySet(), mutex); } } public NavigableSet descendingKeySet() { synchronized (mutex) { return new SynchronizedNavigableSet<>(nm.descendingKeySet(), mutex); } } public SortedMap subMap(K fromKey, K toKey) { synchronized (mutex) { return new SynchronizedNavigableMap<>( nm.subMap(fromKey, true, toKey, false), mutex); } } public SortedMap headMap(K toKey) { synchronized (mutex) { return new SynchronizedNavigableMap<>(nm.headMap(toKey, false), mutex); } } public SortedMap tailMap(K fromKey) { synchronized (mutex) { return new SynchronizedNavigableMap<>(nm.tailMap(fromKey, true),mutex); } } public NavigableMap subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) { synchronized (mutex) { return new SynchronizedNavigableMap<>( nm.subMap(fromKey, fromInclusive, toKey, toInclusive), mutex); } } public NavigableMap headMap(K toKey, boolean inclusive) { synchronized (mutex) { return new SynchronizedNavigableMap<>( nm.headMap(toKey, inclusive), mutex); } } public NavigableMap tailMap(K fromKey, boolean inclusive) { synchronized (mutex) { return new SynchronizedNavigableMap<>( nm.tailMap(fromKey, inclusive), mutex); } } }