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.RegexProperty;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.regex.Pattern;

@Plugin(description = "Event that is published when a user's context data is changed.", displayName = "Context Data Changed")
public final class ContextDataChangedSubscribedEventConfig implements LoginappUserSubscribedEventConfig, AdminappUserSubscribedEventConfig {
   @RegexProperty(
      description = "The event is only handled by this subscriber, if at least one of the changed context data fields matches this pattern.",
      optional = true,
      exampleValues = {"surname", "street.*", ".*name"},
      defaultValue = ".*"
   )
   private Pattern fieldNamePattern;

   public Pattern getFieldNamePattern() {
      return this.fieldNamePattern;
   }

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

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

   @SuppressFBWarnings(justification = "generated code")
   public ContextDataChangedSubscribedEventConfig(Pattern fieldNamePattern) {
      this.fieldNamePattern = fieldNamePattern;
   }

   @SuppressFBWarnings(justification = "generated code")
   public static class ContextDataChangedSubscribedEventConfigBuilder {
      @SuppressFBWarnings(justification = "generated code")
      private Pattern fieldNamePattern;

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

      @SuppressFBWarnings(justification = "generated code")
      public ContextDataChangedSubscribedEventConfig.ContextDataChangedSubscribedEventConfigBuilder fieldNamePattern(Pattern fieldNamePattern) {
         this.fieldNamePattern = fieldNamePattern;
         return this;
      }

      @SuppressFBWarnings(justification = "generated code")
      public ContextDataChangedSubscribedEventConfig build() {
         return new ContextDataChangedSubscribedEventConfig(this.fieldNamePattern);
      }

      @SuppressFBWarnings(justification = "generated code")
      @Override
      public String toString() {
         return "ContextDataChangedSubscribedEventConfig.ContextDataChangedSubscribedEventConfigBuilder(fieldNamePattern=" + this.fieldNamePattern + ")";
      }
   }
}
