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

com.github.ldeitos.validators.util.NodeBuilderCustomizableContextAdapter Maven / Gradle / Ivy

package com.github.ldeitos.validators.util;

import jakarta.validation.ConstraintValidatorContext.ConstraintViolationBuilder.NodeBuilderCustomizableContext;

public class NodeBuilderCustomizableContextAdapter implements ConstraintBuilderAdapter {
	private NodeBuilderCustomizableContext nBuilder;

	public NodeBuilderCustomizableContextAdapter(NodeBuilderCustomizableContext nBuilder) {
		this.nBuilder = nBuilder;
	}

	@Override
	public ConstraintBuilderAdapter addPropertyNode(Path path) {
		ConstraintBuilderAdapter result;
		nBuilder = nBuilder.addPropertyNode(path.getPath());

		if (path.isIterable()) {
			result = new IterablePropertyNodeContextAdapter(nBuilder).addPropertyNode(path);
		} else {
			result = new NodeBuilderCustomizableContextAdapter(nBuilder);
		}

		return result;
	}

	@Override
	public void addConstraintViolation() {
		if (nBuilder != null) {
			nBuilder.addConstraintViolation();
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy