/** * Convenience method that "writes" given `value` as properties * in given {@link Properties} object. * * @since 2.9 */ public void writeValue(Properties targetProps, Object value) throws IOException { if (targetProps == null) { throw new IllegalArgumentException("Can not pass null Properties as target"); } JavaPropsGenerator g = ((JavaPropsFactory) getFactory()) .createGenerator(targetProps); writeValue(g, value); g.close(); }
/** * Convenience method that "writes" given `value` as properties * in given {@link Properties} object. * * @since 2.9 */ public void writeValue(Properties targetProps, Object value, JavaPropsSchema schema) throws IOException { if (targetProps == null) { throw new IllegalArgumentException("Can not pass null Properties as target"); } JavaPropsGenerator g = ((JavaPropsFactory) getFactory()) .createGenerator(targetProps); if (schema != null) { g.setSchema(schema); } writeValue(g, value); g.close(); }
/** * Convenience method which uses given `Properties` as the source * as if they had been read from an external source, processes * them (splits paths etc), and then binds as given result * value. *<p> * Note that this is NOT identical to calling {@link #convertValue(Object, Class)}; * rather, it would be similar to writing `Properties` out into a File, * then calling `readValue()` on this mapper to bind contents. * * @since 2.9 */ @SuppressWarnings("resource") public <T> T readPropertiesAs(Properties props, JavaPropsSchema schema, Class<T> valueType) throws IOException { JsonParser p = getFactory().createParser(props); p.setSchema(schema); return (T) readValue(p, valueType); }
/** * Convenience method which uses given `Properties` as the source * as if they had been read from an external source, processes * them (splits paths etc), and then binds as given result * value. *<p> * Note that this is NOT identical to calling {@link #convertValue(Object, Class)}; * rather, it would be similar to writing `Properties` out into a File, * then calling `readValue()` on this mapper to bind contents. * * @since 2.9 */ @SuppressWarnings({ "resource", "unchecked" }) public <T> T readPropertiesAs(Properties props, JavaPropsSchema schema, JavaType valueType) throws IOException { JsonParser p = getFactory().createParser(props); p.setSchema(schema); return (T) readValue(p, valueType); }