美文网首页
Spel表达式自定义函数

Spel表达式自定义函数

作者: 独处人 | 来源:发表于2019-11-30 22:47 被阅读0次

    package com.alibaba.o2o.ad.kmonitor.utils; import com.google.common.collect.Maps; import org.apache.commons.lang3.StringUtils; import java.util.List; import java.util.Map; /** * @author michael.he * @date 2019-11-27 */ public class SpelUtil { public static final String forEachTag = "forEachTag"; public static final String forEachPrefixTag = "forEachPrefixTag"; public static final String tag = "tag"; public static Map<String, String> forEachTag(List<String> value) { return forEachPrefixTag("", value); } public static Map<String, String> forEachPrefixTag(String prefix, List<String> value) { Map<String, String> result = Maps.newHashMap(); if(value != null) { value.stream().forEach(v -> { result.put(prefix + v, v); }); } return result; } public static Map<String, String> tag(String key, String value) { Map<String, String> result = Maps.newHashMap(); result.put(StringUtils.defaultString(key,""), StringUtils.defaultString(value,"")); return result; } }

    相关文章

      网友评论

          本文标题:Spel表达式自定义函数

          本文链接:https://www.haomeiwen.com/subject/gppawctx.html