
package de.ivu.elect.jee.presentation.dynamicform;

import org.apache.commons.lang3.StringUtils;

public abstract class AbstractRedisplayPasswordProperty extends AbstractPasswordProperty {

  public static final String PASSWORD_NOT_CHANGED_PATTERN = "**********"; // NOSONAR, KEIN hart-kodiertes Passwort...

  protected AbstractRedisplayPasswordProperty(String pattern, String patternDescription) {
    super(pattern, patternDescription);
  }

  @Override
  public boolean isRedisplay() {
    return StringUtils.isNotBlank(getValueInternal());
  }

  @Override
  public String getValue() {
    if (isRedisplay()) {
      return PASSWORD_NOT_CHANGED_PATTERN;

    }

    return "";
  }

  @Override
  public void setValue(String value) {
    if (!PASSWORD_NOT_CHANGED_PATTERN.equals(value)) {
      setValueInternal(value);
    }
  }

  public abstract String getValueInternal();

  public abstract void setValueInternal(String value);
}
