package com.airlock.iam.authentication.application.configuration.targetapp;

import com.airlock.iam.common.api.application.configuration.valueprovider.StringValueProviderConfig;
import com.airlock.iam.plugin.api.annotation.config.Plugin;
import com.airlock.iam.plugin.api.annotation.license.PluginLicenseRestriction;
import com.airlock.iam.plugin.api.annotation.property.PluginProperty;
import com.airlock.iam.plugin.api.annotation.property.StringProperty;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

@Plugin(description = "Defines a header (name and value) to be added to a one-shot response.")
@PluginLicenseRestriction(moduleAffiliation = "OneShotAuthentication")
public final class OneShotResponseHeaderConfig {
   @StringProperty(description = "Name of the header to be added.", exampleValues = {"Location", "X-MyInfo"}, optional = false)
   private String name;
   @PluginProperty(
      description = "Provider for a string to be used as the header value. If the provided value is null or blank, the header is not added to the response.",
      optional = false
   )
   private StringValueProviderConfig value;

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

   public StringValueProviderConfig getValue() {
      return this.value;
   }

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

   @SuppressFBWarnings(justification = "generated code")
   public OneShotResponseHeaderConfig(String name, StringValueProviderConfig value) {
      this.name = name;
      this.value = value;
   }

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

   @SuppressFBWarnings(justification = "generated code")
   public static class OneShotResponseHeaderConfigBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private String name;
      @SuppressFBWarnings(justification = "generated code")
      private StringValueProviderConfig value;

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

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

      @SuppressFBWarnings(justification = "generated code")
      public OneShotResponseHeaderConfig.OneShotResponseHeaderConfigBuilder value(StringValueProviderConfig value) {
         this.value = value;
         return this;
      }

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

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "OneShotResponseHeaderConfig.OneShotResponseHeaderConfigBuilder(name=" + this.name + ", value=" + this.value + ")";
      }
   }
}
