/** * Builds {@link ObjectGenerator} based on current builder configuration. Resulting {@link ObjectGenerator} will * have {@code Map<String, Object>} as return type. * * @return Instance of {@link ObjectGenerator}. */ public ObjectGenerator<Map<String, Object>> build() { return new ObjectGenerator<>(new CompositeValue(propertyValues)); }
/** * Builds {@link ObjectGenerator} based on current builder configuration. Resulting {@link ObjectGenerator} will * have {@code Map<String, Object>} as return type. * * @return Instance of {@link ObjectGenerator}. */ public ObjectGenerator<Map<String, Object>> build() { return new ObjectGenerator<>(new CompositeValue(propertyValues)); }
@SuppressWarnings({ "rawtypes", "unchecked" }) private Value<?> parseCompositeValue(String parentName, Map<String, Object> def) { Map<String, Value<?>> values = new HashMap<>(); for (String property : def.keySet()) { String fullName = parentName + "." + property; Value<?> val = parse(fullName, def.get(property)); ValueProxy proxy = proxyValues.get(fullName); proxy.setDelegate(val); values.put(property, proxy); } return new CompositeValue(values); }
@SuppressWarnings({ "rawtypes", "unchecked" }) private Value<?> parseCompositeValue(String parentName, Map<String, Object> def) { Map<String, Value<?>> values = new HashMap<>(); for (String property : def.keySet()) { String fullName = parentName + "." + property; Value<?> val = parse(fullName, def.get(property)); ValueProxy proxy = proxyValues.get(fullName); proxy.setDelegate(val); values.put(property, proxy); } return new CompositeValue(values); }
/** * Builds {@link ObjectGenerator} based on current builder configuration. Resulting {@link ObjectGenerator} will try * to convert configured output to specified <code>objectType</code>. * * @param objectType Type of object to which conversion will be attempted. * @param objectMapper Object mapper which will be used for conversion. * @param <T> Type of object {@link ObjectGenerator} will generate. * @return Instance of {@link ObjectGenerator}. */ public <T> ObjectGenerator<T> build(Class<T> objectType, ObjectMapper objectMapper) { if (objectType == null) { throw new RuntimeException("objectType cannot be null."); } CompositeValue compositeValue = new CompositeValue(propertyValues); return new ObjectGenerator<T>(new TypeConverterValue<>(objectType, compositeValue, objectMapper)); }
/** * Builds {@link ObjectGenerator} based on current builder configuration. Resulting {@link ObjectGenerator} will try * to convert configured output to specified <code>objectType</code>. * * @param objectType Type of object to which conversion will be attempted. * @param objectMapper Object mapper which will be used for conversion. * @param <T> Type of object {@link ObjectGenerator} will generate. * @return Instance of {@link ObjectGenerator}. */ public <T> ObjectGenerator<T> build(Class<T> objectType, ObjectMapper objectMapper) { if (objectType == null) { throw new RuntimeException("objectType cannot be null."); } CompositeValue compositeValue = new CompositeValue(propertyValues); return new ObjectGenerator<T>(new TypeConverterValue<>(objectType, compositeValue, objectMapper)); }