All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.signalfx.shaded.fasterxml.jackson.databind.util.JacksonCollectors Maven / Gradle / Ivy

Go to download

Bare minimum core library needed to sending metrics to SignalFx from Java clients

The newest version!
package com.signalfx.shaded.fasterxml.jackson.databind.util;

import java.util.stream.Collector;

import com.signalfx.shaded.fasterxml.jackson.databind.JsonNode;
import com.signalfx.shaded.fasterxml.jackson.databind.node.ArrayNode;
import com.signalfx.shaded.fasterxml.jackson.databind.node.JsonNodeCreator;
import com.signalfx.shaded.fasterxml.jackson.databind.node.JsonNodeFactory;

/**
 * Utility class that provides custom {@link Collector} implementations to support Stream operations.
 * 

* This class is not meant to be instantiated and serves only as a utility class. *

* * @since 2.18 */ public abstract class JacksonCollectors { /** * Creates a {@link Collector} that collects {@link JsonNode} elements into an {@link ArrayNode}. *

* This method uses a {@link JsonNodeFactory} to create an empty {@link ArrayNode} and then adds each * {@link JsonNode} to it. *

*

* Short-cut to *{@code toArrayNode(JsonNodeFactory.instance}} * * @return a {@link Collector} that collects {@link JsonNode} elements into an {@link ArrayNode} */ public static Collector toArrayNode() { return toArrayNode(JsonNodeFactory.instance); } /** * Creates a {@link Collector} that collects {@link JsonNode} elements into an {@link ArrayNode}. *

* This method uses a {@link JsonNodeFactory} to create an empty {@link ArrayNode} and then adds each * {@link JsonNode} to it. *

* * @param nodeCreator Factory for constructing {@link ArrayNode} to contain nodes in * * @return a {@link Collector} that collects {@link JsonNode} elements into an {@link ArrayNode} */ public static Collector toArrayNode(JsonNodeCreator nodeCreator) { return Collector.of( nodeCreator::arrayNode, // supplier ArrayNode::add, // accumulator ArrayNode::addAll // combiner ); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy