package org.example.seed.domain;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.example.seed.catalog.ClientStatus;
import org.example.seed.constraint.Denomination;
import org.example.seed.group.chef.ChefCreateGroup;
import org.example.seed.group.chef.ChefUpdateGroup;
import org.example.seed.group.client.ClientCreateGroup;
import org.example.seed.group.client.ClientRegisterGroup;
import org.example.seed.group.client.ClientUpdateGroup;
import org.hibernate.validator.constraints.Email;

import javax.validation.Valid;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.UUID;

/**
 * Created by PINA on 26/06/2017.
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class Client extends Dates {

  @Size(min = 36, max = 36, groups = {ClientRegisterGroup.class, ClientUpdateGroup.class})
  @NotNull(groups = {ClientRegisterGroup.class, ClientUpdateGroup.class})
  private String id;

  @Email(groups = {ClientCreateGroup.class, ClientUpdateGroup.class})
  @Size(max = 45, groups = {ClientCreateGroup.class, ClientUpdateGroup.class})
  @NotNull(groups = {ClientCreateGroup.class, ClientUpdateGroup.class})
  private String email;

  @Denomination(groups = {ChefCreateGroup.class, ChefUpdateGroup.class})
  @Size(min = 2, max = 80, groups = {ClientCreateGroup.class, ClientUpdateGroup.class})
  @NotNull(groups = {ClientCreateGroup.class, ClientUpdateGroup.class})
  private String firstName;

  @Denomination(groups = {ChefCreateGroup.class, ChefUpdateGroup.class})
  @Size(min = 2, max = 80, groups = {ClientCreateGroup.class, ClientUpdateGroup.class})
  @NotNull(groups = {ClientCreateGroup.class, ClientUpdateGroup.class})
  private String lastName;

  @Min(value = 0, groups = {ClientCreateGroup.class, ClientUpdateGroup.class})
  @Max(value = 5, groups = {ClientCreateGroup.class, ClientUpdateGroup.class})
  private Float rating;

  @NotNull(groups = {ClientRegisterGroup.class, ClientUpdateGroup.class})
  private ClientStatus status;

  @Valid
  private Telephone telephone;

  public Client() {
    this.id = UUID.randomUUID().toString();
  }
}

@@ -179,112 +179,8 @@
 on;%0A
-import org.example.seed.group.chef.ChefCreateGroup;%0Aimport org.example.seed.group.chef.ChefUpdateGroup;%0A
 impo
@@ -467,139 +467,9 @@
 nts.
-Max;%0Aimport javax.validation.constraints.Min;%0Aimport javax.validation.constraints.NotNull;%0Aimport javax.validation.constraints.Size
+*
 ;%0Aim
@@ -834,32 +834,59 @@
 eateGroup.class,
+ ClientRegisterGroup.class,
  ClientUpdateGro
@@ -940,32 +940,59 @@
 eateGroup.class,
+ ClientRegisterGroup.class,
  ClientUpdateGro
@@ -1118,35 +1118,37 @@
 tion(groups = %7BC
-hef
+lient
 CreateGroup.clas
@@ -1143,35 +1143,64 @@
 teGroup.class, C
-hef
+lientRegisterGroup.class, Client
 UpdateGroup.clas
@@ -1256,32 +1256,59 @@
 eateGroup.class,
+ ClientRegisterGroup.class,
  ClientUpdateGro
@@ -1446,19 +1446,21 @@
 ups = %7BC
-hef
+lient
 CreateGr
@@ -1475,11 +1475,40 @@
 s, C
-hef
+lientRegisterGroup.class, Client
 Upda
@@ -1576,32 +1576,59 @@
 eateGroup.class,
+ ClientRegisterGroup.class,
  ClientUpdateGro
@@ -1738,16 +1738,273 @@
 tName;%0A%0A
+  @Null(groups = %7BClientCreateGroup.class, ClientUpdateGroup.class%7D)%0A  @NotNull(groups = %7BClientRegisterGroup.class%7D)%0A  @Size(min = 8, max = 16, groups = %7BClientRegisterGroup.class%7D)%0A  private String credential;%0A%0A  @Null(groups = %7BClientCreateGroup.class%7D)%0A
   @Min(v
@@ -2039,32 +2039,59 @@
 eateGroup.class,
+ ClientRegisterGroup.class,
  ClientUpdateGro
@@ -2145,32 +2145,59 @@
 eateGroup.class,
+ ClientRegisterGroup.class,
  ClientUpdateGro

remove bad constraint groups