/*
 * Copyright 2017 requery.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.requery.jackson;

import com.fasterxml.jackson.databind.BeanDescription;
import com.fasterxml.jackson.databind.DeserializationConfig;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.deser.BeanDeserializer;
import com.fasterxml.jackson.databind.deser.BeanDeserializerModifier;

class DeserializerModifier extends BeanDeserializerModifier {

    @Override
    public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config,
                                                  BeanDescription beanDesc,
                                                  JsonDeserializer<?> deserializer) {
        if (deserializer instanceof BeanDeserializer) {
            BeanDeserializer beanDeserializer = (BeanDeserializer) deserializer;
            return new EntityBeanDeserializer(beanDeserializer, deserializer.getObjectIdReader());
        }
        return super.modifyDeserializer(config, beanDesc, deserializer);
    }
}

@@ -920,16 +920,240 @@
 odifier;
+%0Aimport com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition;%0Aimport com.fasterxml.jackson.databind.introspect.POJOPropertyBuilder;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Collection;%0Aimport java.util.List;
 %0A%0Aclass 
@@ -1789,11 +1789,1421 @@
 );%0A    %7D
+%0A%0A    @Override%0A    public List%3CBeanPropertyDefinition%3E updateProperties(DeserializationConfig config,%0A                                                         BeanDescription beanDesc,%0A                                                         List%3CBeanPropertyDefinition%3E propDefs) %7B%0A        List%3CBeanPropertyDefinition%3E definitions = super.updateProperties(config, beanDesc, propDefs);%0A        List%3CBeanPropertyDefinition%3E remove = new ArrayList%3C%3E();%0A        List%3CBeanPropertyDefinition%3E add = new ArrayList%3C%3E();%0A        for (BeanPropertyDefinition definition : definitions) %7B%0A            if (definition.hasGetter() &&%0A                    Collection.class.isAssignableFrom(definition.getGetter().getRawType())) %7B%0A%0A                if (definition instanceof POJOPropertyBuilder) %7B%0A                    POJOPropertyBuilder builder = (POJOPropertyBuilder) definition;%0A                    builder = new POJOPropertyBuilder(builder, builder.getFullName()) %7B%0A                        @Override%0A                        public boolean hasField() %7B%0A                            return false; // forces the getter to be used on the collection%0A                        %7D%0A                    %7D;%0A                    remove.add(definition);%0A                    add.add(builder);%0A                %7D%0A            %7D%0A        %7D%0A%0A        definitions.removeAll(remove);%0A        definitions.addAll(add);%0A%0A        return definitions;%0A    %7D
 %0A%7D%0A

Resolve #563 Jackson collection types force the getter to be used