package com.airlock.iam.common.application.configuration.event;

import com.airlock.iam.plugin.api.annotation.config.Plugin;
import com.airlock.iam.plugin.api.annotation.property.BooleanProperty;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

@Plugin(
   description = "Event that is published when the authentication method of a user changes.\n<p>This event is <em>not</em> published in the following cases:\n<ul>\n<li>The authentication method is edited via context data - use a \"Context Data Changed\" event instead</li>\n<li>The user is newly created</li>\n<li>The user is imported, e.g. via a service container task or from external persistency (AD/LDAP)</li>\n</ul>\n</p>",
   displayName = "Authentication Method Changed"
)
public final class AuthenticationMethodChangedEventConfig implements LoginappUserSubscribedEventConfig, AdminappUserSubscribedEventConfig {
   @BooleanProperty(
      description = "If enabled, the event will not be handled when the user did not have an active previous authentication method.",
      defaultValue = "false",
      optional = true
   )
   private boolean ignoreEmptyPreviousMethod;
   @BooleanProperty(
      description = "If enabled, the event will not be handled when the active authentication method has been removed.",
      defaultValue = "false",
      optional = true
   )
   private boolean ignoreEmptyActiveMethod;

   public boolean isIgnoreEmptyPreviousMethod() {
      return this.ignoreEmptyPreviousMethod;
   }

   public boolean isIgnoreEmptyActiveMethod() {
      return this.ignoreEmptyActiveMethod;
   }

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

   @SuppressFBWarnings(justification = "generated code")
   public AuthenticationMethodChangedEventConfig() {
   }

   @SuppressFBWarnings(justification = "generated code")
   public AuthenticationMethodChangedEventConfig(boolean ignoreEmptyPreviousMethod, boolean ignoreEmptyActiveMethod) {
      this.ignoreEmptyPreviousMethod = ignoreEmptyPreviousMethod;
      this.ignoreEmptyActiveMethod = ignoreEmptyActiveMethod;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class AuthenticationMethodChangedEventConfigBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private boolean ignoreEmptyPreviousMethod;
      @SuppressFBWarnings(justification = "generated code")
      private boolean ignoreEmptyActiveMethod;

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

      @SuppressFBWarnings(justification = "generated code")
      public AuthenticationMethodChangedEventConfig.AuthenticationMethodChangedEventConfigBuilder ignoreEmptyPreviousMethod(boolean ignoreEmptyPreviousMethod) {
         this.ignoreEmptyPreviousMethod = ignoreEmptyPreviousMethod;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public AuthenticationMethodChangedEventConfig.AuthenticationMethodChangedEventConfigBuilder ignoreEmptyActiveMethod(boolean ignoreEmptyActiveMethod) {
         this.ignoreEmptyActiveMethod = ignoreEmptyActiveMethod;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public AuthenticationMethodChangedEventConfig build() {
         return new AuthenticationMethodChangedEventConfig(this.ignoreEmptyPreviousMethod, this.ignoreEmptyActiveMethod);
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "AuthenticationMethodChangedEventConfig.AuthenticationMethodChangedEventConfigBuilder(ignoreEmptyPreviousMethod="
            + this.ignoreEmptyPreviousMethod
            + ", ignoreEmptyActiveMethod="
            + this.ignoreEmptyActiveMethod
            + ")";
      }
   }
}
