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

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

@Plugin(description = "Allows to define the name under which this context data field is mapped to an external interface.")
public final class MappedContextDataField {
   @StringProperty(
      description = "The name under which this context data field is mapped to an external interface.<p>Note that an entry named 'myName' will be nested in a map called 'contextData' and thus mapped to an external interface as <code>data.attributes.contextData.myName</code>.</p>",
      displayName = "Mapped Name",
      optional = false
   )
   private String name;
   static final String NAME = "name";
   @EnumProperty(description = "The type of the context data field.", optional = true, defaultValue = "STRING", displayName = "Type")
   private CredentialBasedAttributeMapping.ContextDataType dataType;
   @EnumProperty(description = "The access type that applies to this attribute and which gets enforced in REST.", optional = true, defaultValue = "READ_WRITE")
   private CredentialBasedAttributeMapping.ContextDataAttributeAccessType accessType;

   public String getName() {
      return this.name;
   }

   public CredentialBasedAttributeMapping.ContextDataType getDataType() {
      return this.dataType;
   }

   public CredentialBasedAttributeMapping.ContextDataAttributeAccessType getAccessType() {
      return this.accessType;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   public MappedContextDataField(
      String name, CredentialBasedAttributeMapping.ContextDataType dataType, CredentialBasedAttributeMapping.ContextDataAttributeAccessType accessType
   ) {
      this.name = name;
      this.dataType = dataType;
      this.accessType = accessType;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class MappedContextDataFieldBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private String name;
      @SuppressFBWarnings(justification = "generated code")
      private CredentialBasedAttributeMapping.ContextDataType dataType;
      @SuppressFBWarnings(justification = "generated code")
      private CredentialBasedAttributeMapping.ContextDataAttributeAccessType accessType;

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

      @SuppressFBWarnings(justification = "generated code")
      public MappedContextDataField.MappedContextDataFieldBuilder name(String name) {
         this.name = name;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public MappedContextDataField.MappedContextDataFieldBuilder dataType(CredentialBasedAttributeMapping.ContextDataType dataType) {
         this.dataType = dataType;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public MappedContextDataField.MappedContextDataFieldBuilder accessType(CredentialBasedAttributeMapping.ContextDataAttributeAccessType accessType) {
         this.accessType = accessType;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public MappedContextDataField build() {
         return new MappedContextDataField(this.name, this.dataType, this.accessType);
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "MappedContextDataField.MappedContextDataFieldBuilder(name="
            + this.name
            + ", dataType="
            + this.dataType
            + ", accessType="
            + this.accessType
            + ")";
      }
   }
}
