package com.airlock.iam.saml2.domain.model.sp;

import com.airlock.iam.saml2.domain.model.Saml2RelayState;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Optional;
import lombok.NonNull;

public record Saml2SpSsoMetadata(
   @NonNull Optional<Saml2InResponseTo> inResponseTo, @NonNull Optional<Saml2RelayState> relayState, @NonNull Saml2SpEntityId spEntityId
) {
   @SuppressFBWarnings(justification = "generated code")
   public Saml2SpSsoMetadata {
      if (inResponseTo == null) {
         throw new NullPointerException("inResponseTo is marked non-null but is null");
      }

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

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

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

   @SuppressFBWarnings(justification = "generated code")
   public static class Saml2SpSsoMetadataBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private Optional<Saml2InResponseTo> inResponseTo;
      @SuppressFBWarnings(justification = "generated code")
      private Optional<Saml2RelayState> relayState;
      @SuppressFBWarnings(justification = "generated code")
      private Saml2SpEntityId spEntityId;

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

      @SuppressFBWarnings(justification = "generated code")
      public Saml2SpSsoMetadata.Saml2SpSsoMetadataBuilder inResponseTo(@NonNull Optional<Saml2InResponseTo> inResponseTo) {
         if (inResponseTo == null) {
            throw new NullPointerException("inResponseTo is marked non-null but is null");
         }

         this.inResponseTo = inResponseTo;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Saml2SpSsoMetadata.Saml2SpSsoMetadataBuilder relayState(@NonNull Optional<Saml2RelayState> relayState) {
         if (relayState == null) {
            throw new NullPointerException("relayState is marked non-null but is null");
         }

         this.relayState = relayState;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Saml2SpSsoMetadata.Saml2SpSsoMetadataBuilder spEntityId(@NonNull Saml2SpEntityId spEntityId) {
         if (spEntityId == null) {
            throw new NullPointerException("spEntityId is marked non-null but is null");
         }

         this.spEntityId = spEntityId;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public Saml2SpSsoMetadata build() {
         return new Saml2SpSsoMetadata(this.inResponseTo, this.relayState, this.spEntityId);
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "Saml2SpSsoMetadata.Saml2SpSsoMetadataBuilder(inResponseTo="
            + this.inResponseTo
            + ", relayState="
            + this.relayState
            + ", spEntityId="
            + this.spEntityId
            + ")";
      }
   }
}
