NodeState snapshot() { assert base != null; if (properties.isEmpty() && nodes.isEmpty()) { return base; } else { return new ModifiedNodeState(base, properties, nodes); } }
NodeState snapshot() { assert base != null; if (properties.isEmpty() && nodes.isEmpty()) { return base; } else { return new ModifiedNodeState(base, properties, nodes); } }
@Test public void emptyEqualsMissing() { NodeState empty = EmptyNodeState.EMPTY_NODE; NodeState missing = new ModifiedNodeState( EmptyNodeState.MISSING_NODE, new HashMap<String, PropertyState>(), new HashMap<String, MutableNodeState>()); assertTrue(empty.exists()); assertFalse(missing.exists()); assertFalse(missing.equals(empty)); assertFalse(empty.equals(missing)); }
@Test public void missingEqualsModified() { NodeState empty = new ModifiedNodeState( EmptyNodeState.EMPTY_NODE, new HashMap<String, PropertyState>(), new HashMap<String, MutableNodeState>()); NodeState missing = EmptyNodeState.MISSING_NODE; assertTrue(empty.exists()); assertFalse(missing.exists()); assertFalse(missing.equals(empty)); assertFalse(empty.equals(missing)); } }