/** * Convenience method that "writes" given `value` as properties * in given {@link Properties} object. */ public void writeValue(Properties targetProps, Object value) throws IOException { if (targetProps == null) { throw new IllegalArgumentException("Can not pass null Properties as target"); } DefaultSerializerProvider prov = _serializerProvider(); JavaPropsGenerator g = tokenStreamFactory() .createGenerator(prov, targetProps); writeValue(g, value); g.close(); }
/** * Convenience method that "writes" given `value` as properties * in given {@link Properties} object. */ public void writeValue(Properties targetProps, Object value, JavaPropsSchema schema) throws IOException { if (targetProps == null) { throw new IllegalArgumentException("Can not pass null Properties as target"); } DefaultSerializerProvider prov = _serializerProvider(); JavaPropsGenerator g = tokenStreamFactory() .createGenerator(prov, 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. */ @SuppressWarnings("resource") public <T> T readPropertiesAs(Properties props, JavaPropsSchema schema, Class<T> valueType) throws IOException { DeserializationContext ctxt = createDeserializationContext(); JsonParser p = tokenStreamFactory().createParser(ctxt, 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. */ @SuppressWarnings({ "resource", "unchecked" }) public <T> T readPropertiesAs(Properties props, JavaPropsSchema schema, JavaType valueType) throws IOException { DeserializationContext ctxt = createDeserializationContext(); JsonParser p = tokenStreamFactory().createParser(ctxt, props); p.setSchema(schema); return (T) readValue(p, valueType); }