package com.airlock.iam.flow.api.application.configuration.dynamicactivation;

import com.airlock.iam.flow.api.application.configuration.step.StepIdConfig;
import com.airlock.iam.flow.api.domain.model.step.StepId;
import com.airlock.iam.plugin.api.annotation.config.Plugin;
import com.airlock.iam.plugin.api.annotation.property.BooleanProperty;
import com.airlock.iam.plugin.api.annotation.property.PluginProperty;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

@Plugin(description = "Dynamic activation of a subsequent step in the flow.")
public final class DynamicStepActivationConfig {
   @PluginProperty(
      description = "The ID of the step to activate dynamically. The taget step must have the \"Requires Dynamic Activation\" flag enabled for the feature to work.",
      displayName = "Step ID",
      optional = false
   )
   private StepIdConfig targetStepId;
   public static final String TARGET_STEP_ID_FIELD = "targetStepId";
   @BooleanProperty(description = "Whether the target step can be <em>activated</em> while in this step.", defaultValue = "true", optional = true)
   private boolean activatable;
   @BooleanProperty(description = "Whether the target step can be <em>deactivated</em> while in this step.", defaultValue = "true", optional = true)
   private boolean deactivatable;

   public StepId getTargetStepId() {
      return this.targetStepId.getId();
   }

   public boolean isActivatable() {
      return this.activatable;
   }

   public boolean isDeactivatable() {
      return this.deactivatable;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   public DynamicStepActivationConfig(StepIdConfig targetStepId, boolean activatable, boolean deactivatable) {
      this.targetStepId = targetStepId;
      this.activatable = activatable;
      this.deactivatable = deactivatable;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class DynamicStepActivationConfigBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private StepIdConfig targetStepId;
      @SuppressFBWarnings(justification = "generated code")
      private boolean activatable;
      @SuppressFBWarnings(justification = "generated code")
      private boolean deactivatable;

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

      @SuppressFBWarnings(justification = "generated code")
      public DynamicStepActivationConfig.DynamicStepActivationConfigBuilder targetStepId(StepIdConfig targetStepId) {
         this.targetStepId = targetStepId;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public DynamicStepActivationConfig.DynamicStepActivationConfigBuilder activatable(boolean activatable) {
         this.activatable = activatable;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public DynamicStepActivationConfig.DynamicStepActivationConfigBuilder deactivatable(boolean deactivatable) {
         this.deactivatable = deactivatable;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public DynamicStepActivationConfig build() {
         return new DynamicStepActivationConfig(this.targetStepId, this.activatable, this.deactivatable);
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "DynamicStepActivationConfig.DynamicStepActivationConfigBuilder(targetStepId="
            + this.targetStepId
            + ", activatable="
            + this.activatable
            + ", deactivatable="
            + this.deactivatable
            + ")";
      }
   }
}
