枚举用于适配
public class ServiceIdMapper {
private static Logger logger = LoggerFactory.getLogger(ServiceIdEnum.class);
enum ServiceIdEnum{
资金路由适配("YF0000031","TNPreRoutAdapt"),
进件申请("000000","00000");
private String transType;
private String transName;
private ServiceIdEnum(String transType,String transName){
this.transType=transType;
this.transName=transName;
}
}
public String getServiceId(String code){
if (StringUtils.isEmpty(code)){
return null;
}
for (ServiceIdEnum item : ServiceIdEnum.values()) {
if (item.transType.equals(code)) {
return item.transName;
}
}
logger.error("未匹配交易类型:transType={}",code);
return null;
}
}
public class ServiceIdMapperTest {
@Test
public void test1(){
ServiceIdMapper serviceIdMapper = new ServiceIdMapper();
String str = serviceIdMapper.getServiceId("YF0000031");
System.out.println(str);
}
}