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

        boolean defaultPresent = node != null && isNotEmpty(node.asText());

        String fieldType = field.type().fullName();

        if (defaultPresent && !field.type().isPrimitive() && node.isNull()) {
            field.init(JExpr._null());
        } else if (fieldType.startsWith(List.class.getName())) {
            field.init(getDefaultList(field.type(), node));
        } else if (fieldType.startsWith(Set.class.getName())) {
            field.init(getDefaultSet(field.type(), node));
        } else if (fieldType.startsWith(String.class.getName()) && node != null ) {
            field.init(getDefaultValue(field.type(), node));
        } else if (defaultPresent) {
            field.init(getDefaultValue(field.type(), node));

        }

        return field;
    }
@Test
    public void whenIsInitializeCollections_false_applyDoesNotInitializeField() throws JClassAlreadyExistsException {
        final String fieldName = "fieldName";
        when(config.isInitializeCollections()).thenReturn(false);

        JDefinedClass jclass = new JCodeModel()._class("org.jsonschema2pojo.rules.ExampleClass");
        JFieldVar field = jclass.field(JMod.NONE, jclass.owner().ref(fieldTypeClass).narrow(Object.class), fieldName);
        ArrayNode node = new ObjectMapper().createArrayNode();

        StringWriter sw = new StringWriter();
        rule.apply("fooBar", node, null, field, null).bind(new JFormatter(sw));
        assertThat(sw.toString(), is(String.format("%s<%s> %s", fieldTypeClass.getName(), Object.class.getName(), fieldName)));
    }