
package de.ivu.elect.presentation.security;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

import de.ivu.elect.business.security.UseCasePermission;

@FacesConverter(forClass = UseCasePermission.class)
public class ElectCommonPermissionConverter implements Converter {

  private static final ElectCommonPermissionConverter INSTANCE = new ElectCommonPermissionConverter();

  @Override
  public Object getAsObject(FacesContext ctx, UIComponent component, String value) {
    return UseCasePermission.valueOf(value);
  }

  @Override
  public String getAsString(FacesContext ctx, UIComponent component, Object value) {
    return ((UseCasePermission) value).name();
  }

  public static ElectCommonPermissionConverter getInstance() {
    return INSTANCE;
  }

}
