java switch case stringjavaswitchcase参数变量使⽤枚举定义枚举
public enum BusinessTypeEnum {
OUT(new Byte("1"),"出库"),
IN(new Byte("2"),"⼊库"),
ACCOUNT(new Byte("3"),"转移记账"),
MOVE(new Byte("4"),"转储"),
;
BusinessTypeEnum(Byte value, String name) {
this.value = value;
this.name = name;
}
BusinessTypeEnum() {
}
private Byte value;
private String name;
public Byte getValue() {
return value;
}
public String getName() {
return name;
}
/**
* 通过value取枚举
* @param value
* @return
*/
public static BusinessTypeEnum getTypeByValue(Byte value){
if (null == value){
return null;
}
for (BusinessTypeEnum enums : BusinessTypeEnum.values()) {
if (Value().intValue() == value.intValue()) {
return enums;
}
}
return null;
}
}
switch+枚举⽤法
public void BusinessBatchOperationMove(BusinessBatchOperationMoveDTO moveDTO) {
MoveTypeHandleBaseDTO baseDTO = BaseDTO();
switch (BusinessType())) {//通过value取枚举 case IN:
handleInBatchOperate(baseDTO);
break;
case OUT:
handleOutBatchOperate(baseDTO);
break;
case MOVE:
handleMoveBatchOperate(baseDTO);
break;
case ACCOUNT:
handleAccountBatchOperate(baseDTO);
break;
default:
break;
}
handleMoveType(baseDTO);
}
over
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论