BlueprintDto.java (2349B)
1 package com.wimdupont.swagger.blueprint.controller.dto; 2 3 import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 4 import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; 5 import com.wimdupont.swagger.blueprint.controller.dto.validation.ReadGroup; 6 import io.swagger.v3.oas.annotations.media.Schema; 7 import io.swagger.v3.oas.annotations.media.Schema.AccessMode; 8 import jakarta.validation.constraints.Min; 9 import jakarta.validation.constraints.NotNull; 10 11 import java.util.UUID; 12 13 @JsonDeserialize(builder = BlueprintDto.Builder.class) 14 public class BlueprintDto { 15 16 @NotNull(groups = ReadGroup.class) 17 @Schema(accessMode = AccessMode.READ_ONLY, 18 description = "Unique identifier of the blueprint", 19 example = "030e5b9d-b4ed-4900-af24-cb2eac570056") 20 private UUID id; 21 22 @NotNull 23 @Schema(description = "Name of the blueprint", 24 example = "blueprint-name") 25 private String name; 26 27 @Min(10) 28 @Schema(description = "Number of the blueprint", 29 example = "42") 30 private Integer number; 31 32 private BlueprintDto(Builder builder) { 33 setId(builder.id); 34 setName(builder.name); 35 setNumber(builder.number); 36 } 37 38 39 public UUID getId() { 40 return id; 41 } 42 43 public void setId(UUID id) { 44 this.id = id; 45 } 46 47 public String getName() { 48 return name; 49 } 50 51 public void setName(String name) { 52 this.name = name; 53 } 54 55 public Integer getNumber() { 56 return number; 57 } 58 59 public void setNumber(Integer number) { 60 this.number = number; 61 } 62 63 @JsonPOJOBuilder(withPrefix = "") 64 public static final class Builder { 65 private @NotNull UUID id; 66 private @NotNull String name; 67 private @Min(10) Integer number; 68 69 private Builder() { 70 } 71 72 public static Builder newBuilder() { 73 return new Builder(); 74 } 75 76 public Builder id(@NotNull UUID val) { 77 id = val; 78 return this; 79 } 80 81 public Builder name(@NotNull String val) { 82 name = val; 83 return this; 84 } 85 86 public Builder number(@Min(10) Integer val) { 87 number = val; 88 return this; 89 } 90 91 public BlueprintDto build() { 92 return new BlueprintDto(this); 93 } 94 } 95 }