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

org.resthub.web.validation.ModelConstraint Maven / Gradle / Ivy

There is a newer version: 2.2.0
Show newest version
package org.resthub.web.validation;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@JsonPropertyOrder(value = {"model", "constraints"})
public class ModelConstraint {

    private String modelRef;
    private Map> constraints;

    public ModelConstraint(String modelRef) {
        this.modelRef = modelRef;
    }

    @JsonProperty(value = "model")
    public String getModelRef() {
        return modelRef;
    }

    public void setModelRef(String modelRef) {
        this.modelRef = modelRef;
    }

    public Map> getConstraints() {
        return constraints;
    }

    public void setConstraints(Map> constraints) {
        this.constraints = constraints;
    }

    public List addConstraint(String property, ValidationConstraint constraint) {

        if (null == this.constraints) {
            this.constraints = new HashMap>();
        }

        List propertyConstraints = this.constraints.get(property);

        if (null == propertyConstraints) {
            propertyConstraints = new ArrayList();
        }

        propertyConstraints.add(constraint);

        return this.constraints.put(property, propertyConstraints);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy