// Path: src/main/java/io/datanerds/avropatch/exception/InvalidReferenceTokenException.java
// public class InvalidReferenceTokenException extends AvroPatchException {
// 
//     public InvalidReferenceTokenException(String message) {
//         super(message);
//     }
// }


import io.datanerds.avropatch.exception.InvalidReferenceTokenException;
import javax.annotation.Generated;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;
        return new Path(parts.subList(parts.size() - 1, parts.size()));
    }

    public List<String> parts() {
        return parts;
    }

    public List<Path> subPaths() {
        if (parts.isEmpty()) {
            return Collections.emptyList();
        }

        List<Path> subPaths = new ArrayList<>();
        for (int i = 1; i <= parts.size(); i++) {
            subPaths.add(new Path(parts.subList(0, i)));
        }

        return subPaths;
    }

    private static Function<Path, Stream<String>> partsStream() {
        return path -> path.parts().stream();
    }

    private static Stream<String> validatedReferenceTokens(String[] referenceTokens) {
        return Stream.of(referenceTokens).map(Path::validateReferenceToken);
    }

    private static String validateReferenceToken(String path) {
        if (!VALID_PATTERN.matcher(path).matches()) {
// Path: src/main/java/io/datanerds/avropatch/exception/InvalidReferenceTokenException.java
// public class InvalidReferenceTokenException extends AvroPatchException {
// 
//     public InvalidReferenceTokenException(String message) {
//         super(message);
//     }
// }


// Path: src/main/java/io/datanerds/avropatch/operation/Path.java
import io.datanerds.avropatch.exception.InvalidReferenceTokenException;
import javax.annotation.Generated;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

        return new Path(parts.subList(parts.size() - 1, parts.size()));
    }

    public List<String> parts() {
        return parts;
    }

    public List<Path> subPaths() {
        if (parts.isEmpty()) {
            return Collections.emptyList();
        }

        List<Path> subPaths = new ArrayList<>();
        for (int i = 1; i <= parts.size(); i++) {
            subPaths.add(new Path(parts.subList(0, i)));
        }

        return subPaths;
    }

    private static Function<Path, Stream<String>> partsStream() {
        return path -> path.parts().stream();
    }

    private static Stream<String> validatedReferenceTokens(String[] referenceTokens) {
        return Stream.of(referenceTokens).map(Path::validateReferenceToken);
    }

    private static String validateReferenceToken(String path) {
        if (!VALID_PATTERN.matcher(path).matches()) {
            throw new InvalidReferenceTokenException(String.format("%s is not a valid JSON path", path));