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

de.larssh.json.dom.JsonDomXPathExpressions Maven / Gradle / Ivy

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

import static java.util.stream.Collectors.toList;
import java.util.List;
import java.util.Optional;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import de.larssh.json.dom.values.JsonDomValue;
import de.larssh.utils.dom.XPathExpressions;

/**
 * This class contains JSON DOM related helper methods for
 * {@link XPathExpression}.
 */
public final class JsonDomXPathExpressions {
	/**
	 * Evaluates the compiled XPath expression in the specified context and
	 * optionally returns a JSON element.
	 *
	 * 

* See the README.md file for a description of the JSON DOM hierarchy. * * @param implementation specific JSON element type * @param jsonDomValue the starting context * @param expression the XPath expression * @return evaluation result as optional {@code T} * @throws XPathExpressionException If the expression cannot be evaluated. */ public static Optional getJsonElement(final JsonDomValue jsonDomValue, final XPathExpression expression) throws XPathExpressionException { return XPathExpressions.>getNode(new JsonDomDocument<>(jsonDomValue), expression).map(JsonDomNode::getJsonElement); } /** * Evaluates the compiled XPath expression in the specified context and returns * a list of JSON elements. * *

* See the README.md file for a description of the JSON DOM hierarchy. * * @param implementation specific JSON element type * @param jsonDomValue the starting context * @param expression the XPath expression * @return evaluation result as list of {@code T} * @throws XPathExpressionException If the expression cannot be evaluated. */ public static List getJsonElementList(final JsonDomValue jsonDomValue, final XPathExpression expression) throws XPathExpressionException { return XPathExpressions.>getNodes(new JsonDomDocument<>(jsonDomValue), expression).stream().map(JsonDomNode::getJsonElement).collect(toList()); } @java.lang.SuppressWarnings("all") @edu.umd.cs.findbugs.annotations.SuppressFBWarnings(justification = "generated code") @lombok.Generated private JsonDomXPathExpressions() { throw new java.lang.UnsupportedOperationException("This is a utility class and cannot be instantiated"); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy