package de.ivu.elect.presentation.wahl.form;

import java.util.List;

import de.ivu.elect.business.wahl.boundary.WahlartConversationStore;
import de.ivu.elect.business.wahl.entity.Wahlart;


import static java.util.Objects.nonNull;

/**
 *  on 26.07.2016.
 */
public class ConversationStoreWahlartSelectOneMenuProperty extends AbstractWahlartSelectOneMenuProperty {

  private final WahlartConversationStore wahlartContextParameter;

  public ConversationStoreWahlartSelectOneMenuProperty(WahlartConversationStore wahlartContextParameter, List<Wahlart> wahlarten) {
    super(wahlarten);
    this.wahlartContextParameter = wahlartContextParameter;
  }


  @Override
  public Wahlart getValue() {
    return wahlartContextParameter.getEntity();
  }

  @Override
  public void setValue(Wahlart value) {
    this.wahlartContextParameter.setEntityPK(null);

    if (nonNull(value)) {
      this.wahlartContextParameter.setEntityPK(value.getPk());
    }
  }


}

