org.resthub.web.validation.ModelConstraint Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of resthub-web-server Show documentation
Show all versions of resthub-web-server Show documentation
RESThub support for REST webservices based on Spring MVC
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);
}
}