package com.airlock.iam.apipolicyservice.domain.model;

import com.airlock.iam.base.api.domain.model.Entity;
import com.airlock.iam.base.api.domain.model.identity.Identity;
import com.airlock.iam.techclient.api.domain.model.TechnicalClient;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.function.Supplier;
import lombok.NonNull;

public final class ApiPolicyServiceTechClientView implements Entity<TechnicalClient> {
   @NonNull
   private final Identity<TechnicalClient> id;
   @NonNull
   private final String displayName;
   private final String label;
   private final boolean locked;
   private final ApiPolicyServiceApiKey apiKey;
   private final ApiPolicyServiceSubscription subscription;

   @SuppressFBWarnings(justification = "generated code")
   ApiPolicyServiceTechClientView(
      @NonNull Identity<TechnicalClient> id,
      @NonNull String displayName,
      String label,
      boolean locked,
      ApiPolicyServiceApiKey apiKey,
      ApiPolicyServiceSubscription subscription
   ) {
      if (id == null) {
         throw new NullPointerException("id is marked non-null but is null");
      }

      if (displayName == null) {
         throw new NullPointerException("displayName is marked non-null but is null");
      }

      this.id = id;
      this.displayName = displayName;
      this.label = label;
      this.locked = locked;
      this.apiKey = apiKey;
      this.subscription = subscription;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static ApiPolicyServiceTechClientView.ApiPolicyServiceTechClientViewBuilder builder() {
      return new ApiPolicyServiceTechClientView.ApiPolicyServiceTechClientViewBuilder();
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Identity<TechnicalClient> getId() {
      return this.id;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public String getDisplayName() {
      return this.displayName;
   }

   @SuppressFBWarnings(justification = "generated code")
   public String getLabel() {
      return this.label;
   }

   @SuppressFBWarnings(justification = "generated code")
   public boolean isLocked() {
      return this.locked;
   }

   @SuppressFBWarnings(justification = "generated code")
   public ApiPolicyServiceApiKey getApiKey() {
      return this.apiKey;
   }

   @SuppressFBWarnings(justification = "generated code")
   public ApiPolicyServiceSubscription getSubscription() {
      return this.subscription;
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public boolean equals(Object o) {
      if (o == this) {
         return true;
      } else if (!(o instanceof ApiPolicyServiceTechClientView other)) {
         return false;
      } else {
         if (this.locked != other.locked) {
            return false;
         }

         Object this$id = this.id;
         Object other$id = other.id;
         if (this$id == null ? other$id == null : this$id.equals(other$id)) {
            Object this$displayName = this.displayName;
            Object other$displayName = other.displayName;
            if (this$displayName == null ? other$displayName == null : this$displayName.equals(other$displayName)) {
               Object this$label = this.label;
               Object other$label = other.label;
               if (this$label == null ? other$label == null : this$label.equals(other$label)) {
                  Object this$apiKey = this.apiKey;
                  Object other$apiKey = other.apiKey;
                  if (this$apiKey == null ? other$apiKey == null : this$apiKey.equals(other$apiKey)) {
                     Object this$subscription = this.subscription;
                     Object other$subscription = other.subscription;
                     return this$subscription == null ? other$subscription == null : this$subscription.equals(other$subscription);
                  } else {
                     return false;
                  }
               } else {
                  return false;
               }
            } else {
               return false;
            }
         } else {
            return false;
         }
      }
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public int hashCode() {
      int PRIME = 59;
      int result = 1;
      result = result * 59 + (this.locked ? 79 : 97);
      Object $id = this.id;
      result = result * 59 + ($id == null ? 43 : $id.hashCode());
      Object $displayName = this.displayName;
      result = result * 59 + ($displayName == null ? 43 : $displayName.hashCode());
      Object $label = this.label;
      result = result * 59 + ($label == null ? 43 : $label.hashCode());
      Object $apiKey = this.apiKey;
      result = result * 59 + ($apiKey == null ? 43 : $apiKey.hashCode());
      Object $subscription = this.subscription;
      return result * 59 + ($subscription == null ? 43 : $subscription.hashCode());
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "ApiPolicyServiceTechClientView(id="
         + this.getId()
         + ", displayName="
         + this.getDisplayName()
         + ", label="
         + this.getLabel()
         + ", locked="
         + this.isLocked()
         + ", apiKey="
         + this.getApiKey()
         + ", subscription="
         + this.getSubscription()
         + ")";
   }

   public static class ApiPolicyServiceTechClientViewBuilder implements Supplier<ApiPolicyServiceTechClientView> {
      @SuppressFBWarnings(justification = "generated code")
      private Identity<TechnicalClient> id;
      @SuppressFBWarnings(justification = "generated code")
      private String displayName;
      @SuppressFBWarnings(justification = "generated code")
      private String label;
      @SuppressFBWarnings(justification = "generated code")
      private boolean locked;
      @SuppressFBWarnings(justification = "generated code")
      private ApiPolicyServiceApiKey apiKey;
      @SuppressFBWarnings(justification = "generated code")
      private ApiPolicyServiceSubscription subscription;
      private ApiPolicyServiceSubscription.ApiPolicyServiceSubscriptionBuilder subscriptionBuilder;

      public ApiPolicyServiceTechClientView.ApiPolicyServiceTechClientViewBuilder subscriptionBuilder(
         ApiPolicyServiceSubscription.ApiPolicyServiceSubscriptionBuilder builder
      ) {
         this.subscriptionBuilder = builder;
         return this;
      }

      public ApiPolicyServiceSubscription.ApiPolicyServiceSubscriptionBuilder getSubscriptionBuilder() {
         return this.subscriptionBuilder;
      }

      public ApiPolicyServiceTechClientView get() {
         if (this.subscriptionBuilder != null) {
            this.subscription(this.subscriptionBuilder.build());
         }

         return this.build();
      }

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

      @SuppressFBWarnings(justification = "generated code")
      public ApiPolicyServiceTechClientView.ApiPolicyServiceTechClientViewBuilder id(@NonNull Identity<TechnicalClient> id) {
         if (id == null) {
            throw new NullPointerException("id is marked non-null but is null");
         }

         this.id = id;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public ApiPolicyServiceTechClientView.ApiPolicyServiceTechClientViewBuilder displayName(@NonNull String displayName) {
         if (displayName == null) {
            throw new NullPointerException("displayName is marked non-null but is null");
         }

         this.displayName = displayName;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public ApiPolicyServiceTechClientView.ApiPolicyServiceTechClientViewBuilder label(String label) {
         this.label = label;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public ApiPolicyServiceTechClientView.ApiPolicyServiceTechClientViewBuilder locked(boolean locked) {
         this.locked = locked;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public ApiPolicyServiceTechClientView.ApiPolicyServiceTechClientViewBuilder apiKey(ApiPolicyServiceApiKey apiKey) {
         this.apiKey = apiKey;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public ApiPolicyServiceTechClientView.ApiPolicyServiceTechClientViewBuilder subscription(ApiPolicyServiceSubscription subscription) {
         this.subscription = subscription;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public ApiPolicyServiceTechClientView build() {
         return new ApiPolicyServiceTechClientView(this.id, this.displayName, this.label, this.locked, this.apiKey, this.subscription);
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "ApiPolicyServiceTechClientView.ApiPolicyServiceTechClientViewBuilder(id="
            + this.id
            + ", displayName="
            + this.displayName
            + ", label="
            + this.label
            + ", locked="
            + this.locked
            + ", apiKey="
            + this.apiKey
            + ", subscription="
            + this.subscription
            + ")";
      }
   }
}
