use of cn.hutool.core.lang.Dict in project Jpom by dromara.
the class DbExtConfig method parse.
public static DbExtConfig parse(InputStream inputStream) {
Dict dict = YamlUtil.load(inputStream, Dict.class);
Object db = dict.get("db");
StringWriter writer = new StringWriter();
YamlUtil.dump(db, writer);
ByteArrayInputStream byteArrayInputStream = IoUtil.toStream(writer.toString(), CharsetUtil.CHARSET_UTF_8);
return YamlUtil.load(byteArrayInputStream, DbExtConfig.class);
}
use of cn.hutool.core.lang.Dict in project hutool by dromara.
the class ConsoleLog method log.
// ------------------------------------------------------------------------- Log
@Override
public void log(String fqcn, Level level, Throwable t, String format, Object... arguments) {
// fqcn 无效
if (false == isEnabled(level)) {
return;
}
final Dict dict = Dict.create().set("date", DateUtil.now()).set("level", level.toString()).set("name", this.name).set("msg", StrUtil.format(format, arguments));
final String logMsg = StrUtil.format(logFormat, dict);
// WARN以上级别打印至System.err
if (level.ordinal() >= Level.WARN.ordinal()) {
Console.error(t, logMsg);
} else {
Console.log(t, logMsg);
}
}
use of cn.hutool.core.lang.Dict in project hutool by dromara.
the class ExpressionUtilTest method rhinoTest.
@Test
public void rhinoTest() {
ExpressionEngine engine = new RhinoEngine();
final Dict dict = Dict.create().set("a", 100.3).set("b", 45).set("c", -199.100);
final Object eval = engine.eval("a-(b-c)", dict);
Assert.assertEquals(-143.8, (double) eval, 2);
}
use of cn.hutool.core.lang.Dict in project hutool by dromara.
the class ExpressionUtilTest method mvelTest.
@Test
public void mvelTest() {
ExpressionEngine engine = new MvelEngine();
final Dict dict = Dict.create().set("a", 100.3).set("b", 45).set("c", -199.100);
final Object eval = engine.eval("a-(b-c)", dict);
Assert.assertEquals(-143.8, (double) eval, 2);
}
use of cn.hutool.core.lang.Dict in project hutool by dromara.
the class ExpressionUtilTest method jfireELTest.
@Test
public void jfireELTest() {
ExpressionEngine engine = new JfireELEngine();
final Dict dict = Dict.create().set("a", 100.3).set("b", 45).set("c", -199.100);
final Object eval = engine.eval("a-(b-c)", dict);
Assert.assertEquals(-143.8, (double) eval, 2);
}
Aggregations