From 9f994b33de7bfa31872ba2cf9b583df00539e458 Mon Sep 17 00:00:00 2001 From: Zhangmei Li Date: Wed, 27 Dec 2017 11:35:11 +0800 Subject: [PATCH] HugeGraph-1000: allow non-check of config options Change-Id: Ida0a2d88818f0ca53e9ddf886cff88e7ceb52ed8 --- pom.xml | 4 ++-- .../baidu/hugegraph/config/ConfigOption.java | 20 +++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index eb871e12d..c80f06c8a 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.baidu.hugegraph hugegraph-common - 1.3.10-SNAPSHOT + 1.3.11-SNAPSHOT @@ -156,7 +156,7 @@ - 1.3.9.0 + 1.3.11.0 diff --git a/src/main/java/com/baidu/hugegraph/config/ConfigOption.java b/src/main/java/com/baidu/hugegraph/config/ConfigOption.java index 9241418d3..2bc993fe7 100644 --- a/src/main/java/com/baidu/hugegraph/config/ConfigOption.java +++ b/src/main/java/com/baidu/hugegraph/config/ConfigOption.java @@ -63,6 +63,10 @@ public class ConfigOption { private final T defaultValue; private final Predicate checkFunc; + public ConfigOption(String name, String desc, T value) { + this(name, desc, null, value); + } + @SuppressWarnings("unchecked") public ConfigOption(String name, String desc, Predicate func, T value) { this(name, false, desc, func, (Class) value.getClass(), value); @@ -81,9 +85,7 @@ public class ConfigOption { this.desc = desc; this.checkFunc = func; - if (this.checkFunc != null) { - check(this.defaultValue); - } + this.check(this.defaultValue); } private Class checkAndAssignDataType(Class dataType) { @@ -150,10 +152,12 @@ public class ConfigOption { E.checkArgument(this.dataType.isInstance(value), "Invalid type of value '%s' for option '%s'", value, this.name); - @SuppressWarnings("unchecked") - T result = (T) value; - E.checkArgument(this.checkFunc.apply(result), - "Invalid option value for '%s': %s", - this.name, value); + if (this.checkFunc != null) { + @SuppressWarnings("unchecked") + T result = (T) value; + E.checkArgument(this.checkFunc.apply(result), + "Invalid option value for '%s': %s", + this.name, value); + } } }