Reformatting code of javaxval before starting on [BAEL-3306]
This commit is contained in:
parent
0ba79b88b4
commit
76e0fe4642
|
@ -10,16 +10,16 @@ import javax.validation.constraints.PositiveOrZero;
|
|||
|
||||
public class Customer {
|
||||
|
||||
@NotBlank(message="Name cannot be empty")
|
||||
@NotBlank(message = "Name cannot be empty")
|
||||
private String name;
|
||||
|
||||
private List<@NotBlank(message="Address must not be blank") String> addresses;
|
||||
|
||||
private List<@NotBlank(message = "Address must not be blank") String> addresses;
|
||||
|
||||
private Integer age;
|
||||
|
||||
|
||||
@PositiveOrZero
|
||||
private OptionalInt numberOfOrders;
|
||||
|
||||
|
||||
//@NotBlank
|
||||
private Profile profile;
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ import javax.validation.constraints.Email;
|
|||
import javax.validation.constraints.NotNull;
|
||||
|
||||
public class CustomerMap {
|
||||
|
||||
private Map<@Email(message="Must be a valid email") String, @NotNull Customer> customers;
|
||||
|
||||
private Map<@Email(message = "Must be a valid email") String, @NotNull Customer> customers;
|
||||
|
||||
public Map<String, Customer> getCustomers() {
|
||||
return customers;
|
||||
|
|
|
@ -6,9 +6,9 @@ import org.baeldung.javabeanconstraints.entities.UserNotBlank;
|
|||
|
||||
public class Application {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
public static void main(String[] args) {
|
||||
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
|
||||
UserNotBlank user = new UserNotBlank(" ");
|
||||
validator.validate(user).stream().forEach(violation -> System.out.println(violation.getMessage()));
|
||||
validator.validate(user).stream().forEach(violation -> System.out.println(violation.getMessage()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,14 +6,14 @@ import javax.validation.constraints.DecimalMin;
|
|||
import javax.validation.constraints.Digits;
|
||||
|
||||
public class Invoice {
|
||||
|
||||
@DecimalMin(value = "0.0", inclusive = false)
|
||||
@Digits(integer=3, fraction=2)
|
||||
|
||||
@DecimalMin(value = "0.0", inclusive = false)
|
||||
@Digits(integer = 3, fraction = 2)
|
||||
private BigDecimal price;
|
||||
private String description;
|
||||
|
||||
public Invoice(BigDecimal price, String description) {
|
||||
this.price = price;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Invoice(BigDecimal price, String description) {
|
||||
this.price = price;
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,15 +6,15 @@ public class UserNotBlank {
|
|||
|
||||
@NotBlank(message = "Name is mandatory")
|
||||
private final String name;
|
||||
|
||||
|
||||
public UserNotBlank(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User{" + "name=" + name + "}";
|
||||
|
|
|
@ -3,18 +3,18 @@ package org.baeldung.javabeanconstraints.entities;
|
|||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
public class UserNotEmpty {
|
||||
|
||||
|
||||
@NotEmpty(message = "Name is mandatory")
|
||||
private final String name;
|
||||
|
||||
|
||||
public UserNotEmpty(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User{" + "name=" + name + "}";
|
||||
|
|
|
@ -3,18 +3,18 @@ package org.baeldung.javabeanconstraints.entities;
|
|||
import javax.validation.constraints.NotNull;
|
||||
|
||||
public class UserNotNull {
|
||||
|
||||
|
||||
@NotNull(message = "Name is mandatory")
|
||||
private final String name;
|
||||
|
||||
|
||||
public UserNotNull(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User{" + "name=" + name + "}";
|
||||
|
|
|
@ -4,107 +4,107 @@ import javax.validation.constraints.Email;
|
|||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
public class RegistrationForm {
|
||||
@NotBlank(groups = BasicInfo.class)
|
||||
private String firstName;
|
||||
@NotBlank(groups = BasicInfo.class)
|
||||
private String lastName;
|
||||
@Email(groups = BasicInfo.class)
|
||||
private String email;
|
||||
@NotBlank(groups = BasicInfo.class)
|
||||
private String phone;
|
||||
@NotBlank(groups = BasicInfo.class)
|
||||
private String firstName;
|
||||
@NotBlank(groups = BasicInfo.class)
|
||||
private String lastName;
|
||||
@Email(groups = BasicInfo.class)
|
||||
private String email;
|
||||
@NotBlank(groups = BasicInfo.class)
|
||||
private String phone;
|
||||
|
||||
@NotBlank(groups = { BasicInfo.class, AdvanceInfo.class })
|
||||
private String captcha;
|
||||
@NotBlank(groups = {BasicInfo.class, AdvanceInfo.class})
|
||||
private String captcha;
|
||||
|
||||
@NotBlank(groups = AdvanceInfo.class)
|
||||
private String street;
|
||||
@NotBlank(groups = AdvanceInfo.class)
|
||||
private String houseNumber;
|
||||
@NotBlank(groups = AdvanceInfo.class)
|
||||
private String zipCode;
|
||||
@NotBlank(groups = AdvanceInfo.class)
|
||||
private String city;
|
||||
@NotBlank(groups = AdvanceInfo.class)
|
||||
private String contry;
|
||||
@NotBlank(groups = AdvanceInfo.class)
|
||||
private String street;
|
||||
@NotBlank(groups = AdvanceInfo.class)
|
||||
private String houseNumber;
|
||||
@NotBlank(groups = AdvanceInfo.class)
|
||||
private String zipCode;
|
||||
@NotBlank(groups = AdvanceInfo.class)
|
||||
private String city;
|
||||
@NotBlank(groups = AdvanceInfo.class)
|
||||
private String contry;
|
||||
|
||||
public String getStreet() {
|
||||
return street;
|
||||
}
|
||||
public String getStreet() {
|
||||
return street;
|
||||
}
|
||||
|
||||
public void setStreet(String street) {
|
||||
this.street = street;
|
||||
}
|
||||
public void setStreet(String street) {
|
||||
this.street = street;
|
||||
}
|
||||
|
||||
public String getHouseNumber() {
|
||||
return houseNumber;
|
||||
}
|
||||
public String getHouseNumber() {
|
||||
return houseNumber;
|
||||
}
|
||||
|
||||
public void setHouseNumber(String houseNumber) {
|
||||
this.houseNumber = houseNumber;
|
||||
}
|
||||
public void setHouseNumber(String houseNumber) {
|
||||
this.houseNumber = houseNumber;
|
||||
}
|
||||
|
||||
public String getZipCode() {
|
||||
return zipCode;
|
||||
}
|
||||
public String getZipCode() {
|
||||
return zipCode;
|
||||
}
|
||||
|
||||
public void setZipCode(String zipCode) {
|
||||
this.zipCode = zipCode;
|
||||
}
|
||||
public void setZipCode(String zipCode) {
|
||||
this.zipCode = zipCode;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getContry() {
|
||||
return contry;
|
||||
}
|
||||
public String getContry() {
|
||||
return contry;
|
||||
}
|
||||
|
||||
public void setContry(String contry) {
|
||||
this.contry = contry;
|
||||
}
|
||||
public void setContry(String contry) {
|
||||
this.contry = contry;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getCaptcha() {
|
||||
return captcha;
|
||||
}
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public void setCaptcha(String captcha) {
|
||||
this.captcha = captcha;
|
||||
}
|
||||
public String getCaptcha() {
|
||||
return captcha;
|
||||
}
|
||||
|
||||
public void setCaptcha(String captcha) {
|
||||
this.captcha = captcha;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,10 +8,10 @@ import javax.validation.constraints.AssertTrue;
|
|||
import javax.validation.constraints.Email;
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Past;
|
||||
import javax.validation.constraints.Size;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
public class User {
|
||||
|
||||
|
@ -30,9 +30,9 @@ public class User {
|
|||
|
||||
@Email(message = "Email should be valid")
|
||||
private String email;
|
||||
|
||||
List<@NotBlank String> preferences;
|
||||
|
||||
|
||||
private List<@NotBlank String> preferences;
|
||||
|
||||
private LocalDate dateOfBirth;
|
||||
|
||||
public int getAge() {
|
||||
|
@ -90,5 +90,4 @@ public class User {
|
|||
public void setPreferences(List<String> preferences) {
|
||||
this.preferences = preferences;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,9 +24,9 @@ public class ValidReservationValidator implements ConstraintValidator<ValidReser
|
|||
}
|
||||
|
||||
return (reservation.getBegin()
|
||||
.isAfter(LocalDate.now())
|
||||
&& reservation.getBegin()
|
||||
.isAfter(LocalDate.now())
|
||||
&& reservation.getBegin()
|
||||
.isBefore(reservation.getEnd())
|
||||
&& reservation.getRoom() > 0);
|
||||
&& reservation.getRoom() > 0);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue