package com.airlock.iam.admin.infrastructure.transfer.request.techclient;

import com.airlock.iam.base.infrastructure.validation.MinOptionalValue;
import com.airlock.iam.base.infrastructure.validation.NotNullOptionalValue;
import com.airlock.iam.base.infrastructure.validation.PatternOptionalString;
import com.airlock.iam.base.infrastructure.validation.SizeOptionalString;
import com.airlock.iam.base.misc.data.OptionalString;
import com.airlock.iam.base.misc.data.OptionalValue;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.swagger.v3.oas.annotations.media.Schema;

@JsonTypeName("plan-usage")
@JsonDeserialize(builder = PlanUsageUpdateRequest.PlanUsageUpdateRequestJsonBuilder.class)
@JsonInclude(Include.NON_EMPTY)
public final class PlanUsageUpdateRequest {
   @SizeOptionalString(min = 1, max = 100)
   @NotNullOptionalValue
   @PatternOptionalString(regexp = "[A-Za-z0-9_-]+")
   @Schema(
      type = "string",
      nullable = true,
      minLength = 1,
      maxLength = 100,
      description = "Name of the Plan-Usage. The name must be unique within the subscription and must be between 1 and 100 characters. Valid characters are [A-Za-z0-9_-]."
   )
   private OptionalString name;
   public static final String NAME_FIELD = "name";
   @MinOptionalValue(0L)
   @Schema(nullable = true, type = "integer", description = "Rate limit of the Plan-Usage (requests / second).")
   private OptionalValue<Integer> rateLimit;

   private PlanUsageUpdateRequest() {
      this.name = OptionalString.none();
      this.rateLimit = OptionalValue.none();
   }

   public static PlanUsageUpdateRequest.PlanUsageUpdateRequestBuilder builder() {
      return new PlanUsageUpdateRequest().toBuilder();
   }

   @SuppressFBWarnings(justification = "generated code")
   public PlanUsageUpdateRequest.PlanUsageUpdateRequestBuilder toBuilder() {
      return new PlanUsageUpdateRequest.PlanUsageUpdateRequestBuilder().name(this.name).rateLimit(this.rateLimit);
   }

   @SuppressFBWarnings(justification = "generated code")
   public OptionalString getName() {
      return this.name;
   }

   @SuppressFBWarnings(justification = "generated code")
   public OptionalValue<Integer> getRateLimit() {
      return this.rateLimit;
   }

   @SuppressFBWarnings(justification = "generated code")
   public void setName(OptionalString name) {
      this.name = name;
   }

   @SuppressFBWarnings(justification = "generated code")
   public void setRateLimit(OptionalValue<Integer> rateLimit) {
      this.rateLimit = rateLimit;
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public boolean equals(Object o) {
      if (o == this) {
         return true;
      } else if (!(o instanceof PlanUsageUpdateRequest other)) {
         return false;
      } else {
         Object this$name = this.name;
         Object other$name = other.name;
         if (this$name == null ? other$name == null : this$name.equals(other$name)) {
            Object this$rateLimit = this.rateLimit;
            Object other$rateLimit = other.rateLimit;
            return this$rateLimit == null ? other$rateLimit == null : this$rateLimit.equals(other$rateLimit);
         } else {
            return false;
         }
      }
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public int hashCode() {
      int PRIME = 59;
      int result = 1;
      Object $name = this.name;
      result = result * 59 + ($name == null ? 43 : $name.hashCode());
      Object $rateLimit = this.rateLimit;
      return result * 59 + ($rateLimit == null ? 43 : $rateLimit.hashCode());
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "PlanUsageUpdateRequest(name=" + this.getName() + ", rateLimit=" + this.getRateLimit() + ")";
   }

   @SuppressFBWarnings(justification = "generated code")
   public PlanUsageUpdateRequest(OptionalString name, OptionalValue<Integer> rateLimit) {
      this.name = name;
      this.rateLimit = rateLimit;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class PlanUsageUpdateRequestBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private OptionalString name;
      @SuppressFBWarnings(justification = "generated code")
      private OptionalValue<Integer> rateLimit;

      @SuppressFBWarnings(justification = "generated code")
      PlanUsageUpdateRequestBuilder() {
      }

      @SuppressFBWarnings(justification = "generated code")
      public PlanUsageUpdateRequest.PlanUsageUpdateRequestBuilder name(OptionalString name) {
         this.name = name;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public PlanUsageUpdateRequest.PlanUsageUpdateRequestBuilder rateLimit(OptionalValue<Integer> rateLimit) {
         this.rateLimit = rateLimit;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public PlanUsageUpdateRequest build() {
         return new PlanUsageUpdateRequest(this.name, this.rateLimit);
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "PlanUsageUpdateRequest.PlanUsageUpdateRequestBuilder(name=" + this.name + ", rateLimit=" + this.rateLimit + ")";
      }
   }

   @JsonPOJOBuilder(withPrefix = "")
   public static class PlanUsageUpdateRequestJsonBuilder {
      private final PlanUsageUpdateRequest.PlanUsageUpdateRequestBuilder builder = PlanUsageUpdateRequest.builder();

      public PlanUsageUpdateRequest.PlanUsageUpdateRequestJsonBuilder name(String name) {
         this.builder.name(OptionalString.of(name));
         return this;
      }

      public PlanUsageUpdateRequest.PlanUsageUpdateRequestJsonBuilder rateLimit(Integer rateLimit) {
         this.builder.rateLimit(OptionalValue.of(rateLimit));
         return this;
      }

      public PlanUsageUpdateRequest build() {
         return this.builder.build();
      }

      public static PlanUsageUpdateRequest.PlanUsageUpdateRequestJsonBuilder get() {
         return new PlanUsageUpdateRequest.PlanUsageUpdateRequestJsonBuilder();
      }
   }
}
