@Override protected Mapper initialValue() { /** * MapperComplex(FieldAccessMode fieldAccessType, boolean useAnnotations, boolean caseInsensitiveFields, Set<String> ignoreSet, String view, boolean respectIgnore, boolean acceptSingleValueAsArray) { fieldsAccessor = FieldAccessMode.create( fieldAccessType, useAnnotations, caseInsensitiveFields ); this.ignoreSet = ignoreSet; this.view = view; this.respectIgnore = respectIgnore; this.acceptSingleValueAsArray = acceptSingleValueAsArray; this.outputType = true; } */ return new MapperComplex(false, FieldAccessMode.PROPERTY_THEN_FIELD, true, false, Collections.emptySet(), null, true, true); } };
@Override protected Mapper initialValue() { /** * MapperComplex(FieldAccessMode fieldAccessType, boolean useAnnotations, boolean caseInsensitiveFields, Set<String> ignoreSet, String view, boolean respectIgnore, boolean acceptSingleValueAsArray) { fieldsAccessor = FieldAccessMode.create( fieldAccessType, useAnnotations, caseInsensitiveFields ); this.ignoreSet = ignoreSet; this.view = view; this.respectIgnore = respectIgnore; this.acceptSingleValueAsArray = acceptSingleValueAsArray; this.outputType = true; } */ return new MapperComplex(false, FieldAccessMode.PROPERTY_THEN_FIELD, true, false, Collections.emptySet(), null, true, true); } };
@Override protected Mapper initialValue() { /** * MapperComplex(FieldAccessMode fieldAccessType, boolean useAnnotations, boolean caseInsensitiveFields, Set<String> ignoreSet, String view, boolean respectIgnore, boolean acceptSingleValueAsArray) { fieldsAccessor = FieldAccessMode.create( fieldAccessType, useAnnotations, caseInsensitiveFields ); this.ignoreSet = ignoreSet; this.view = view; this.respectIgnore = respectIgnore; this.acceptSingleValueAsArray = acceptSingleValueAsArray; this.outputType = true; } */ return new MapperComplex(false, FieldAccessMode.PROPERTY_THEN_FIELD, true, false, Collections.emptySet(), null, true, true); } };
/** * This could be refactored to use core.TypeType class and it would run faster. * Converts an object into a map * @param object the object that we want to convert * @param ignore the map * @return map map representation of the object */ public static Map<String, Object> toMap( final Object object, Set<String> ignore ) { return new MapperComplex(ignore).toMap(object); }
/** * This could be refactored to use core.TypeType class and it would run faster. * Converts an object into a map * @param object the object that we want to convert * @param ignore the map * @return map map representation of the object */ public static Map<String, Object> toMap( final Object object, Set<String> ignore ) { return new MapperComplex(ignore).toMap(object); }
/** * 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); }
/** Convert an item from a list into a class using the classes constructor. * * REFACTOR: Can't this just be from collection? * REFACTOR * * @param fieldsAccessor how we are going to access the fields (by field, by property, combination) * @param argList list if arguments * @param clazz the type of the object we are creating * @param <T> generics * @return the new object that we just created. */ public static <T> T fromList( FieldsAccessor fieldsAccessor, List<?> argList, Class<T> clazz ) { return new MapperComplex(fieldsAccessor, null, null, false).fromList(argList, clazz); }
/** Convert an item from a list into a class using the classes constructor. * * REFACTOR: Can't this just be from collection? * REFACTOR * * @param fieldsAccessor how we are going to access the fields (by field, by property, combination) * @param argList list if arguments * @param clazz the type of the object we are creating * @param <T> generics * @return the new object that we just created. */ public static <T> T fromList( FieldsAccessor fieldsAccessor, List<?> argList, Class<T> clazz ) { return new MapperComplex(fieldsAccessor, null, null, false).fromList(argList, clazz); }
/** * 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); }
/** Convert an item from a list into a class using the classes constructor. * * REFACTOR: Can't this just be from collection? * REFACTOR * * @param respectIgnore honor @JsonIgnore, transients, etc. of the field * @param view honor views for fields * @param fieldsAccessor how we are going to access the fields (by field, by property, combination) * @param argList list if arguments * @param clazz the type of the object we are creating * @param ignoreSet a set of properties to ignore * @param <T> generics * @return the new object that we just created. */ public static <T> T fromList( boolean respectIgnore, String view, FieldsAccessor fieldsAccessor, List<?> argList, Class<T> clazz, Set<String> ignoreSet ) { return new MapperComplex(fieldsAccessor, ignoreSet, view, respectIgnore).fromList(argList, clazz); }
/** * This converts a list of maps to objects. * I always forget that this exists. I need to remember. * * @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 componentType The component type of the created list * @param list the input list * @param ignoreProperties properties to ignore * @param <T> generics * @return a new list */ public static <T> List<T> convertListOfMapsToObjects( boolean respectIgnore, String view, FieldsAccessor fieldsAccessor, Class<T> componentType, List<Map> list, Set<String> ignoreProperties) { return new MapperComplex(fieldsAccessor, ignoreProperties,view, respectIgnore).convertListOfMapsToObjects(list, componentType); }
/** * This converts a list of maps to objects. * I always forget that this exists. I need to remember. * * @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 componentType The component type of the created list * @param list the input list * @param ignoreProperties properties to ignore * @param <T> generics * @return a new list */ public static <T> List<T> convertListOfMapsToObjects( boolean respectIgnore, String view, FieldsAccessor fieldsAccessor, Class<T> componentType, List<Map> list, Set<String> ignoreProperties) { return new MapperComplex(fieldsAccessor, ignoreProperties,view, respectIgnore).convertListOfMapsToObjects(list, componentType); }
/** Convert an item from a list into a class using the classes constructor. * * REFACTOR: Can't this just be from collection? * REFACTOR * * @param respectIgnore honor @JsonIgnore, transients, etc. of the field * @param view honor views for fields * @param fieldsAccessor how we are going to access the fields (by field, by property, combination) * @param argList list if arguments * @param clazz the type of the object we are creating * @param ignoreSet a set of properties to ignore * @param <T> generics * @return the new object that we just created. */ public static <T> T fromList( boolean respectIgnore, String view, FieldsAccessor fieldsAccessor, List<?> argList, Class<T> clazz, Set<String> ignoreSet ) { return new MapperComplex(fieldsAccessor, ignoreSet, view, respectIgnore).fromList(argList, clazz); }
/** * 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); }
/** * fromMap converts a map into a java object. * @param map map to create the object from. * @param clazz the new instance type * @param excludeProperties the properties to exclude * @param <T> generic type capture * @return the new object */ @SuppressWarnings( "unchecked" ) public static <T> T fromMap( Map<String, Object> map, Class<T> clazz, String... excludeProperties ) { Set<String> ignoreProps = excludeProperties.length > 0 ? Sets.set(excludeProperties) : null; return new MapperComplex(FieldAccessMode.FIELD_THEN_PROPERTY.create( false ), ignoreProps, null, true).fromMap(map, clazz); }
private Mapper createMapper() { if (useAnnotations && !caseInsensitiveFields && !acceptSingleValueAsArray && ignoreSet == null && Str.isEmpty(view) && respectIgnore) { return new MapperSimple(fieldAccessType.create(true)); } return new MapperComplex(fieldAccessType, useAnnotations, caseInsensitiveFields, ignoreSet, view, respectIgnore, acceptSingleValueAsArray); }
private Mapper createMapper() { if (useAnnotations && !caseInsensitiveFields && !acceptSingleValueAsArray && ignoreSet == null && Str.isEmpty(view) && respectIgnore) { return new MapperSimple(fieldAccessType.create(true)); } return new MapperComplex(fieldAccessType, useAnnotations, caseInsensitiveFields, ignoreSet, view, respectIgnore, acceptSingleValueAsArray); }
private Mapper createMapper() { if (useAnnotations && !caseInsensitiveFields && !acceptSingleValueAsArray && ignoreSet == null && Str.isEmpty(view) && respectIgnore) { return new MapperSimple(fieldAccessType.create(true)); } return new MapperComplex(fieldAccessType, useAnnotations, caseInsensitiveFields, ignoreSet, view, respectIgnore, acceptSingleValueAsArray); }
/** * fromMap converts a map into a java object. * @param map map to create the object from. * @param clazz the new instance type * @param excludeProperties the properties to exclude * @param <T> generic type capture * @return the new object */ @SuppressWarnings( "unchecked" ) public static <T> T fromMap( Map<String, Object> map, Class<T> clazz, String... excludeProperties ) { Set<String> ignoreProps = excludeProperties.length > 0 ? Sets.set(excludeProperties) : null; return new MapperComplex(FieldAccessMode.FIELD_THEN_PROPERTY.create( false ), ignoreProps, null, true).fromMap(map, clazz); }