World config and inventories
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package com.bernard.nodecames.util;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BinaryOperator;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collector;
|
||||
|
||||
import tools.jackson.databind.JsonNode;
|
||||
import tools.jackson.databind.node.ArrayNode;
|
||||
import tools.jackson.databind.node.JsonNodeFactory;
|
||||
|
||||
public class Utils {
|
||||
|
||||
private Utils() {}
|
||||
|
||||
public static final Collector<JsonNode,ArrayNode,ArrayNode> jsonNodeCollector(JsonNodeFactory jsn) {
|
||||
return new Collector<JsonNode,ArrayNode,ArrayNode>() {
|
||||
@Override
|
||||
public Supplier<ArrayNode> supplier() {
|
||||
return jsn::arrayNode;
|
||||
}
|
||||
@Override
|
||||
public BiConsumer<ArrayNode, JsonNode> accumulator() {
|
||||
return ArrayNode::add;
|
||||
}
|
||||
@Override
|
||||
public BinaryOperator<ArrayNode> combiner() {
|
||||
return (a,b) -> {
|
||||
a.addAll(b);
|
||||
return a;
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public Function<ArrayNode, ArrayNode> finisher() {
|
||||
return Function.identity();
|
||||
}
|
||||
@Override
|
||||
public Set<Characteristics> characteristics() {
|
||||
return EnumSet.of(Characteristics.IDENTITY_FINISH);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user