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

import de.ivu.elect.business.person.entity.Personendaten;
import de.ivu.elect.business.person.entity.PersonendatenConstants;
import de.ivu.elect.jee.faces.Messages;
import de.ivu.elect.jee.presentation.Icons;
import de.ivu.elect.jee.presentation.dynamictable.ColumnType;

public class PersonendatenPersonStatusMitIconColumn<E extends Personendaten> extends AbstractPersonendatenColumn<E> {

  private static final long serialVersionUID = 1L;

  private final Icons icons;

  public PersonendatenPersonStatusMitIconColumn(Messages messages, Icons icons) {
    super("Personendaten-PersonStatusMitIcon", messages, PersonendatenConstants.MESSAGE_KEY_PERSON_STATUS_EINZAHL, ColumnType.ENUM, Personendaten::getPersonStatus);

    this.icons = icons;
  }

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

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

  @Override
  public String getIcon(E personendaten) {
    if (personendaten != null) {
      return personendaten.getPersonStatus().getIcon(icons);
    }

    return super.getIcon(personendaten);
  }
}
