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

com.github.loyada.jdollarx.PathOperators Maven / Gradle / Ivy

There is a newer version: 1.5.5
Show newest version
package com.github.loyada.jdollarx;


import java.util.Optional;

/**
 * Utilities to manipulate a {@link Path}
 */
public final class PathOperators {
    private PathOperators(){}


    /**
     * Any element that does NOT conform to the definition of the given path parameters
     * @param path - the path that represent what the element does NOT match
     * @return a new path that represents the negation of the given parameter
     */
    static public Path not(Path path) {
        if (!path.getXPath().isPresent()) throw new IllegalArgumentException();
        return BasicPath.builder().
                withXpath(String.format("*[not(self::%s)]", PathUtils.transformXpathToCorrectAxis(path).get())).
                withUnderlyingOptional(path.getUnderlyingSource()).
                withAlternateXpath(String.format("*[not(self::%s)]", path.getAlternateXPath().get())).
                withXpathExplanationOptional(Optional.of(String.format("anything except (%s)", path))).build();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy