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

import de.ivu.elect.business.email.entity.Email;
import de.ivu.elect.business.person.entity.Personendaten;
import de.ivu.elect.jee.faces.Messages;
import de.ivu.elect.jee.presentation.dynamictable.ColumnType;
import de.ivu.elect.presentation.person.table.AbstractPersonendatenColumn;

public class EmailPersonendatenColumn extends AbstractEmailColumn<Email> {

  private static final long serialVersionUID = 1L;

  private final AbstractPersonendatenColumn<Personendaten> personendatenColumn;

  public EmailPersonendatenColumn(Messages messages, AbstractPersonendatenColumn<Personendaten> personendatenColumn) {
    super("Email-Personendaten-" + personendatenColumn.getName(), messages, null, null, null);

    this.personendatenColumn = personendatenColumn;
  }

  @Override
  public ColumnType getType() {
    return personendatenColumn.getType();
  }

  @Override
  public String getHeader() {
    return personendatenColumn.getHeader();
  }

  @Override
  public Object getValue(Email email) {
    if (email != null && email.hasPersonendaten()) {
      return personendatenColumn.getDisplayValue(email.getPersonendaten());
    }

    return "";
  }
}
