
package de.ivu.elect.presentation.exchange;

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

import de.ivu.elect.jee.presentation.dynamicform.AdvancedDynaFormModel;

public class ExportViewConfirmDialog {

  public static final ExportViewConfirmDialog UNSUPPORTED = new ExportViewConfirmDialog(false, "", "", null);

  private final boolean required;

  private final String header;

  private final String message;

  private final AdvancedDynaFormModel model;

  public ExportViewConfirmDialog(String header, String message) {
    this(true, header, message, null);
  }

  public ExportViewConfirmDialog(String header, AdvancedDynaFormModel model) {
    this(true, header, "", model);
  }

  public ExportViewConfirmDialog(String header, String message, AdvancedDynaFormModel model) {
    this(true, header, message, model);
  }

  private ExportViewConfirmDialog(boolean required, String header, String message, AdvancedDynaFormModel model) {
    super();

    this.required = required;

    this.header = header;
    this.message = message;
    this.model = model;
  }

  public boolean isRequired() {
    return required;
  }

  public boolean isVisible() {
    return isRequired() && (isMessageRendered() || isModelRendered());
  }

  public String getHeader() {
    return header;
  }

  public boolean isMessageRendered() {
    return isNotBlank(getMessage());
  }

  public String getMessage() {
    return message;
  }

  public boolean isModelRendered() {
    return getModel() != null && getModel().isAnyPropertyAdded();
  }

  public AdvancedDynaFormModel getModel() {
    return model;
  }
}
