package com.airlock.iam.base.domain.model.event;

import com.airlock.iam.base.api.domain.model.event.EventId;
import com.airlock.iam.base.api.domain.model.event.metadata.EventMetadata;
import com.airlock.iam.base.api.domain.model.event.source.EventSource;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.time.Instant;
import lombok.NonNull;

public final class EventCreationData {
   @NonNull
   private final EventId id;
   @NonNull
   private final EventSource source;
   @NonNull
   private final EventMetadata metadata;
   @NonNull
   private final Instant createdAt;

   @SuppressFBWarnings(justification = "generated code")
   EventCreationData(@NonNull EventId id, @NonNull EventSource source, @NonNull EventMetadata metadata, @NonNull Instant createdAt) {
      if (id == null) {
         throw new NullPointerException("id is marked non-null but is null");
      }

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

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

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

      this.id = id;
      this.source = source;
      this.metadata = metadata;
      this.createdAt = createdAt;
   }

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

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public EventId id() {
      return this.id;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public EventSource source() {
      return this.source;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public EventMetadata metadata() {
      return this.metadata;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Instant createdAt() {
      return this.createdAt;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "EventCreationData(id=" + this.id() + ", source=" + this.source() + ", metadata=" + this.metadata() + ", createdAt=" + this.createdAt() + ")";
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class EventCreationDataBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private EventId id;
      @SuppressFBWarnings(justification = "generated code")
      private EventSource source;
      @SuppressFBWarnings(justification = "generated code")
      private EventMetadata metadata;
      @SuppressFBWarnings(justification = "generated code")
      private Instant createdAt;

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

      @SuppressFBWarnings(justification = "generated code")
      public EventCreationData.EventCreationDataBuilder id(@NonNull EventId 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 EventCreationData.EventCreationDataBuilder source(@NonNull EventSource source) {
         if (source == null) {
            throw new NullPointerException("source is marked non-null but is null");
         }

         this.source = source;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public EventCreationData.EventCreationDataBuilder metadata(@NonNull EventMetadata metadata) {
         if (metadata == null) {
            throw new NullPointerException("metadata is marked non-null but is null");
         }

         this.metadata = metadata;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public EventCreationData.EventCreationDataBuilder createdAt(@NonNull Instant createdAt) {
         if (createdAt == null) {
            throw new NullPointerException("createdAt is marked non-null but is null");
         }

         this.createdAt = createdAt;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public EventCreationData build() {
         return new EventCreationData(this.id, this.source, this.metadata, this.createdAt);
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "EventCreationData.EventCreationDataBuilder(id="
            + this.id
            + ", source="
            + this.source
            + ", metadata="
            + this.metadata
            + ", createdAt="
            + this.createdAt
            + ")";
      }
   }
}
