com.mzt.logapi.service.impl.ParseFunctionFactory Maven / Gradle / Ivy
package com.mzt.logapi.service.impl;
import com.mzt.logapi.service.IParseFunction;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author muzhantong
* create on 2021/2/6 9:45 上午
*/
public class ParseFunctionFactory {
private Map allFunctionMap;
public ParseFunctionFactory(List parseFunctions) {
if (CollectionUtils.isEmpty(parseFunctions)) {
return;
}
allFunctionMap = new HashMap<>();
for (IParseFunction parseFunction : parseFunctions) {
if (StringUtils.isEmpty(parseFunction.functionName())) {
continue;
}
allFunctionMap.put(parseFunction.functionName(), parseFunction);
}
}
public IParseFunction getFunction(String functionName) {
return allFunctionMap.get(functionName);
}
public boolean isBeforeFunction(String functionName) {
return allFunctionMap.get(functionName) != null && allFunctionMap.get(functionName).executeBefore();
}
}