- protected transient Map<String, INode> children = createChildMap();
- private transient TLongObjectHashMap<String> childrenIdMap = new TLongObjectHashMap<>();
+ private static class ImmutableIdMap extends TLongObjectHashMap<String> {
+ private static final String MSG = "immutable singleton instance";
+
+ @Override
+ public String put(long key, String value) {
+ throw new UnsupportedOperationException(MSG);
+ }
+ @Override
+ public void putAll(Map<? extends Long, ? extends String> map) {
+ throw new UnsupportedOperationException(MSG);
+ }
+ @Override
+ public void putAll(TLongObjectMap<? extends String> map) {
+ throw new UnsupportedOperationException(MSG);
+ }
+ @Override
+ public String putIfAbsent(long key, String value) {
+ throw new UnsupportedOperationException(MSG);
+ }
+ }
+
+ /**
+ * This is the value given to {@link #children} when this node is disposed and
+ * cleaned up.
+ */
+ private static final Map<String, INode> DISPOSED_CHILDREN = Collections.emptyMap();
+
+ /**
+ * This is the value given to {@link #childrenIdMap} when this node is disposed
+ * and cleaned up.
+ */
+ private static final TLongObjectMap<String> DISPOSED_CHILDREN_ID_MAP = new ImmutableIdMap();
+
+ protected transient Map<String, INode> children = createChildMap();
+ private transient TLongObjectMap<String> childrenIdMap = new TLongObjectHashMap<>();