On 10/29/2012 05:20 PM, Tatu Saloranta wrote:We don't have a way to say that a feature is optional/cosmetic. May be that's something is needed.
On Mon, Oct 29, 2012 at 12:48 AM,>> JsonConfig config = new JsonConfig();
>> config.put(JsonConfiguration.CONFIG_DATE_FORMAT, "yyyy-MM-dd HH:mm:ss");
>> config.put(JsonConfiguration.CONFIG_PRETTY_PRINTING, true);
>> config.put("alibaba.json.cacheKeys", true);
>> config.put("alibaba.json.cacheKeys.threshold", 1024);
>> config.put("alibaba.json.threadLocalBufferCache", true);
>> config.put("alibaba.json.threadLocalBufferCache.size", 1024);
>> ... ...
if JsonFeature is interface, implementation will need to define a lot of
Types are cheap, why should this be a concern.
But I would expect that in most cases one would define an enum that
implements this interface.
I like the type-safety of an interface, as it removes the possibility of typos in feature names, but it also has its problems. Each implementation would probably define constants or an enum for the supported features. Now imagine a user wants to configure a non-standard feature which is supported by multiple implementations, but of course with different names. An example:
This would add a compile and runtime dependency on multiple implementations, which won't be needed with a string-based api. For an optional or cosmetic feature like in the example above it could still run with yet another implementation.
Given this problem, I think a map like api might be the better solution and should be familiar to anyone who has worked with JAXP before.
[json-processing-spec users] Re: JsonFeature interface - is it meant as a marker or constant?