package de.ivu.elect.jee.performance;

import javax.faces.event.PhaseId;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public enum PhaseIdEnum {

  RESTORE_VIEW,
  APPLY_REQUEST_VALUES,
  PROCESS_VALIDATIONS,
  UPDATE_MODEL_VALUES,
  INVOKE_APPLICATION,
  RENDER_RESPONSE;

  private static final Logger LOG = LoggerFactory.getLogger(PhaseIdEnum.class);

  public static PhaseIdEnum fromPhaseId(PhaseId phaseId) {
    if (phaseId == PhaseId.RESTORE_VIEW) {
      return RESTORE_VIEW;
    } else if (phaseId == PhaseId.APPLY_REQUEST_VALUES) {
      return APPLY_REQUEST_VALUES;
    } else if (phaseId == PhaseId.PROCESS_VALIDATIONS) {
      return PROCESS_VALIDATIONS;
    } else if (phaseId == PhaseId.UPDATE_MODEL_VALUES) {
      return UPDATE_MODEL_VALUES;
    } else if (phaseId == PhaseId.INVOKE_APPLICATION) {
      return INVOKE_APPLICATION;
    } else if (phaseId == PhaseId.RENDER_RESPONSE) {
      return RENDER_RESPONSE;
    }
    throw new IllegalStateException("Unbekanhnte PhaseId: " + phaseId);
  }
}
