org.hibernate.validator.internal.xml.ContainerElementTypePath Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bean-validator Show documentation
Show all versions of bean-validator Show documentation
JSR 380's RI, Hibernate Validator version ${hibernate-validator.version} and its dependencies repackaged as OSGi bundle
/*
* Hibernate Validator, declare and validate application constraints
*
* License: Apache License, Version 2.0
* See the license.txt file in the root directory or .
*/
package org.hibernate.validator.internal.xml;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.validator.internal.util.StringHelper;
/**
* The path to a container element type.
*
* @author Guillaume Smet
*/
public class ContainerElementTypePath {
private final List nodes;
private ContainerElementTypePath(List nodes) {
this.nodes = nodes;
}
public static ContainerElementTypePath root() {
return new ContainerElementTypePath( new ArrayList<>() );
}
public static ContainerElementTypePath of(ContainerElementTypePath parentPath, Integer typeArgumentIndex) {
List nodes = new ArrayList<>( parentPath.nodes );
nodes.add( typeArgumentIndex );
return new ContainerElementTypePath( nodes );
}
@Override
public boolean equals(Object obj) {
if ( this == obj ) {
return true;
}
if ( obj == null ) {
return false;
}
if ( getClass() != obj.getClass() ) {
return false;
}
ContainerElementTypePath other = (ContainerElementTypePath) obj;
if ( !this.nodes.equals( other.nodes ) ) {
return false;
}
return true;
}
@Override
public int hashCode() {
return nodes.hashCode();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append( "[" ).append( StringHelper.join( nodes, ", " ) ).append( "]" );
return sb.toString();
}
}