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

de.zalando.sprocwrapper.validation.SimplePath Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 2.0.0
Show newest version
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;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy