Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.jackson.databind.deser.std;
  
  import java.util.*;
  
Helper class used to contain simple/well-known key deserializers. Following kinds of Objects can be handled currently:
  • Primitive wrappers (Boolean, Byte, Char, Short, Integer, Float, Long, Double)
  • Enums (usually not needed, since EnumMap doesn't call us)
  • java.util.Date
  • java.util.Calendar
  • java.util.UUID
  • java.util.Locale
  • Anything with constructor that takes a single String arg (if not explicitly

    JsonIgnore:
    d)
  • Anything with static T valueOf(String) factory method (if not explicitly @JsonIgnore'd)
 
 public class StdKeyDeserializers
     implements KeyDeserializersjava.io.Serializable
 {
     private static final long serialVersionUID = 923268084968181479L;

    

Deprecated:
Since 2.2, just call StdKeyDeserializer.StringKD directly
 
     @Deprecated
             JavaType type) {
         return StdKeyDeserializer.StringKD.forType(type.getRawClass());
     }
     
     public static KeyDeserializer constructEnumKeyDeserializer(EnumResolver<?> enumResolver) {
         return new StdKeyDeserializer.EnumKD(enumResolvernull);
     }
 
     public static KeyDeserializer constructEnumKeyDeserializer(EnumResolver<?> enumResolver,
             AnnotatedMethod factory) {
         return new StdKeyDeserializer.EnumKD(enumResolverfactory);
     }
     
             JavaType typeJsonDeserializer<?> deser)
     {
         return new StdKeyDeserializer.DelegatingKD(type.getRawClass(), deser);
     }
     
             JavaType type)
     {
         /* We don't need full deserialization information, just need to
          * know creators.
          */
         BeanDescription beanDesc = config.introspect(type);
         // Ok, so: can we find T(String) constructor?
         Constructor<?> ctor = beanDesc.findSingleArgConstructor(String.class);
         if (ctor != null) {
             if (config.canOverrideAccessModifiers()) {
                 ClassUtil.checkAndFixAccess(ctor);
             }
             return new StdKeyDeserializer.StringCtorKeyDeserializer(ctor);
         }
         /* or if not, "static T valueOf(String)" (or equivalent marked
          * with @JsonCreator annotation?)
          */
         Method m = beanDesc.findFactoryMethod(String.class);
         if (m != null){
             if (config.canOverrideAccessModifiers()) {
                 ClassUtil.checkAndFixAccess(m);
             }
             return new StdKeyDeserializer.StringFactoryKeyDeserializer(m);
         }
         // nope, no such luck...
         return null;
     }
     
     /*
     /**********************************************************
     /* KeyDeserializers implementation
     /**********************************************************
      */
     
     @Override
             DeserializationConfig configBeanDescription beanDesc)
         throws JsonMappingException
     {
         Class<?> raw = type.getRawClass();
         // First, common types; String/Object/UUID, Int/Long, Dates
        if (raw == String.class || raw == Object.class) {
            return StdKeyDeserializer.StringKD.forType(raw);
        }
        if (raw == UUID.class) {
            return new StdKeyDeserializer.UuidKD();
        }
        if (raw == Integer.class) {
            return new StdKeyDeserializer.IntKD();
        }
        if (raw == Long.class) {
            return new StdKeyDeserializer.LongKD();
        }
        if (raw == Date.class) {
            return new StdKeyDeserializer.DateKD();
        }
        if (raw == Calendar.class) {
            return new StdKeyDeserializer.CalendarKD();
        }
        
        // then less common ones...
        if (raw == Boolean.class) {
            return new StdKeyDeserializer.BoolKD();
        }
        if (raw == Byte.class) {
            return new StdKeyDeserializer.ByteKD();
        }
        if (raw == Character.class) {
            return new StdKeyDeserializer.CharKD();
        }
        if (raw == Short.class) {
            return new StdKeyDeserializer.ShortKD();
        }
        if (raw == Float.class) {
            return new StdKeyDeserializer.FloatKD();
        }
        if (raw == Double.class) {
            return new StdKeyDeserializer.DoubleKD();
        }
        if (raw == Locale.class) {
            return new StdKeyDeserializer.LocaleKD();
        }
        return null;
    }
New to GrepCode? Check out our FAQ X