
package de.ivu.elect.presentation.status;

import java.io.Serializable;
import java.util.Date;

import javax.inject.Inject;

import de.ivu.elect.business.gebietsbaum.entity.Gebiet;
import de.ivu.elect.jee.faces.Messages;
import de.ivu.elect.jee.faces.UserLocale;
import de.ivu.elect.jee.presentation.status.StatusEntry;
import de.ivu.elect.presentation.gebietsbaum.GebietNummerFormatter;

public abstract class AbstractStatusEntryFactory implements Serializable {

  private static final long serialVersionUID = 1L;

  @Deprecated // einfacher linebreak \n tut es genauso gut...
  public static final String TOOLTIP_LINE_SEPARATOR = StatusEntry.TOOLTIP_LINE_SEPARATOR;

  @Inject
  private transient Messages messages;

  @Inject
  private transient UserLocale userLocale;

  @Inject
  private transient GebietNummerFormatter gebietNummerFormatter;

  protected AbstractStatusEntryFactory() {
    super();
  }

  protected GebietNummerFormatter getGebietNummerFormatter() {
    return gebietNummerFormatter;
  }

  protected String formatTooltipGebietDarstellung(Gebiet gebiet) {
    return getGebietNummerFormatter().getDetailMitMarkierungen(gebiet, getGebietNummerFormatter()::getDarstellung);
  }

  protected String getMessage(Enum< ? > enumValue) {
    return getMessages().lokalisiere(enumValue);
  }

  protected String getMessage(String msgKey, Object... params) {
    return getMessages().getMessageForMessageKey(msgKey, params);
  }

  protected Messages getMessages() {
    return messages;
  }

  protected String formatDateTime(Date dateTime) {
    return getUserLocale().formatDateTime(dateTime);
  }

  protected UserLocale getUserLocale() {
    return userLocale;
  }
}
