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; } }
网友评论