mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 12:12:08 +08:00
1.新增dataMapPut私有方法进行dataMap的put操作,在该操作中会有value的判空逻辑.2.使用ObjectUtil进行对象判空
This commit is contained in:
@@ -304,7 +304,7 @@ public class FlowExecutor {
|
||||
*/
|
||||
public <T extends Slot> T execute(String chainId, Object param, Class<T> slotClazz,
|
||||
Integer slotIndex, boolean isInnerChain) throws Exception {
|
||||
if (null == param) {
|
||||
if (ObjectUtil.isNull(param)) {
|
||||
//data slot is a ConcurrentHashMap, so null value will trigger NullPointerException
|
||||
throw new NullParamException("data slot can't accept null param");
|
||||
}
|
||||
@@ -367,7 +367,7 @@ public class FlowExecutor {
|
||||
*/
|
||||
public <T extends Slot> LiteflowResponse<T> execute2Resp(String chainId, Object param, Class<T> slotClazz, Integer slotIndex,
|
||||
boolean isInnerChain) {
|
||||
if (null == param) {
|
||||
if (ObjectUtil.isNull(param)) {
|
||||
//data slot is a ConcurrentHashMap, so null value will trigger NullPointerException
|
||||
throw new NullParamException("data slot can't accept null param");
|
||||
}
|
||||
@@ -434,13 +434,13 @@ public class FlowExecutor {
|
||||
|
||||
if (!isInnerChain) {
|
||||
//对param进行判空,如果为null,则不进行slot设置
|
||||
if (null != param) {
|
||||
if (ObjectUtil.isNotNull(param)) {
|
||||
slot.setRequestData(param);
|
||||
}
|
||||
slot.setChainName(chainId);
|
||||
} else {
|
||||
//对param进行判空,如果为null,则不进行slot设置
|
||||
if (null != param) {
|
||||
if (ObjectUtil.isNotNull(param)) {
|
||||
slot.setChainReqData(chainId, param);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
package com.yomahub.liteflow.entity.data;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.yomahub.liteflow.exception.NullParamException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -48,6 +49,14 @@ public abstract class AbsSlot implements Slot {
|
||||
|
||||
protected ConcurrentHashMap<String, Object> dataMap = new ConcurrentHashMap<String, Object>();
|
||||
|
||||
private <T> void dataMapPut(String key, T t) {
|
||||
if (ObjectUtil.isNull(t)) {
|
||||
//data slot is a ConcurrentHashMap, so null value will trigger NullPointerException
|
||||
throw new NullParamException("data slot can't accept null param");
|
||||
}
|
||||
dataMap.put(key, t);
|
||||
}
|
||||
|
||||
public <T> T getInput(String nodeId){
|
||||
return (T)dataMap.get(NODE_INPUT_PREFIX + nodeId);
|
||||
}
|
||||
@@ -57,19 +66,11 @@ public abstract class AbsSlot implements Slot {
|
||||
}
|
||||
|
||||
public <T> void setInput(String nodeId,T t){
|
||||
if (null == t) {
|
||||
//data slot is a ConcurrentHashMap, so null value will trigger NullPointerException
|
||||
throw new NullParamException("data slot can't accept null param");
|
||||
}
|
||||
dataMap.put(NODE_INPUT_PREFIX + nodeId, t);
|
||||
dataMapPut(NODE_INPUT_PREFIX + nodeId, t);
|
||||
}
|
||||
|
||||
public <T> void setOutput(String nodeId,T t){
|
||||
if (null == t) {
|
||||
//data slot is a ConcurrentHashMap, so null value will trigger NullPointerException
|
||||
throw new NullParamException("data slot can't accept null param");
|
||||
}
|
||||
dataMap.put(NODE_OUTPUT_PREFIX + nodeId, t);
|
||||
dataMapPut(NODE_OUTPUT_PREFIX + nodeId, t);
|
||||
}
|
||||
|
||||
public <T> T getRequestData(){
|
||||
@@ -77,11 +78,7 @@ public abstract class AbsSlot implements Slot {
|
||||
}
|
||||
|
||||
public <T> void setRequestData(T t){
|
||||
if (null == t) {
|
||||
//data slot is a ConcurrentHashMap, so null value will trigger NullPointerException
|
||||
throw new NullParamException("data slot can't accept null param");
|
||||
}
|
||||
dataMap.put(REQUEST, t);
|
||||
dataMapPut(REQUEST, t);
|
||||
}
|
||||
|
||||
public <T> T getResponseData(){
|
||||
@@ -89,11 +86,7 @@ public abstract class AbsSlot implements Slot {
|
||||
}
|
||||
|
||||
public <T> void setResponseData(T t){
|
||||
if (null == t) {
|
||||
//data slot is a ConcurrentHashMap, so null value will trigger NullPointerException
|
||||
throw new NullParamException("data slot can't accept null param");
|
||||
}
|
||||
dataMap.put(RESPONSE, t);
|
||||
dataMapPut(RESPONSE, t);
|
||||
}
|
||||
|
||||
public <T> T getChainReqData(String chainId) {
|
||||
@@ -101,11 +94,7 @@ public abstract class AbsSlot implements Slot {
|
||||
}
|
||||
|
||||
public <T> void setChainReqData(String chainId, T t) {
|
||||
if (null == t) {
|
||||
//data slot is a ConcurrentHashMap, so null value will trigger NullPointerException
|
||||
throw new NullParamException("data slot can't accept null param");
|
||||
}
|
||||
dataMap.put(CHAIN_REQ_PREFIX + chainId, t);
|
||||
dataMapPut(CHAIN_REQ_PREFIX + chainId, t);
|
||||
}
|
||||
|
||||
public boolean hasData(String key){
|
||||
@@ -117,11 +106,7 @@ public abstract class AbsSlot implements Slot {
|
||||
}
|
||||
|
||||
public <T> void setData(String key, T t){
|
||||
if (null == t) {
|
||||
//data slot is a ConcurrentHashMap, so null value will trigger NullPointerException
|
||||
throw new NullParamException("data slot can't accept null param");
|
||||
}
|
||||
dataMap.put(key, t);
|
||||
dataMapPut(key, t);
|
||||
}
|
||||
|
||||
public <T> void setPrivateDeliveryData(String nodeId, T t){
|
||||
@@ -149,11 +134,7 @@ public abstract class AbsSlot implements Slot {
|
||||
}
|
||||
|
||||
public <T> void setCondResult(String key, T t){
|
||||
if (null == t) {
|
||||
//data slot is a ConcurrentHashMap, so null value will trigger NullPointerException
|
||||
throw new NullParamException("data slot can't accept null param");
|
||||
}
|
||||
dataMap.put(COND_NODE_PREFIX + key, t);
|
||||
dataMapPut(COND_NODE_PREFIX + key, t);
|
||||
}
|
||||
|
||||
public <T> T getCondResult(String key){
|
||||
@@ -161,11 +142,7 @@ public abstract class AbsSlot implements Slot {
|
||||
}
|
||||
|
||||
public void setChainName(String chainName) {
|
||||
if (null == chainName) {
|
||||
//data slot is a ConcurrentHashMap, so null value will trigger NullPointerException
|
||||
throw new NullParamException("data slot can't accept null param");
|
||||
}
|
||||
dataMap.put(CHAINNAME, chainName);
|
||||
dataMapPut(CHAINNAME, chainName);
|
||||
}
|
||||
|
||||
public String getChainName() {
|
||||
@@ -211,10 +188,6 @@ public abstract class AbsSlot implements Slot {
|
||||
|
||||
@Override
|
||||
public void setException(Exception e) {
|
||||
if (null == e) {
|
||||
//data slot is a ConcurrentHashMap, so null value will trigger NullPointerException
|
||||
throw new NullParamException("data slot can't accept null param");
|
||||
}
|
||||
this.dataMap.put(EXCEPTION, e);
|
||||
dataMapPut(EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user