@Test public void testNotUsed() { when(config.isIncludeJsr303Annotations()).thenReturn(true); when(node.has("minimum")).thenReturn(false); when(node.has("maximum")).thenReturn(false); when(fieldVar.type().boxify().fullName()).thenReturn(fieldClass.getTypeName()); JFieldVar result = rule.apply("node", node, null, fieldVar, null); assertSame(fieldVar, result); verify(fieldVar, never()).annotate(Size.class); verify(annotationMin, never()).param(anyString(), anyString()); verify(annotationMax, never()).param(anyString(), anyString()); }
@Override public JFieldVar apply(String nodeName, JsonNode node, JsonNode parent, JFieldVar field, Schema currentSchema) { if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations() && isApplicableType(field)) { if (node.has("minimum")) { JAnnotationUse annotation = field.annotate(DecimalMin.class); annotation.param("value", node.get("minimum").asText()); } if (node.has("maximum")) { JAnnotationUse annotation = field.annotate(DecimalMax.class); annotation.param("value", node.get("maximum").asText()); } } return field; }
MinimumMaximumRule implements Rule<JFieldVar, JFieldVar> { @Override public JFieldVar apply(String nodeName, JsonNode node, JsonNode parent, JFieldVar field, Schema currentSchema) { if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations() && isApplicableType(field)) { if (node.has("minimum")) { JAnnotationUse annotation = field.annotate(DecimalMin.class); annotation.param("value", node.get("minimum").asText()); } if (node.has("maximum")) { JAnnotationUse annotation = field.annotate(DecimalMax.class); annotation.param("value", node.get("maximum").asText()); } } return field; } }
MinimumMaximumRule implements Rule<JFieldVar, JFieldVar> { @Override public JFieldVar apply(String nodeName, JsonNode node, JsonNode parent, JFieldVar field, Schema currentSchema) { if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations() && isApplicableType(field)) { if (node.has("minimum")) { JAnnotationUse annotation = field.annotate(DecimalMin.class); annotation.param("value", node.get("minimum").asText()); } if (node.has("maximum")) { JAnnotationUse annotation = field.annotate(DecimalMax.class); annotation.param("value", node.get("maximum").asText()); } } return field; } protected  MinimumMaximumRule(RuleFactory ruleFactory); }
MinimumMaximumRule implements Rule<JFieldVar, JFieldVar> { @Override public JFieldVar apply(String nodeName, JsonNode node, JsonNode parent, JFieldVar field, Schema currentSchema) { if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations() && isApplicableType(field)) { if (node.has("minimum")) { JAnnotationUse annotation = field.annotate(DecimalMin.class); annotation.param("value", node.get("minimum").asText()); } if (node.has("maximum")) { JAnnotationUse annotation = field.annotate(DecimalMax.class); annotation.param("value", node.get("maximum").asText()); } } return field; } protected  MinimumMaximumRule(RuleFactory ruleFactory); @Override JFieldVar apply(String nodeName, JsonNode node, JsonNode parent, JFieldVar field, Schema currentSchema); }
MinimumMaximumRule implements Rule<JFieldVar, JFieldVar> { @Override public JFieldVar apply(String nodeName, JsonNode node, JsonNode parent, JFieldVar field, Schema currentSchema) { if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations() && isApplicableType(field)) { if (node.has("minimum")) { JAnnotationUse annotation = field.annotate(DecimalMin.class); annotation.param("value", node.get("minimum").asText()); } if (node.has("maximum")) { JAnnotationUse annotation = field.annotate(DecimalMax.class); annotation.param("value", node.get("maximum").asText()); } } return field; } protected  MinimumMaximumRule(RuleFactory ruleFactory); @Override JFieldVar apply(String nodeName, JsonNode node, JsonNode parent, JFieldVar field, Schema currentSchema);  }