AtomicCounterEditor extends DefaultEditor { static boolean isConsolidate(@NotNull NodeBuilder b) { checkNotNull(b); PropertyState counter = b.getProperty(PROP_COUNTER); if (counter == null) { counter = LongPropertyState.createLongProperty(PROP_COUNTER, 0); } long hiddensum = 0; for (PropertyState p : b.getProperties()) { if (p.getName().startsWith(PREFIX_PROP_COUNTER)) { hiddensum += p.getValue(LONG); } } return counter.getValue(LONG) != hiddensum; } AtomicCounterEditor(@NotNull final NodeBuilder builder, 
                               @Nullable String instanceId,
                               @Nullable ScheduledExecutorService executor,
                               @Nullable NodeStore store,
                               @Nullable Whiteboard board); private  AtomicCounterEditor(final String path, 
                                final NodeBuilder builder, 
                                @Nullable String instanceId, 
                                @Nullable ScheduledExecutorService executor,
                                @Nullable NodeStore store,
                                @Nullable Whiteboard board); static void consolidateCount(@NotNull final NodeBuilder builder); @Override void propertyAdded(final PropertyState after); @Override Editor childNodeAdded(final String name, final NodeState after); @Override Editor childNodeChanged(final String name, 
                                   final NodeState before, 
                                   final NodeState after); @Override void leave(final NodeState before, final NodeState after); static final String PROP_INCREMENT; static final String PROP_COUNTER; static final String PREFIX_PROP_COUNTER; static final String PREFIX_PROP_REVISION; }
@Test public void isConsolidate() { NodeBuilder b = EMPTY_NODE.builder(); PropertyState counter, hidden1, hidden2; String hidden1Name = PREFIX_PROP_COUNTER + "1"; String hidden2Name = PREFIX_PROP_COUNTER + "2"; assertFalse(AtomicCounterEditor.isConsolidate(b)); counter = LongPropertyState.createLongProperty(PROP_COUNTER, 0); hidden1 = LongPropertyState.createLongProperty(hidden1Name, 1); b.setProperty(counter); b.setProperty(hidden1); assertTrue(AtomicCounterEditor.isConsolidate(b)); counter = LongPropertyState.createLongProperty(PROP_COUNTER, 1); hidden1 = LongPropertyState.createLongProperty(hidden1Name, 1); hidden2 = LongPropertyState.createLongProperty(hidden2Name, 1); b.setProperty(counter); b.setProperty(hidden1); b.setProperty(hidden2); assertTrue(AtomicCounterEditor.isConsolidate(b)); counter = LongPropertyState.createLongProperty(PROP_COUNTER, 2); hidden1 = LongPropertyState.createLongProperty(hidden1Name, 1); hidden2 = LongPropertyState.createLongProperty(hidden2Name, 1); b.setProperty(counter); b.setProperty(hidden1); b.setProperty(hidden2); assertFalse(AtomicCounterEditor.isConsolidate(b)); }