I wouldnt put it in Configuration.of - would collide with formats no? I see
codec closer to values otherwise we laybe need to merge codec and formats.
But globally agree.
Le 18 déc. 2014 13:13, "Tresch, Anatole" <[email protected]>
a écrit :

> See inline...
>
>
>
> -----Original Message-----
> From: Romain Manni-Bucau [mailto:[email protected]]
> Sent: Donnerstag, 18. Dezember 2014 09:21
> To: [email protected]
> Subject: Re: UC: Configuration Injection (SE)
>
>
>
> using pseudo code to make it shorter:
>
>
>
> public class MyConfig {
>
>     @Config(...)
>
>     @Codec(deserializer = JSonDeserializer.class, serializer =
>
> JSonSerializer.class)
>
>      MySubConfig sub;
>
> }
>
>
>
> config could then be foo = {"a":"b",...} and MySubConfig = { String b;...
> }.
>
>
>
> Until now nothing needing all this stuff but now suppose I modify sub
>
> during app lifecycle, how do I store modifications?
>
>
>
> What I would avoid is to 100% rely on impls (ie I cast my Source and
>
> use its store method for instance).
>
>
>
> -> +1 if we want this feature to be offered, it should be supported by the
> API...
>
>
>
> Would be great to be symmetric :)
>
> -> I would also start think about how to include this feature as part of
> the API. My ideas currently are as follows
>
>
>
> 0) a Codec implements two functional interfaces: ConfigSerializer,
> ConfigDeserializer (or encoder/decoder? )
>
>
>
> 1) Offer creation of a Configuration using a Codec, e.g.
>
>
>
>   String jsonOrWhatever = ...;
>
>   Codec codec = ...;
>
>   Configuration config = Configuration.of(jsonOrWhatEver, codec); // takes
> a deserializer
>
>
>
> and with templates:
>
>
>
>   String jsonOrWhatever = ...;
>
>   Codec codec = ...;
>
>   Configuration config = codec.decode(jsonOrWhatEver); // takes a
> deserializer
>
>  MyConfig config = Configuration.of(MyConfig.class, config); // signature
> public static <T> T of(Class<T> template, Configuration... configs);
>
>
>
> and
>
>
>
>   Codec codec = ...;
>
>   Configuration config = ...;
>
>   String jsonOrWhatever = codec.encode(config);   // a serializer
>
> // or in addition, when serializer extends ConfigQuery<String>
>
>   String jsonOrWhatever = config.query(encoder);
>
>
>
>
>
> and
>
>
>
>   Codec codec = ...;
>
>   MyConfig config = ...;
>
>   String jsonOrWhatever = codec.encode(config);
>
>
>
> WDYT?
>
>
>
> Anatole
>
>
>
>
>

Reply via email to