SkipFromAstIfOnlyOneChild implements AstNodeSkippingPolicy { @Override public boolean hasToBeSkippedFromAst(AstNode node) { return node.getNumberOfChildren() == 1; } private  SkipFromAstIfOnlyOneChild(); @Override boolean hasToBeSkippedFromAst(AstNode node); static final SkipFromAstIfOnlyOneChild INSTANCE; }
@Test public void testHasToBeSkippedFromAst() { AstNode astNode = mock(AstNode.class); when(astNode.getNumberOfChildren()).thenReturn(1); assertThat(SkipFromAstIfOnlyOneChild.INSTANCE.hasToBeSkippedFromAst(astNode)).isTrue(); when(astNode.getNumberOfChildren()).thenReturn(2); assertThat(SkipFromAstIfOnlyOneChild.INSTANCE.hasToBeSkippedFromAst(astNode)).isFalse(); }