@Override
    public JFieldVar apply(String nodeName, JsonNode node, JsonNode parent, JFieldVar field, Schema currentSchema) {

        if (ruleFactory.getGenerationConfig().isIncludeJsr303Annotations()
                && (node.has("minItems") || node.has("maxItems"))
                && isApplicableType(field)) {

            final Class<? extends Annotation> sizeClass
                    = ruleFactory.getGenerationConfig().isUseJakartaValidation()
                    ? Size.class
                    : javax.validation.constraints.Size.class;
            JAnnotationUse annotation = field.annotate(sizeClass);

            if (node.has("minItems")) {
                annotation.param("min", node.get("minItems").asInt());
            }

            if (node.has("maxItems")) {
                annotation.param("max", node.get("maxItems").asInt());
            }
        }

        return field;
    }
@Test
    public void testMaxLength() {
        when(config.isIncludeJsr303Annotations()).thenReturn(true);
        final int maxValue = new Random().nextInt();
        when(subNode.asInt()).thenReturn(maxValue);
        when(node.get("maxItems")).thenReturn(subNode);
        when(fieldVar.annotate(sizeClass)).thenReturn(annotation);
        when(node.has("maxItems")).thenReturn(true);
        when(fieldVar.type().boxify().fullName()).thenReturn(fieldClass.getTypeName());

        JFieldVar result = rule.apply("node", node, null, fieldVar, null);
        assertSame(fieldVar, result);

        verify(fieldVar, times(isApplicable ? 1 : 0)).annotate(sizeClass);
        verify(annotation, times(isApplicable ? 1 : 0)).param("max", maxValue);
        verify(annotation, never()).param(eq("min"), anyInt());
    }