Hi Peter, On 10/08/16 22:06, Peter Levart wrote:
static synchronized void add(Level l) { purge(); KnownLevel o = new KnownLevel(l); nameToLevels.computeIfAbsent(l.name, n -> new ArrayList<>()).add(o); intToLevels.computeIfAbsent(l.value, v -> new ArrayList<>()).add(o); }
I agree that's a much cleaner piece of code :-) However I purposefully stayed away from lambdas in KnownLevel.add because that will be called in the static initializer of the Level class (when creating standard levels) - and I didn't want to trigger the initialization of the lambda infrastructure too early. This may or may not be an issue any more though. best regards, -- daniel