If you apply @DecimalMax annotation on a number, then the number must be lower or equal to the specified maximum.
What are the supported types?
a. byte,
b. short,
c. int,
d. long,
e. Byte,
f. Short,
g. Integer,
h. Long,
i. BigDecimal,
j. BigInteger,
k. CharSequence
Note: As per specification double, float is not supported due to rounding errors. Some providers may provide some approximative support
Where can I apply this annotation?
a. METHOD,
b. FIELD,
c. ANNOTATION_TYPE,
d. CONSTRUCTOR,
e. PARAMETER,
f. TYPE_USE
Find the below working application.
package com.sample.model;
import javax.validation.constraints.DecimalMax;
public class Employee {
@DecimalMax(value = "100000")
private int id;
private String name;
public Employee(int id, String name) {
this.id = id;
this.name = name;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
This post first appeared on Java Tutorial : Blog To Learn Java Programming, please read the originial post: here