@Test public void testGetOrAddSubtree() { String text = "foo"; SetStatementTree tree = new SetStatementTree(); assertThat(tree._children, anEmptyMap()); SetStatementTree child = tree.getOrAddSubtree(text); assertThat(child, notNullValue()); assertThat(tree._children, hasEntry(equalTo(text), sameInstance(child))); assertThat(tree.getOrAddSubtree(text), sameInstance(child)); }
public @Nonnull SetStatementTree getOrAddSubtree(String partialStatementText) { return _children.computeIfAbsent(partialStatementText, t -> new SetStatementTree(this)); }
SetStatementTree { public @Nonnull SetStatementTree getOrAddSubtree(String partialStatementText) { return _children.computeIfAbsent(partialStatementText, t -> new SetStatementTree(this)); } }
SetStatementTree { public @Nonnull SetStatementTree getOrAddSubtree(String partialStatementText) { return _children.computeIfAbsent(partialStatementText, t -> new SetStatementTree(this)); } SetStatementTree(); private  SetStatementTree(@Nullable SetStatementTree parent); }
SetStatementTree { public @Nonnull SetStatementTree getOrAddSubtree(String partialStatementText) { return _children.computeIfAbsent(partialStatementText, t -> new SetStatementTree(this)); } SetStatementTree(); private  SetStatementTree(@Nullable SetStatementTree parent); void addSetStatementIndex(int setStatementIndex); @Nonnull SetStatementTree getOrAddSubtree(String partialStatementText); @Nullable SetStatementTree getParent(); @Nonnull Set<Integer> getSetStatementIndices(); SetStatementTree replaceSubtree(String partialStatementText); }
SetStatementTree { public @Nonnull SetStatementTree getOrAddSubtree(String partialStatementText) { return _children.computeIfAbsent(partialStatementText, t -> new SetStatementTree(this)); } SetStatementTree(); private  SetStatementTree(@Nullable SetStatementTree parent); void addSetStatementIndex(int setStatementIndex); @Nonnull SetStatementTree getOrAddSubtree(String partialStatementText); @Nullable SetStatementTree getParent(); @Nonnull Set<Integer> getSetStatementIndices(); SetStatementTree replaceSubtree(String partialStatementText);  }