com.mzt.logapi.service.impl.DefaultFunctionServiceImpl Maven / Gradle / Ivy
package com.mzt.logapi.service.impl;
import com.mzt.logapi.service.IFunctionService;
import com.mzt.logapi.service.IParseFunction;
/**
* @author muzhantong
* create on 2021/2/1 5:18 下午
*/
public class DefaultFunctionServiceImpl implements IFunctionService {
private final ParseFunctionFactory parseFunctionFactory;
public DefaultFunctionServiceImpl(ParseFunctionFactory parseFunctionFactory) {
this.parseFunctionFactory = parseFunctionFactory;
}
@Override
public String apply(String functionName, Object value) {
IParseFunction function = parseFunctionFactory.getFunction(functionName);
if (function == null) {
return value.toString();
}
return function.apply(value);
}
@Override
public boolean beforeFunction(String functionName) {
return parseFunctionFactory.isBeforeFunction(functionName);
}
}