Commit 8f970efd authored by suhuiguang's avatar suhuiguang

refactor(大编辑):管道增减功能开发

1.方法名称修改
parent 5ca6f1be
......@@ -11,19 +11,19 @@ import java.util.function.BiPredicate;
import static com.yeejoin.amos.boot.module.jg.biz.edit.utils.JsonDiffUtil.isNullOrEmpty;
public class DiffUtils {
private static final Map<String, BiPredicate<String, String>> diffCache = new ConcurrentHashMap<>();
private static final Map<String, BiPredicate<String, String>> comparatorFactory = new ConcurrentHashMap<>();
static {
registerDefaultComparators();
}
private static void registerDefaultComparators() {
diffCache.put(String.class.getSimpleName(), StringUtils::equals);
diffCache.put(JSON.class.getSimpleName(), JsonDiffUtil::jsonEqualsIgnoreType);
comparatorFactory.put(String.class.getSimpleName(), StringUtils::equals);
comparatorFactory.put(JSON.class.getSimpleName(), JsonDiffUtil::jsonEqualsIgnoreType);
}
public static void register(String type, BiPredicate<String, String> comparator) {
diffCache.put(type, comparator);
comparatorFactory.put(type, comparator);
}
public static boolean compare(String type, String newValue, String oldValue) {
......@@ -32,7 +32,7 @@ public class DiffUtils {
if (type == null) {
return Objects.equals(newValue, oldValue);
}
return diffCache.getOrDefault(type, Objects::equals).test(newValue, oldValue);
return comparatorFactory.getOrDefault(type, Objects::equals).test(newValue, oldValue);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment