package com.airlock.iam.admin.application.configuration.generic.ui;

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.StringProperty;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

@Plugin(description = "Renders a checkbox for a boolean property.", displayName = "Boolean Input Token Controller Element")
public final class BooleanInputTokenControllerUiElementConfig implements TokenControllerUiElementConfig {
   @StringProperty(
      description = "Label for the field. The UI treats it as a key to translate.\nIf there is no translation, the label is shown in the UI as is.",
      exampleValues = "user.generic-token.device-token.enabled",
      optional = false
   )
   private String label;
   @StringProperty(
      description = "The property to use as value for this field.\n<p>The referenced property must be available in the <code>attributes</code> value of the generic token REST call response.\nIf the property is nested, e.g. inside the <code>contextData</code> key, it can be referenced with dot notation (see example values).</p>",
      optional = false,
      exampleValues = {"enabled", "contextData.locked"}
   )
   private String property;
   @BooleanProperty(
      description = "If enabled, the field is read-only and cannot be altered by administrators via the UI.",
      displayName = "Read-only",
      defaultValue = "false",
      optional = true
   )
   private boolean readOnly;

   public String getLabel() {
      return this.label;
   }

   public String getProperty() {
      return this.property;
   }

   public boolean isReadOnly() {
      return this.readOnly;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   public BooleanInputTokenControllerUiElementConfig(String label, String property, boolean readOnly) {
      this.label = label;
      this.property = property;
      this.readOnly = readOnly;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class BooleanInputTokenControllerUiElementConfigBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private String label;
      @SuppressFBWarnings(justification = "generated code")
      private String property;
      @SuppressFBWarnings(justification = "generated code")
      private boolean readOnly;

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

      @SuppressFBWarnings(justification = "generated code")
      public BooleanInputTokenControllerUiElementConfig.BooleanInputTokenControllerUiElementConfigBuilder label(String label) {
         this.label = label;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public BooleanInputTokenControllerUiElementConfig.BooleanInputTokenControllerUiElementConfigBuilder property(String property) {
         this.property = property;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public BooleanInputTokenControllerUiElementConfig.BooleanInputTokenControllerUiElementConfigBuilder readOnly(boolean readOnly) {
         this.readOnly = readOnly;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public BooleanInputTokenControllerUiElementConfig build() {
         return new BooleanInputTokenControllerUiElementConfig(this.label, this.property, this.readOnly);
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "BooleanInputTokenControllerUiElementConfig.BooleanInputTokenControllerUiElementConfigBuilder(label="
            + this.label
            + ", property="
            + this.property
            + ", readOnly="
            + this.readOnly
            + ")";
      }
   }
}
