AddTeamsToProductAreaRequest.java

  1. package no.nav.data.team.po.dto;

  2. import lombok.AllArgsConstructor;
  3. import lombok.Builder;
  4. import lombok.Data;
  5. import lombok.NoArgsConstructor;
  6. import lombok.experimental.FieldNameConstants;
  7. import no.nav.data.common.utils.StreamUtils;
  8. import no.nav.data.common.validator.Validated;
  9. import no.nav.data.common.validator.Validator;

  10. import java.util.List;
  11. import java.util.UUID;

  12. @Data
  13. @Builder
  14. @NoArgsConstructor
  15. @AllArgsConstructor
  16. @FieldNameConstants
  17. public class AddTeamsToProductAreaRequest implements Validated {

  18.     private String productAreaId;
  19.     private List<String> teamIds;

  20.     @Override
  21.     public void format() {
  22.         setTeamIds(StreamUtils.nullToEmptyList(teamIds));
  23.     }

  24.     @Override
  25.     public void validateFieldValues(Validator<?> validator) {
  26.         validator.checkBlank(Fields.productAreaId, productAreaId);
  27.         validator.checkUUID(Fields.productAreaId, productAreaId);
  28.         teamIds.forEach(id -> validator.checkUUID(Fields.teamIds, id));
  29.     }

  30.     public UUID productAreaIdAsUUID() {
  31.         return productAreaId != null ? UUID.fromString(productAreaId) : null;
  32.     }
  33. }