mirror of
https://github.com/lightbend/config.git
synced 2025-03-12 18:20:27 +08:00
Fix a bunch of compile-time warnings, minor doc tweaks
This commit is contained in:
parent
ea78c17381
commit
8ec5784e32
@ -12,7 +12,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
import com.typesafe.config.Config;
|
import com.typesafe.config.Config;
|
||||||
@ -79,7 +78,7 @@ public class ConfigBeanImpl {
|
|||||||
List<ConfigException.ValidationProblem> problems = new ArrayList<ConfigException.ValidationProblem>();
|
List<ConfigException.ValidationProblem> problems = new ArrayList<ConfigException.ValidationProblem>();
|
||||||
for (PropertyDescriptor beanProp : beanProps) {
|
for (PropertyDescriptor beanProp : beanProps) {
|
||||||
Method setter = beanProp.getWriteMethod();
|
Method setter = beanProp.getWriteMethod();
|
||||||
Class parameterClass = setter.getParameterTypes()[0];
|
Class<?> parameterClass = setter.getParameterTypes()[0];
|
||||||
|
|
||||||
ConfigValueType expectedType = getValueTypeOrNull(parameterClass);
|
ConfigValueType expectedType = getValueTypeOrNull(parameterClass);
|
||||||
if (expectedType != null) {
|
if (expectedType != null) {
|
||||||
@ -127,7 +126,8 @@ public class ConfigBeanImpl {
|
|||||||
// setting. So, instead, we only support a limited number of
|
// setting. So, instead, we only support a limited number of
|
||||||
// types plus you can always use Object, ConfigValue, Config,
|
// types plus you can always use Object, ConfigValue, Config,
|
||||||
// ConfigObject, etc. as an escape hatch.
|
// ConfigObject, etc. as an escape hatch.
|
||||||
private static Object getValue(Class beanClass, Type parameterType, Class<?> parameterClass, Config config, String configPropName) {
|
private static Object getValue(Class<?> beanClass, Type parameterType, Class<?> parameterClass, Config config,
|
||||||
|
String configPropName) {
|
||||||
if (parameterClass == Boolean.class || parameterClass == boolean.class) {
|
if (parameterClass == Boolean.class || parameterClass == boolean.class) {
|
||||||
return config.getBoolean(configPropName);
|
return config.getBoolean(configPropName);
|
||||||
} else if (parameterClass == Integer.class || parameterClass == int.class) {
|
} else if (parameterClass == Integer.class || parameterClass == int.class) {
|
||||||
|
@ -336,7 +336,6 @@ final class ConfigDocumentParser {
|
|||||||
t = nextTokenCollectingWhitespace(children);
|
t = nextTokenCollectingWhitespace(children);
|
||||||
|
|
||||||
// quoted string
|
// quoted string
|
||||||
String name;
|
|
||||||
if (!Tokens.isValueWithType(t, ConfigValueType.STRING)) {
|
if (!Tokens.isValueWithType(t, ConfigValueType.STRING)) {
|
||||||
throw parseError("expecting a quoted string inside file(), classpath(), or url(), rather than: "
|
throw parseError("expecting a quoted string inside file(), classpath(), or url(), rather than: "
|
||||||
+ t);
|
+ t);
|
||||||
@ -399,7 +398,6 @@ final class ConfigDocumentParser {
|
|||||||
Token afterKey = nextTokenCollectingWhitespace(keyValueNodes);
|
Token afterKey = nextTokenCollectingWhitespace(keyValueNodes);
|
||||||
boolean insideEquals = false;
|
boolean insideEquals = false;
|
||||||
|
|
||||||
Token valueToken;
|
|
||||||
AbstractConfigNodeValue nextValue;
|
AbstractConfigNodeValue nextValue;
|
||||||
if (flavor == ConfigSyntax.CONF && afterKey == Tokens.OPEN_CURLY) {
|
if (flavor == ConfigSyntax.CONF && afterKey == Tokens.OPEN_CURLY) {
|
||||||
// can omit the ':' or '=' before an object value
|
// can omit the ':' or '=' before an object value
|
||||||
|
@ -9,7 +9,7 @@ abstract class ConfigNodeComplexValue extends AbstractConfigNodeValue {
|
|||||||
final protected ArrayList<AbstractConfigNode> children;
|
final protected ArrayList<AbstractConfigNode> children;
|
||||||
|
|
||||||
ConfigNodeComplexValue(Collection<AbstractConfigNode> children) {
|
ConfigNodeComplexValue(Collection<AbstractConfigNode> children) {
|
||||||
this.children = new ArrayList(children);
|
this.children = new ArrayList<AbstractConfigNode>(children);
|
||||||
}
|
}
|
||||||
|
|
||||||
final public Collection<AbstractConfigNode> children() {
|
final public Collection<AbstractConfigNode> children() {
|
||||||
@ -18,7 +18,7 @@ abstract class ConfigNodeComplexValue extends AbstractConfigNodeValue {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Collection<Token> tokens() {
|
protected Collection<Token> tokens() {
|
||||||
ArrayList<Token> tokens = new ArrayList();
|
ArrayList<Token> tokens = new ArrayList<Token>();
|
||||||
for (AbstractConfigNode child : children) {
|
for (AbstractConfigNode child : children) {
|
||||||
tokens.addAll(child.tokens());
|
tokens.addAll(child.tokens());
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ final class ConfigNodeInclude extends AbstractConfigNode {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Collection<Token> tokens() {
|
protected Collection<Token> tokens() {
|
||||||
ArrayList<Token> tokens = new ArrayList();
|
ArrayList<Token> tokens = new ArrayList<Token>();
|
||||||
for (AbstractConfigNode child : children) {
|
for (AbstractConfigNode child : children) {
|
||||||
tokens.addAll(child.tokens());
|
tokens.addAll(child.tokens());
|
||||||
}
|
}
|
||||||
|
@ -238,9 +238,7 @@ final class ConfigParser {
|
|||||||
} else if (node instanceof ConfigNodeField) {
|
} else if (node instanceof ConfigNodeField) {
|
||||||
lastWasNewline = false;
|
lastWasNewline = false;
|
||||||
Path path = ((ConfigNodeField) node).path().value();
|
Path path = ((ConfigNodeField) node).path().value();
|
||||||
AbstractConfigNodeValue nodeValue = ((ConfigNodeField) node).value();
|
|
||||||
comments.addAll(((ConfigNodeField) node).comments());
|
comments.addAll(((ConfigNodeField) node).comments());
|
||||||
boolean insideEquals = false;
|
|
||||||
|
|
||||||
// path must be on-stack while we parse the value
|
// path must be on-stack while we parse the value
|
||||||
pathStack.push(path);
|
pathStack.push(path);
|
||||||
@ -263,10 +261,6 @@ final class ConfigParser {
|
|||||||
AbstractConfigNodeValue valueNode;
|
AbstractConfigNodeValue valueNode;
|
||||||
AbstractConfigValue newValue;
|
AbstractConfigValue newValue;
|
||||||
|
|
||||||
if (((ConfigNodeField) node).separator() == Tokens.EQUALS) {
|
|
||||||
insideEquals = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
valueNode = ((ConfigNodeField) node).value();
|
valueNode = ((ConfigNodeField) node).value();
|
||||||
|
|
||||||
// comments from the key token go to the value token
|
// comments from the key token go to the value token
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.typesafe.config.impl;
|
package com.typesafe.config.impl;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
import com.typesafe.config.ConfigException;
|
import com.typesafe.config.ConfigException;
|
||||||
|
@ -161,11 +161,6 @@ final class SimpleConfig implements Config, MergeableValue, Serializable {
|
|||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static private AbstractConfigValue find(AbstractConfigObject self, Path path,
|
|
||||||
ConfigValueType expected, Path originalPath) {
|
|
||||||
return throwIfNull(findOrNull(self, path, expected, originalPath), expected, originalPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
static private AbstractConfigValue findOrNull(AbstractConfigObject self, Path path,
|
static private AbstractConfigValue findOrNull(AbstractConfigObject self, Path path,
|
||||||
ConfigValueType expected, Path originalPath) {
|
ConfigValueType expected, Path originalPath) {
|
||||||
try {
|
try {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.typesafe.config.impl;
|
package com.typesafe.config.impl;
|
||||||
|
|
||||||
import com.typesafe.config.parser.ConfigDocument;
|
import com.typesafe.config.parser.ConfigDocument;
|
||||||
import com.typesafe.config.ConfigException;
|
|
||||||
import com.typesafe.config.ConfigParseOptions;
|
import com.typesafe.config.ConfigParseOptions;
|
||||||
import com.typesafe.config.ConfigValue;
|
import com.typesafe.config.ConfigValue;
|
||||||
|
|
||||||
|
@ -131,8 +131,6 @@ final class Tokens {
|
|||||||
this.value = s;
|
this.value = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
String value() { return value; }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() { return "'" + value + "' (WHITESPACE)"; }
|
public String toString() { return "'" + value + "' (WHITESPACE)"; }
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.typesafe.config.parser;
|
package com.typesafe.config.parser;
|
||||||
|
|
||||||
import com.typesafe.config.ConfigParseOptions;
|
|
||||||
import com.typesafe.config.ConfigValue;
|
import com.typesafe.config.ConfigValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,7 +2,6 @@ package com.typesafe.config.parser;
|
|||||||
|
|
||||||
import com.typesafe.config.ConfigParseOptions;
|
import com.typesafe.config.ConfigParseOptions;
|
||||||
|
|
||||||
import com.typesafe.config.impl.ConfigImpl;
|
|
||||||
import com.typesafe.config.impl.Parseable;
|
import com.typesafe.config.impl.Parseable;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -7,6 +7,13 @@ package com.typesafe.config.parser;
|
|||||||
* A node in the syntax tree for a HOCON or JSON document.
|
* A node in the syntax tree for a HOCON or JSON document.
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
|
* Note: at present there is no way to obtain an instance of this interface, so
|
||||||
|
* please ignore it. A future release will make syntax tree nodes available in
|
||||||
|
* the public API. If you are interested in working on it, please see: <a
|
||||||
|
* href="https://github.com/typesafehub/config/issues/300"
|
||||||
|
* >https://github.com/typesafehub/config/issues/300</a>
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
* Because this object is immutable, it is safe to use from multiple threads and
|
* Because this object is immutable, it is safe to use from multiple threads and
|
||||||
* there's no need for "defensive copies."
|
* there's no need for "defensive copies."
|
||||||
*
|
*
|
||||||
@ -19,7 +26,9 @@ package com.typesafe.config.parser;
|
|||||||
*/
|
*/
|
||||||
public interface ConfigNode {
|
public interface ConfigNode {
|
||||||
/**
|
/**
|
||||||
* The original text of the input which was used to form this particular node.
|
* The original text of the input which was used to form this particular
|
||||||
|
* node.
|
||||||
|
*
|
||||||
* @return the original text used to form this node as a String
|
* @return the original text used to form this node as a String
|
||||||
*/
|
*/
|
||||||
public String render();
|
public String render();
|
||||||
|
@ -248,7 +248,7 @@ abstract trait TestUtils {
|
|||||||
"possibly caused by http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6446627",
|
"possibly caused by http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6446627",
|
||||||
nf)
|
nf)
|
||||||
case e: Exception =>
|
case e: Exception =>
|
||||||
System.err.println(e.getStackTraceString);
|
System.err.println(e.getStackTrace.toString);
|
||||||
throw new AssertionError("failed to make a copy via serialization", e)
|
throw new AssertionError("failed to make a copy via serialization", e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user