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

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

Go to download

Easy Redis Java client and Real-Time Data Platform. Valkey compatible. Sync/Async/RxJava3/Reactive API. Client side caching. Over 50 Redis based Java objects and services: JCache API, Apache Tomcat, Hibernate, Spring, Set, Multimap, SortedSet, Map, List, Queue, Deque, Semaphore, Lock, AtomicLong, Map Reduce, Bloom filter, Scheduler, RPC

There is a newer version: 3.40.2
Show newest version
package com.fasterxml.jackson.databind.util;

import java.util.stream.Collector;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeCreator;
import com.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 - 2024 Weber Informatics LLC | Privacy Policy