package com.airlock.iam.common.application.configuration.userprofile;

import com.airlock.iam.elog.api.ELogger;
import com.airlock.iam.elog.api.ELoggerFactory;
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;

public abstract class UserProfileItemConfigBase implements UserProfileItemConfig {
   protected static final ELogger LOG = ELoggerFactory.getLogger(UserProfileItemConfigBase.class);
   @StringProperty(
      description = "String identifier for the language-specific string tables.",
      optional = false,
      exampleValues = {
            "userdata.label.salutation",
            "userdata.label.firstname",
            "userdata.label.lastname",
            "userdata.label.email",
            "userdata.label.nationality",
            "userdata.label.birthdate",
            "userdata.label.street",
            "userdata.label.street-number",
            "userdata.label.address2",
            "userdata.label.zipcode",
            "userdata.label.town",
            "userdata.label.state",
            "userdata.label.country",
            "userdata.label.company",
            "userdata.label.department",
            "userdata.label.office-phone",
            "userdata.label.mobile-phone",
            "userdata.label.language",
            "userdata.label.correspondence-language",
            "userdata.label.realm"
      }
   )
   private String stringResourceKey;
   @StringProperty(
      description = "Name of the context-data field in which the value is stored.",
      optional = false,
      exampleValues = {"surname", "givenname", "email", "mtan_number"}
   )
   private String propertyName;
   @BooleanProperty(description = "If this field is optional or mandatory for the user.", optional = true, defaultValue = "true")
   private boolean optional;
   static final String OPTIONAL_PROPERTY_NAME = "optional";
   @BooleanProperty(
      description = "Indicates if the user is allowed to change this property once it is set. Specifically, if this flag is set to false, then during self-registration the property could be set, but when editing the user data, this property would be read-only.",
      optional = true,
      defaultValue = "true"
   )
   private boolean modifiable;
   @BooleanProperty(
      description = "If enabled, only values that have been changed by the user (compared to the data loaded from the data layer) are validated.",
      optional = true,
      defaultValue = "true"
   )
   private boolean validateOnlyChangedValues;
   @BooleanProperty(
      description = "If enabled, the attribute is sortable in the user list if the underlying user iterator supports sorting.",
      optional = true,
      defaultValue = "true"
   )
   private boolean sortable;

   @SuppressFBWarnings(justification = "generated code")
   protected UserProfileItemConfigBase(
      String stringResourceKey, String propertyName, boolean optional, boolean modifiable, boolean validateOnlyChangedValues, boolean sortable
   ) {
      this.stringResourceKey = stringResourceKey;
      this.propertyName = propertyName;
      this.optional = optional;
      this.modifiable = modifiable;
      this.validateOnlyChangedValues = validateOnlyChangedValues;
      this.sortable = sortable;
   }

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

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String getStringResourceKey() {
      return this.stringResourceKey;
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public String getPropertyName() {
      return this.propertyName;
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public boolean isOptional() {
      return this.optional;
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public boolean isModifiable() {
      return this.modifiable;
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public boolean isValidateOnlyChangedValues() {
      return this.validateOnlyChangedValues;
   }

   @SuppressFBWarnings(justification = "generated code")
   @Override
   public boolean isSortable() {
      return this.sortable;
   }
}
