### Question:
RequiredRule implements Rule<JDocCommentable, JDocCommentable> { @Override public JDocCommentable apply(String nodeName, JsonNode node, JsonNode parent, JDocCommentable generatableType, Schema schema) { if (node.asBoolean()) { generatableType.javadoc().append("\n(Required)"); if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations() && generatableType instanceof JFieldVar) { ((JFieldVar) generatableType).annotate(NotNull.class); } if (ruleFactory.getGenerationConfig().isIncludeJsr305Annotations() && generatableType instanceof JFieldVar) { ((JFieldVar) generatableType).annotate(Nonnull.class); } } else { if (ruleFactory.getGenerationConfig().isIncludeJsr305Annotations() && generatableType instanceof JFieldVar) { ((JFieldVar) generatableType).annotate(Nullable.class); } } return generatableType; } protected  RequiredRule(RuleFactory ruleFactory); @Override JDocCommentable apply(String nodeName, JsonNode node, JsonNode parent, JDocCommentable generatableType, Schema schema);  }### Answer:
@Test public void applyAddsTextWhenRequired() throws JClassAlreadyExistsException { JDefinedClass jclass = new JCodeModel()._class(TARGET_CLASS_NAME); ObjectMapper mapper = new ObjectMapper(); BooleanNode descriptionNode = mapper.createObjectNode().booleanNode(true); JDocCommentable result = rule.apply("fooBar", descriptionNode, null, jclass, null); assertThat(result.javadoc(), sameInstance(jclass.javadoc())); assertThat(result.javadoc().size(), is(1)); assertThat((String) result.javadoc().get(0), is("\n(Required)")); }
@Test public void applySkipsTextWhenNotRequired() throws JClassAlreadyExistsException { JDefinedClass jclass = new JCodeModel()._class(TARGET_CLASS_NAME); ObjectMapper mapper = new ObjectMapper(); BooleanNode descriptionNode = mapper.createObjectNode().booleanNode(false); JDocCommentable result = rule.apply("fooBar", descriptionNode, null, jclass, null); assertThat(result.javadoc(), sameInstance(jclass.javadoc())); assertThat(result.javadoc().size(), is(0)); }