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

import static org.apache.commons.lang3.StringUtils.isBlank;

public class ReadOnlyStringProperty extends AbstractStringProperty {

  private final String label;

  private final String value;

  public ReadOnlyStringProperty(String label, String value) {
    super();

    this.label = label;
    this.value = value;
  }

  @Override
  public boolean isReadonly() {
    return true;
  }

  @Override
  public boolean getDefaultRequired() {
    return false;
  }

  @Override
  public int getDefaultMaxLength() {
    if (isBlank(value)) {
      return 0;
    }

    return value.length();
  }

  @Override
  public String getDefaultLabel() {
    return label;
  }

  @Override
  public String getValue() {
    return value;
  }

  @Override
  public void setValue(String value) {
    // Readonly!
  }
}
