本文整理汇总了Java中net.logstash.logback.encoder.org.apache.commons.lang.StringUtils类的典型用法代码示例。如果您正苦于以下问题:Java StringUtils类的具体用法?Java StringUtils怎么用?Java StringUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StringUtils类属于net.logstash.logback.encoder.org.apache.commons.lang包,在下文中一共展示了StringUtils类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUnnamedContext
import net.logstash.logback.encoder.org.apache.commons.lang.StringUtils; //导入依赖的package包/类
private Map<String, Object> getUnnamedContext(Map<String, Object> logContext) {
Map<String, Object> unnamed = new HashMap<>();
logContext.keySet()
.stream()
.filter(key -> key.equals(StringUtils.EMPTY))
.forEach(key -> unnamed.put(key, logContext.get(key)));
return unnamed;
}
示例2: appendNamedContext
import net.logstash.logback.encoder.org.apache.commons.lang.StringUtils; //导入依赖的package包/类
private Map<String, Object> appendNamedContext(Map<String, Object> logContext, Map<String, List<String>> keyNames, Map<String, Integer> keyCollisionIdentifier) {
Map<String, Object> named = new HashMap<>();
logContext.keySet()
.stream()
.filter(key -> !key.equals(StringUtils.EMPTY))
.forEach(key -> {
String name = key;
/**
* _unnamed_values is a reserved key for values with no key.
* If a named key with the value of _unnamed_values is received, a counter value will be appended to the key name.
*/
if (keyNames.get(key).size() > 1 || key.equals(CommonKeys.UNNAMED_VALUES_KEY)) {
if (!keyCollisionIdentifier.containsKey(key)) {
keyCollisionIdentifier.put(key, 1);
}
Integer identity = keyCollisionIdentifier.get(key);
name = identity == 1 && !key.equals(CommonKeys.UNNAMED_VALUES_KEY) ? name : (name += identity);
keyCollisionIdentifier.put(key, ++identity);
}
named.put(name, logContext.get(key));
});
return named;
}