package com.airlock.iam.oauth2.domain.model.token;

import com.airlock.iam.oauth2.api.domain.model.AuthorizationServerId;
import com.airlock.iam.oauth2.api.domain.model.OAuth2ClientId;
import com.airlock.iam.oauth2.domain.model.session.OAuth2SessionId;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Date;
import lombok.NonNull;

public final class SessionInfo {
   @NonNull
   private final OAuth2SessionId sessionId;
   @NonNull
   private final String username;
   @NonNull
   private final OAuth2ClientId clientId;
   @NonNull
   private final AuthorizationServerId authorizationServerId;
   @NonNull
   private final Date userAuthenticationDate;

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

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public OAuth2SessionId getSessionId() {
      return this.sessionId;
   }

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

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public OAuth2ClientId getClientId() {
      return this.clientId;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public AuthorizationServerId getAuthorizationServerId() {
      return this.authorizationServerId;
   }

   @NonNull
   @SuppressFBWarnings(justification = "generated code")
   public Date getUserAuthenticationDate() {
      return this.userAuthenticationDate;
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public boolean equals(Object o) {
      if (o == this) {
         return true;
      } else if (!(o instanceof SessionInfo other)) {
         return false;
      } else {
         Object this$sessionId = this.sessionId;
         Object other$sessionId = other.sessionId;
         if (this$sessionId == null ? other$sessionId == null : this$sessionId.equals(other$sessionId)) {
            Object this$username = this.username;
            Object other$username = other.username;
            if (this$username == null ? other$username == null : this$username.equals(other$username)) {
               Object this$clientId = this.clientId;
               Object other$clientId = other.clientId;
               if (this$clientId == null ? other$clientId == null : this$clientId.equals(other$clientId)) {
                  Object this$authorizationServerId = this.authorizationServerId;
                  Object other$authorizationServerId = other.authorizationServerId;
                  if (this$authorizationServerId == null ? other$authorizationServerId == null : this$authorizationServerId.equals(other$authorizationServerId)
                     )
                   {
                     Object this$userAuthenticationDate = this.userAuthenticationDate;
                     Object other$userAuthenticationDate = other.userAuthenticationDate;
                     return this$userAuthenticationDate == null
                        ? other$userAuthenticationDate == null
                        : this$userAuthenticationDate.equals(other$userAuthenticationDate);
                  } 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;
      Object $sessionId = this.sessionId;
      result = result * 59 + ($sessionId == null ? 43 : $sessionId.hashCode());
      Object $username = this.username;
      result = result * 59 + ($username == null ? 43 : $username.hashCode());
      Object $clientId = this.clientId;
      result = result * 59 + ($clientId == null ? 43 : $clientId.hashCode());
      Object $authorizationServerId = this.authorizationServerId;
      result = result * 59 + ($authorizationServerId == null ? 43 : $authorizationServerId.hashCode());
      Object $userAuthenticationDate = this.userAuthenticationDate;
      return result * 59 + ($userAuthenticationDate == null ? 43 : $userAuthenticationDate.hashCode());
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String toString() {
      return "SessionInfo(sessionId="
         + this.getSessionId()
         + ", username="
         + this.getUsername()
         + ", clientId="
         + this.getClientId()
         + ", authorizationServerId="
         + this.getAuthorizationServerId()
         + ", userAuthenticationDate="
         + this.getUserAuthenticationDate()
         + ")";
   }

   @SuppressFBWarnings(justification = "generated code")
   public SessionInfo(
      @NonNull OAuth2SessionId sessionId,
      @NonNull String username,
      @NonNull OAuth2ClientId clientId,
      @NonNull AuthorizationServerId authorizationServerId,
      @NonNull Date userAuthenticationDate
   ) {
      if (sessionId == null) {
         throw new NullPointerException("sessionId is marked non-null but is null");
      }

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

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

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

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

      this.sessionId = sessionId;
      this.username = username;
      this.clientId = clientId;
      this.authorizationServerId = authorizationServerId;
      this.userAuthenticationDate = userAuthenticationDate;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class SessionInfoBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private OAuth2SessionId sessionId;
      @SuppressFBWarnings(justification = "generated code")
      private String username;
      @SuppressFBWarnings(justification = "generated code")
      private OAuth2ClientId clientId;
      @SuppressFBWarnings(justification = "generated code")
      private AuthorizationServerId authorizationServerId;
      @SuppressFBWarnings(justification = "generated code")
      private Date userAuthenticationDate;

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

      @SuppressFBWarnings(justification = "generated code")
      public SessionInfo.SessionInfoBuilder sessionId(@NonNull OAuth2SessionId sessionId) {
         if (sessionId == null) {
            throw new NullPointerException("sessionId is marked non-null but is null");
         }

         this.sessionId = sessionId;
         return this;
      }

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

         this.username = username;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public SessionInfo.SessionInfoBuilder clientId(@NonNull OAuth2ClientId clientId) {
         if (clientId == null) {
            throw new NullPointerException("clientId is marked non-null but is null");
         }

         this.clientId = clientId;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public SessionInfo.SessionInfoBuilder authorizationServerId(@NonNull AuthorizationServerId authorizationServerId) {
         if (authorizationServerId == null) {
            throw new NullPointerException("authorizationServerId is marked non-null but is null");
         }

         this.authorizationServerId = authorizationServerId;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public SessionInfo.SessionInfoBuilder userAuthenticationDate(@NonNull Date userAuthenticationDate) {
         if (userAuthenticationDate == null) {
            throw new NullPointerException("userAuthenticationDate is marked non-null but is null");
         }

         this.userAuthenticationDate = userAuthenticationDate;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public SessionInfo build() {
         return new SessionInfo(this.sessionId, this.username, this.clientId, this.authorizationServerId, this.userAuthenticationDate);
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "SessionInfo.SessionInfoBuilder(sessionId="
            + this.sessionId
            + ", username="
            + this.username
            + ", clientId="
            + this.clientId
            + ", authorizationServerId="
            + this.authorizationServerId
            + ", userAuthenticationDate="
            + this.userAuthenticationDate
            + ")";
      }
   }
}
