de.zalando.sprocwrapper.validation.SimplePath Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zalando-sprocwrapper Show documentation
Show all versions of zalando-sprocwrapper Show documentation
Library to make PostgreSQL stored procedures available through simple Java "*SProcService" interfaces
including automatic object serialization and deserialization (using typemapper and
convention-over-configuration). Supports sharding, advisory locking, statement timeouts and PostgreSQL types
such as enums and hstore.
package de.zalando.sprocwrapper.validation;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import javax.validation.Path;
import com.google.common.base.Preconditions;
public class SimplePath implements Path {
public final List nodeList = new LinkedList();
public void addNode(final Path.Node node) {
nodeList.add(Preconditions.checkNotNull(node, "node"));
}
@Override
public Iterator iterator() {
return nodeList.iterator();
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("SimplePath [nodeList=");
builder.append(nodeList);
builder.append("]");
return builder.toString();
}
public static SimplePath createPathForMethodParameter(final Method method, final String parameterName) {
Preconditions.checkNotNull(method, "method");
Preconditions.checkNotNull(parameterName, "parameterName");
final StringBuilder builder = new StringBuilder(method.getDeclaringClass().getSimpleName());
builder.append("#").append(method.getName()).append("(").append(parameterName).append(")");
SimplePath path = new SimplePath();
path.addNode(new SimpleNode(builder.toString(), false, null, null));
return path;
}
}