Tuesday, 25 January 2011

public enum POSEntryMode {

 SWIPE("01"),
 SWIPE_WO_PIN("01"),
 EMV_WO_PIN("05"),
 EMV_ONLINE_PIN("05"),
 EMV_OFFLINE_PIN("05"),
 MANUAL("02"),
 TOUCH("06"),
 FALLBACK("04"),
 CARD_NOT_PRESENT("03"),
 UNKNOWN("00"); 
 
 private String name;
 
 private POSEntryMode(String name){
  this.name = name;
 }
 
 public String getValue(){
  return this.name;
 }
 
 public static POSEntryMode parse(String POSEntryMode) throws OneICommonException{
  if(POSEntryMode == null || "".equalsIgnoreCase(POSEntryMode)){
   throw new OneICommonException(ErrorCodeConstant.INVALID_REQUEST_ERROR,
            CommonExceptionConstant.INVALID_POS_ENTRY_MODE_ERR_MSG,
            new IllegalArgumentException("POS ENTRY MODE IS BLANK OR NULL"));
  }
  /*
   * Matching starts here
   */
  if(POSEntryMode.equalsIgnoreCase("SWIPE") || POSEntryMode.equalsIgnoreCase("S") || POSEntryMode.equalsIgnoreCase("01")){
   return SWIPE;   
  }else if(POSEntryMode.equalsIgnoreCase("EMV") || POSEntryMode.equalsIgnoreCase("ICC")
      || POSEntryMode.equalsIgnoreCase("DIP") || POSEntryMode.equalsIgnoreCase("CHIP")
       || POSEntryMode.equalsIgnoreCase("PIN") || POSEntryMode.equalsIgnoreCase("D") || POSEntryMode.equalsIgnoreCase("05")){
   return EMV_ONLINE_PIN;   
  }else if(POSEntryMode.equalsIgnoreCase("MANUAL") || POSEntryMode.equalsIgnoreCase("KEYED")
     || POSEntryMode.equalsIgnoreCase("M") || POSEntryMode.equalsIgnoreCase("02")){
   return MANUAL;   
  }else if(POSEntryMode.equalsIgnoreCase("TOUCH") || POSEntryMode.equalsIgnoreCase("CONTANTLESS")
     || POSEntryMode.equalsIgnoreCase("T")|| POSEntryMode.equalsIgnoreCase("06")){
   return TOUCH;   
  }else if(POSEntryMode.equalsIgnoreCase("FALLBACK") || POSEntryMode.equalsIgnoreCase("04")){
   return FALLBACK;   
  }else if(POSEntryMode.equalsIgnoreCase("03") ){
   return CARD_NOT_PRESENT;   
  }else{
   throw new OneICommonException(ErrorCodeConstant.INVALID_REQUEST_ERROR,
       CommonExceptionConstant.INVALID_POS_ENTRY_MODE_ERR_MSG,
       new IllegalArgumentException("POS ENTRY MODE IS NOT RECOGNIZED ["+ POSEntryMode+"]"));
  }
 }
 
}

No comments:

Post a Comment