
package de.ivu.elect.presentation.email.table;

import javax.annotation.Nullable;

import de.ivu.elect.business.email.entity.EmailVorgang;
import de.ivu.elect.jee.faces.Messages;
import de.ivu.elect.jee.presentation.Icons;
import de.ivu.elect.jee.presentation.dynamictable.ColumnType;

public class EmailVorgangStatusColumn<E extends EmailVorgang> extends AbstractEmailVorgangColumn<E> {

  private static final long serialVersionUID = 1L;

  private final Icons icons;

  protected EmailVorgangStatusColumn(Messages messages, Icons icons) {
    super("EmailVorgang-Status", messages, "email.vorgang.column.status", ColumnType.ENUM, EmailVorgang::getStatus);

    this.icons = icons;
  }

  @Override
  public String getTooltip(E entity) {
    if (entity == null || entity.getStatus() == null) {
      return null;
    }

    return getMessage(entity.getStatus());
  }

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

  @Override
  public boolean isIconRendered(E entity) {
    return getIcon(entity) != null;
  }

  @Nullable
  @Override
  public String getIcon(E entity) {
    if (entity == null) {
      return null;
    }

    return entity.getStatus().getIcon(icons);
  }
}
