/** * Creates an object from a value map. * * This does some special handling to take advantage of us using the value map so it avoids creating * a bunch of array objects and collections. Things you have to worry about when writing a * high-speed JSON serializer. * @param respectIgnore honor @JsonIgnore, transients, etc. of the field * @param view the view of the object which can ignore certain fields given certain views * @param fieldsAccessor how we are going to access the fields (by field, by property, combination) * @param cls the new type * @param ignoreSet a set of properties to ignore * @param valueMap value map * @param <T> type * @return new object from value map */ @SuppressWarnings("unchecked") public static <T> T fromValueMap( boolean respectIgnore, String view, final FieldsAccessor fieldsAccessor, final Map<String, Value> valueMap, final Class<T> cls, Set<String> ignoreSet ) { Mapper mapper = new MapperComplex(fieldsAccessor, ignoreSet, view, respectIgnore); return mapper.fromValueMap(valueMap, cls); }
/** * Creates an object from a value map. * * This does some special handling to take advantage of us using the value map so it avoids creating * a bunch of array objects and collections. Things you have to worry about when writing a * high-speed JSON serializer. * @param respectIgnore honor @JsonIgnore, transients, etc. of the field * @param view the view of the object which can ignore certain fields given certain views * @param fieldsAccessor how we are going to access the fields (by field, by property, combination) * @param cls the new type * @param ignoreSet a set of properties to ignore * @param valueMap value map * @param <T> type * @return new object from value map */ @SuppressWarnings("unchecked") public static <T> T fromValueMap( boolean respectIgnore, String view, final FieldsAccessor fieldsAccessor, final Map<String, Value> valueMap, final Class<T> cls, Set<String> ignoreSet ) { Mapper mapper = new MapperComplex(fieldsAccessor, ignoreSet, view, respectIgnore); return mapper.fromValueMap(valueMap, cls); }
private <T> T finalExtract( Class<T> type, Object object ) { if (object instanceof Map ) { Map<String, Value> objectMap = ( Map<String, Value> ) object; return mapper.fromValueMap( objectMap, type ); } if (object instanceof ValueContainer) { object = ((ValueContainer) object).toValue(); } if (object instanceof List ) { List<Object> list = ( List<Object> ) object; return MapObjectConversion.fromList ( list, type ); } else { return (T)object; } }
private <T> T finalExtract( Class<T> type, Object object ) { if (object instanceof Map ) { Map<String, Value> objectMap = ( Map<String, Value> ) object; return mapper.fromValueMap( objectMap, type ); } if (object instanceof ValueContainer) { object = ((ValueContainer) object).toValue(); } if (object instanceof List ) { List<Object> list = ( List<Object> ) object; return MapObjectConversion.fromList ( list, type ); } else { return (T)object; } }
private <T> T finalExtract( Class<T> type, Object object ) { if (object instanceof Map ) { Map<String, Value> objectMap = ( Map<String, Value> ) object; return mapper.fromValueMap( objectMap, type ); } if (object instanceof ValueContainer) { object = ((ValueContainer) object).toValue(); } if (object instanceof List ) { List<Object> list = ( List<Object> ) object; return MapObjectConversion.fromList ( list, type ); } else { return (T)object; } }
protected final <T> T convert( Class<T> clz, Object object ) { if (object == null ) { return null; } TypeType coerceTo = TypeType.getType(clz); switch ( coerceTo ) { case MAP: case LIST: case OBJECT: return (T)object; } TypeType coerceFrom = TypeType.getType(object.getClass()); switch ( coerceFrom ) { case VALUE_MAP: return mapper.fromValueMap( ( Map<String, Value> ) object, clz ); case MAP: return mapper.fromMap ( ( Map<String, Object> ) object, clz ); case VALUE: return (T)( (Value) object).toValue (); case LIST: return (T) mapper.convertListOfMapsToObjects( (List<Map>)object, clz); default: if ( Typ.isBasicTypeOrCollection(clz) ) { return Conversions.coerce(coerceTo, clz, object); } else { return (T)object; } } }
protected final <T> T convert( Class<T> clz, Object object ) { if (object == null ) { return null; } TypeType coerceTo = TypeType.getType(clz); switch ( coerceTo ) { case MAP: case LIST: case OBJECT: return (T)object; } TypeType coerceFrom = TypeType.getType(object.getClass()); switch ( coerceFrom ) { case VALUE_MAP: return mapper.fromValueMap( ( Map<String, Value> ) object, clz ); case MAP: return mapper.fromMap ( ( Map<String, Object> ) object, clz ); case VALUE: return (T)( (Value) object).toValue (); case LIST: return (T) mapper.convertListOfMapsToObjects( (List<Map>)object, clz); default: if ( Typ.isBasicTypeOrCollection(clz) ) { return Conversions.coerce(coerceTo, clz, object); } else { return (T)object; } } }
protected final <T> T convert( Class<T> clz, Object object ) { if (object == null ) { return null; } TypeType coerceTo = TypeType.getType(clz); switch ( coerceTo ) { case MAP: case LIST: case OBJECT: return (T)object; } TypeType coerceFrom = TypeType.getType(object.getClass()); switch ( coerceFrom ) { case VALUE_MAP: return mapper.fromValueMap( ( Map<String, Value> ) object, clz ); case MAP: return mapper.fromMap ( ( Map<String, Object> ) object, clz ); case VALUE: return (T)( (Value) object).toValue (); case LIST: return (T) mapper.convertListOfMapsToObjects( (List<Map>)object, clz); default: if ( Typ.isBasicTypeOrCollection(clz) ) { return Conversions.coerce(coerceTo, clz, object); } else { return (T)object; } } }