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

io.vertx.up.uca.rs.regular.Ruler Maven / Gradle / Ivy

There is a newer version: 0.9.0
Show newest version
package io.vertx.up.uca.rs.regular;

import io.vertx.up.atom.Rule;
import io.vertx.up.exception.WebException;

import java.util.Collection;

public interface Ruler {
    /**
     * Verify each field for @BodyParam
     *
     * @param field
     * @param value
     * @param rule
     * @return
     */
    WebException verify(final String field,
                        final Object value,
                        final Rule rule);

    static Ruler get(final String type) {
        return Pool.RULERS.get(type);
    }

    static WebException verify(final Collection rules,
                               final String field,
                               final Object value) {
        WebException error = null;
        for (final Rule rule : rules) {
            final Ruler ruler = get(rule.getType());
            if (null != ruler) {
                error = ruler.verify(field, value, rule);
            }
            // Error found
            if (null != error) {
                break;
            }
        }
        return error;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy