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

de.larssh.json.dom.children.JsonDomArrayChildren Maven / Gradle / Ivy

// Generated by delombok at Tue Jun 11 15:48:59 UTC 2024
package de.larssh.json.dom.children;

import static de.larssh.utils.Collectors.toLinkedHashMap;
import static java.util.function.Function.identity;
import java.util.ArrayList;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import de.larssh.json.dom.values.JsonDomValue;

/**
 * JSON DOM children of a JSON array.
 *
 * @param  {@link JsonDomValue} type
 */
public class JsonDomArrayChildren> extends ArrayList implements JsonDomChildren {
	/**
	 * Constructor that allows adding an initial amount of children while applying
	 * {@code jsonDomValueMapper} before.
	 *
	 * @param                 type of children before mapping to a
	 *                           {@link JsonDomValue} type
	 * @param initialCapacity    hint on the number of children to add
	 * @param children           children to apply {@code jsonDomValueMapper} and
	 *                           add
	 * @param jsonDomValueMapper mapper from any given type to a
	 *                           {@link JsonDomValue} type
	 */
	public  JsonDomArrayChildren(final int initialCapacity, final Iterable children, final Function jsonDomValueMapper) {
		super(initialCapacity);
		for (final V child : children) {
			add(jsonDomValueMapper.apply(child));
		}
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Set> entrySet() {
		final AtomicInteger index = new AtomicInteger(0);
		return stream().collect(toLinkedHashMap(element -> Integer.toString(index.getAndIncrement()), identity())).entrySet();
	}

	@java.lang.SuppressWarnings("all")
	@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(justification = "generated code")
	@lombok.Generated
	public JsonDomArrayChildren() {
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy