/** * From map. * @param map map to create the object from. * @param clazz the new instance type * @param <T> generic type capture * @return new object */ @SuppressWarnings( "unchecked" ) public static <T> T fromMap( Map<String, Object> map, Class<T> clazz ) { return mapper.fromMap(map, clazz); }
/** * fromMap converts a map into a Java object. * This version will see if there is a class parameter in the map, and dies if there is not. * @param map map to create the object from. * @return new object */ public static Object fromMap( Map<String, Object> map ) { return mapper.fromMap(map); }
/** * From map. * @param map map to create the object from. * @param clazz the new instance type * @param <T> generic type capture * @return new object */ @SuppressWarnings( "unchecked" ) public static <T> T fromMap( Map<String, Object> map, Class<T> clazz ) { return mapper.fromMap(map, clazz); }
/** * fromMap converts a map into a Java object. * This version will see if there is a class parameter in the map, and dies if there is not. * @param map map to create the object from. * @return new object */ public static Object fromMap( Map<String, Object> map ) { return mapper.fromMap(map); }
/** * fromMap converts a map into a java object * @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 map map to create the object from. * @param cls class type of new object * @param ignoreSet a set of properties to ignore * @param <T> map to create teh object from. * @return new object of type cls */ @SuppressWarnings("unchecked") public static <T> T fromMap( boolean respectIgnore, String view, FieldsAccessor fieldsAccessor, Map<String, Object> map, Class<T> cls, Set<String> ignoreSet ) { Mapper mapper = new MapperComplex(ignoreSet, view, respectIgnore); return mapper.fromMap(map, cls); }
/** * fromMap converts a map into a java object * @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 map map to create the object from. * @param cls class type of new object * @param ignoreSet a set of properties to ignore * @param <T> map to create teh object from. * @return new object of type cls */ @SuppressWarnings("unchecked") public static <T> T fromMap( boolean respectIgnore, String view, FieldsAccessor fieldsAccessor, Map<String, Object> map, Class<T> cls, Set<String> ignoreSet ) { Mapper mapper = new MapperComplex(ignoreSet, view, respectIgnore); return mapper.fromMap(map, cls); }
@Override @SuppressWarnings("unchecked") public <T> T get(String path, Class<T> type) { final Object value = validatePath(path); if (type.isAssignableFrom(value.getClass())) { return (T) value; } else if (value instanceof Map) { final Map<String, Object> map = getMap(path); return mapper.fromMap(map, type); } else { return Conversions.coerce(type, value); } }
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; } } }