If you annotate any Element with @AssertFalse annotation, then the annotated element must be false.
Supported Types
a. boolean
b. Boolean
Where can I apply this annotation?
a. METHOD,
b. FIELD,
c. ANNOTATION_TYPE,
d. CONSTRUCTOR,
e. PARAMETER,
f. TYPE_USE
package com.sample.model;
import javax.validation.constraints.AssertFalse;
public class Employee {
private int id;
@AssertFalse
private boolean isExperienced;
public Employee(int id, boolean isExperienced) {
this.id = id;
this.isExperienced = isExperienced;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public boolean isExperienced() {
return isExperienced;
}
public void setExperienced(boolean isExperienced) {
this.isExperienced = isExperienced;
}
}
This post first appeared on Java Tutorial : Blog To Learn Java Programming, please read the originial post: here