Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.jackson.module.afterburner.deser;
  
  import java.util.*;
  
 
 
 {
    
Class loader to use for generated classes; if null, will try to use class loader of the target class.
 
     protected final MyClassLoader _classLoader;
     
     protected final boolean _useCustomDeserializer;
     
     public DeserializerModifier(ClassLoader clboolean useCustomDeserializer)
     {
         // If we were given parent class loader explicitly, use that:
          = (cl == null) ? null : new MyClassLoader(clfalse);
          = useCustomDeserializer;
     }
 
     /*
     /********************************************************************** 
     /* BeanDeserializerModifier methods
     /********************************************************************** 
      */
     
             BasicBeanDescription beanDescBeanDeserializerBuilder builder
     {
         final Class<?> beanClass = beanDesc.getBeanClass();
         /* Hmmh. Can we access stuff from private classes?
          * Possibly, if we can use parent class loader.
          * (should probably skip all non-public?)
          */
         if ( != null) {
             if (Modifier.isPrivate(beanClass.getModifiers())) {
                 return builder;
             }
         }
         PropertyMutatorCollector collector = new PropertyMutatorCollector();
                 collectorbuilder.getProperties());
         // and if we found any, create mutator proxy, replace property objects
         if (!newProps.isEmpty()) {
             BeanPropertyMutator mutator = collector.buildMutator(beanClass);
             for (OptimizedSettableBeanProperty<?> prop : newProps) {
                 builder.addOrReplaceProperty(prop.withMutator(mutator), true);
             }
         }
         // Second thing: see if we could (re)generate Creator(s):
         ValueInstantiator inst = builder.getValueInstantiator();
         /* Hmmh. Probably better to require exact default implementation
          * and not sub-class; chances are sub-class uses its own
          * construction anyway.
          */
         if (inst.getClass() == StdValueInstantiator.class) {
             // also, only override if using default creator (no-arg ctor, no-arg static factory)
             if (inst.canCreateUsingDefault()) {
                 inst = new CreatorOptimizer(beanClass, (StdValueInstantiatorinst).createOptimized();
                 if (inst != null) {
                     builder.setValueInstantiator(inst);
                 }
             }
         }
 
         // also: may want to replace actual BeanDeserializer as well? For this, need to replace builder
         // (but only if builder is the original standard one; don't want to break other impls)
         if ( && builder.getClass() == BeanDeserializerBuilder.class) {
             return new CustomDeserializerBuilder(builder);
         }
         return builder;
     }
 
     /*
     /********************************************************************** 
     /* Internal methods
     /********************************************************************** 
      */
     
             PropertyMutatorCollector collector,
             Iterator<SettableBeanPropertypropIterator)
     {
 
         // Ok, then, find any properties for which we could generate accessors
         while (propIterator.hasNext()) {
            SettableBeanProperty prop = propIterator.next();
            AnnotatedMember member = prop.getMember();
            // First: we can't access private fields or methods....
            if (Modifier.isPrivate(member.getMember().getModifiers())) {
                continue;
            }
            // (although, interestingly enough, can seem to access private classes...)
            // !!! TODO: skip entries with non-standard serializer
            // (may need to add accessor(s) to BeanPropertyWriter?)
            
            if (prop instanceof SettableBeanProperty.MethodProperty) { // simple setter methods
                Class<?> type = ((AnnotatedMethodmember).getParameterClass(0);
                if (type.isPrimitive()) {
                    if (type == .) {
                        newProps.add(collector.addIntSetter(prop));
                    } else if (type == .) {
                        newProps.add(collector.addLongSetter(prop));
                    }
                } else {
                    if (type == String.class) {
                        newProps.add(collector.addStringSetter(prop));
                    } else { // any other Object types; we can at least call accessor
                        newProps.add(collector.addObjectSetter(prop));
                    }
                }
            } else if (prop instanceof SettableBeanProperty.FieldProperty) { // regular fields
                Class<?> type = ((AnnotatedFieldmember).getRawType();
                if (type.isPrimitive()) {
                    if (type == .) {
                        newProps.add(collector.addIntField(prop));
                    } else if (type == .) {
                        newProps.add(collector.addLongField(prop));
                    }
                } else {
                    if (type == String.class) {
                        newProps.add(collector.addStringField(prop));
                    } else { // any other Object types; we can at least call accessor
                        newProps.add(collector.addObjectField(prop));
                    }
                } 
            }
        }
        return newProps;
    }
New to GrepCode? Check out our FAQ X