Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package de.zalando.typemapper.core.fieldMapper;
  
  
  import java.util.Date;
  import java.util.List;
  import java.util.Map;
  import java.util.Set;
 
 
 public class FieldMapperRegister {
 
     @SuppressWarnings({ "rawtypes" })
     private static final Map<ClassFieldMapperregister = new ConcurrentHashMap<ClassFieldMapper>();
 
     static {
         final FieldMapper dateFieldMapper = new DateFieldMapper();
         FieldMapperRegister.register(Date.classdateFieldMapper);
 
         final FieldMapper integerMapper = new IntegerFieldMapper();
         FieldMapperRegister.register(Integer.classintegerMapper);
 
         final FieldMapper intMapper = new IntFieldMapper();
         FieldMapperRegister.register(int.classintMapper);
 
         final FieldMapper longMapper = new LongFieldMapper();
         FieldMapperRegister.register(Long.classlongMapper);
 
         final FieldMapper primitiveLongMapper = new PrimitiveLongFieldMapper();
         FieldMapperRegister.register(long.classprimitiveLongMapper);
 
         final FieldMapper charMapper = new CharFieldMapper();
         FieldMapperRegister.register(char.classcharMapper);
         FieldMapperRegister.register(Character.classcharMapper);
 
         final FieldMapper stringMapper = new StringFieldMapper();
         FieldMapperRegister.register(String.classstringMapper);
 
         final FieldMapper doubleMapper = new DoubleFieldMapper();
         FieldMapperRegister.register(Double.classdoubleMapper);
         FieldMapperRegister.register(double.classdoubleMapper);
 
         final FieldMapper floatMapper = new FloatFieldMapper();
         FieldMapperRegister.register(Float.classfloatMapper);
         FieldMapperRegister.register(float.classfloatMapper);
 
         final FieldMapper shortMapper = new ShortFieldMapper();
         FieldMapperRegister.register(Short.classshortMapper);
         FieldMapperRegister.register(short.classshortMapper);
 
         final FieldMapper booleanMapper = new BooleanFieldMapper();
         FieldMapperRegister.register(Boolean.classbooleanMapper);
         FieldMapperRegister.register(boolean.classbooleanMapper);
 
         final FieldMapper enumMapper = new EnumrationFieldMapper();
         FieldMapperRegister.register(Enum.classenumMapper);
 
         final FieldMapper bigDecimalMapper = new BigDecimalFieldMappper();
         FieldMapperRegister.register(BigDecimal.classbigDecimalMapper);
 
         final FieldMapper hstoreMapper = new HStoreFieldMapper();
         FieldMapperRegister.register(Map.classhstoreMapper);
 
         final FieldMapper nullListMapper = new NullListFieldMapper();
         FieldMapperRegister.register(List.classnullListMapper);
 
         final FieldMapper nullSetMapper = new NullSetFieldMapper();
         FieldMapperRegister.register(Set.classnullSetMapper);
     }
 
     @SuppressWarnings("rawtypes")
     private static void register(final Class clazzfinal FieldMapper mapper) {
         .put(clazzmapper);
     }
 
     @SuppressWarnings("rawtypes")
     public static FieldMapper getMapperForClass(final Class clazz) {
         FieldMapper fieldMapper = .get(clazz);
 
         if (fieldMapper == null) {
 
             // check if there is a global field mapper defined in the value transformer register:
             final ValueTransformer<?, ?> valueTransformer = GlobalValueTransformerRegistry.getValueTransformerForClass(
                     clazz);
             if (valueTransformer != null) {
                 fieldMapper = new ValueTransformerFieldMapper(valueTransformer);
                 .put(clazzfieldMapper);
             }
         }
 
         if (fieldMapper == null) {
             if (clazz.getEnumConstants() != null) {
                 fieldMapper = .get(Enum.class);
             }
         }
 
         return fieldMapper;
    }
New to GrepCode? Check out our FAQ X