mirror of
https://github.com/lightbend/config.git
synced 2025-03-11 09:40:25 +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.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.time.Duration;
|
||||
|
||||
import com.typesafe.config.Config;
|
||||
@ -79,7 +78,7 @@ public class ConfigBeanImpl {
|
||||
List<ConfigException.ValidationProblem> problems = new ArrayList<ConfigException.ValidationProblem>();
|
||||
for (PropertyDescriptor beanProp : beanProps) {
|
||||
Method setter = beanProp.getWriteMethod();
|
||||
Class parameterClass = setter.getParameterTypes()[0];
|
||||
Class<?> parameterClass = setter.getParameterTypes()[0];
|
||||
|
||||
ConfigValueType expectedType = getValueTypeOrNull(parameterClass);
|
||||
if (expectedType != null) {
|
||||
@ -127,7 +126,8 @@ public class ConfigBeanImpl {
|
||||
// setting. So, instead, we only support a limited number of
|
||||
// types plus you can always use Object, ConfigValue, Config,
|
||||
// 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) {
|
||||
return config.getBoolean(configPropName);
|
||||
} else if (parameterClass == Integer.class || parameterClass == int.class) {
|
||||
|
@ -336,7 +336,6 @@ final class ConfigDocumentParser {
|
||||
t = nextTokenCollectingWhitespace(children);
|
||||
|
||||
// quoted string
|
||||
String name;
|
||||
if (!Tokens.isValueWithType(t, ConfigValueType.STRING)) {
|
||||
throw parseError("expecting a quoted string inside file(), classpath(), or url(), rather than: "
|
||||
+ t);
|
||||
@ -399,7 +398,6 @@ final class ConfigDocumentParser {
|
||||
Token afterKey = nextTokenCollectingWhitespace(keyValueNodes);
|
||||
boolean insideEquals = false;
|
||||
|
||||
Token valueToken;
|
||||
AbstractConfigNodeValue nextValue;
|
||||
if (flavor == ConfigSyntax.CONF && afterKey == Tokens.OPEN_CURLY) {
|
||||
// can omit the ':' or '=' before an object value
|
||||
|
@ -9,7 +9,7 @@ abstract class ConfigNodeComplexValue extends AbstractConfigNodeValue {
|
||||
final protected ArrayList<AbstractConfigNode> children;
|
||||
|
||||
ConfigNodeComplexValue(Collection<AbstractConfigNode> children) {
|
||||
this.children = new ArrayList(children);
|
||||
this.children = new ArrayList<AbstractConfigNode>(children);
|
||||
}
|
||||
|
||||
final public Collection<AbstractConfigNode> children() {
|
||||
@ -18,7 +18,7 @@ abstract class ConfigNodeComplexValue extends AbstractConfigNodeValue {
|
||||
|
||||
@Override
|
||||
protected Collection<Token> tokens() {
|
||||
ArrayList<Token> tokens = new ArrayList();
|
||||
ArrayList<Token> tokens = new ArrayList<Token>();
|
||||
for (AbstractConfigNode child : children) {
|
||||
tokens.addAll(child.tokens());
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ final class ConfigNodeInclude extends AbstractConfigNode {
|
||||
|
||||
@Override
|
||||
protected Collection<Token> tokens() {
|
||||
ArrayList<Token> tokens = new ArrayList();
|
||||
ArrayList<Token> tokens = new ArrayList<Token>();
|
||||
for (AbstractConfigNode child : children) {
|
||||
tokens.addAll(child.tokens());
|
||||
}
|
||||
|
@ -238,9 +238,7 @@ final class ConfigParser {
|
||||
} else if (node instanceof ConfigNodeField) {
|
||||
lastWasNewline = false;
|
||||
Path path = ((ConfigNodeField) node).path().value();
|
||||
AbstractConfigNodeValue nodeValue = ((ConfigNodeField) node).value();
|
||||
comments.addAll(((ConfigNodeField) node).comments());
|
||||
boolean insideEquals = false;
|
||||
|
||||
// path must be on-stack while we parse the value
|
||||
pathStack.push(path);
|
||||
@ -263,10 +261,6 @@ final class ConfigParser {
|
||||
AbstractConfigNodeValue valueNode;
|
||||
AbstractConfigValue newValue;
|
||||
|
||||
if (((ConfigNodeField) node).separator() == Tokens.EQUALS) {
|
||||
insideEquals = true;
|
||||
}
|
||||
|
||||
valueNode = ((ConfigNodeField) node).value();
|
||||
|
||||
// comments from the key token go to the value token
|
||||
|
@ -3,8 +3,6 @@
|
||||
*/
|
||||
package com.typesafe.config.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Stack;
|
||||
|
||||
import com.typesafe.config.ConfigException;
|
||||
|
@ -161,11 +161,6 @@ final class SimpleConfig implements Config, MergeableValue, Serializable {
|
||||
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,
|
||||
ConfigValueType expected, Path originalPath) {
|
||||
try {
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.typesafe.config.impl;
|
||||
|
||||
import com.typesafe.config.parser.ConfigDocument;
|
||||
import com.typesafe.config.ConfigException;
|
||||
import com.typesafe.config.ConfigParseOptions;
|
||||
import com.typesafe.config.ConfigValue;
|
||||
|
||||
|
@ -131,8 +131,6 @@ final class Tokens {
|
||||
this.value = s;
|
||||
}
|
||||
|
||||
String value() { return value; }
|
||||
|
||||
@Override
|
||||
public String toString() { return "'" + value + "' (WHITESPACE)"; }
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.typesafe.config.parser;
|
||||
|
||||
import com.typesafe.config.ConfigParseOptions;
|
||||
import com.typesafe.config.ConfigValue;
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,6 @@ package com.typesafe.config.parser;
|
||||
|
||||
import com.typesafe.config.ConfigParseOptions;
|
||||
|
||||
import com.typesafe.config.impl.ConfigImpl;
|
||||
import com.typesafe.config.impl.Parseable;
|
||||
|
||||
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.
|
||||
*
|
||||
* <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
|
||||
* there's no need for "defensive copies."
|
||||
*
|
||||
@ -19,7 +26,9 @@ package com.typesafe.config.parser;
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public String render();
|
||||
|
@ -248,7 +248,7 @@ abstract trait TestUtils {
|
||||
"possibly caused by http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6446627",
|
||||
nf)
|
||||
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)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user