Environment增加forEach方法
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
package org.redkale.util;
|
package org.redkale.util;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 环境变量, 只读版Properties
|
* 环境变量, 只读版Properties
|
||||||
@@ -47,6 +47,11 @@ public class Environment implements java.io.Serializable {
|
|||||||
properties.forEach((BiConsumer) action);
|
properties.forEach((BiConsumer) action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void forEach(Predicate<String> predicate, BiConsumer<String, String> action) {
|
||||||
|
properties.entrySet().stream().filter(en -> predicate.test(en.getKey().toString()))
|
||||||
|
.forEach(en -> action.accept(en.getKey().toString(), en.getValue() == null ? null : en.getValue().toString()));
|
||||||
|
}
|
||||||
|
|
||||||
public boolean getBooleanProperty(String key) {
|
public boolean getBooleanProperty(String key) {
|
||||||
String val = properties.getProperty(key);
|
String val = properties.getProperty(key);
|
||||||
return "true".equalsIgnoreCase(val) || "1".equalsIgnoreCase(val);
|
return "true".equalsIgnoreCase(val) || "1".equalsIgnoreCase(val);
|
||||||
|
|||||||
Reference in New Issue
Block a user