mirror of
https://github.com/lightbend/config.git
synced 2025-01-15 23:01:05 +08:00
Rename set functions to with.
This commit is contained in:
parent
a0f2e49a85
commit
4a8e1023a3
@ -108,9 +108,10 @@ public interface ConfigValue extends ConfigMergeable {
|
||||
Config atKey(String key);
|
||||
|
||||
/**
|
||||
* Returns a new {@code ConfigValue} based on this one, but with the given
|
||||
* origin. This is useful when you are parsing a new format of file or setting
|
||||
* Returns a {@code ConfigValue} based on this one, but with the given
|
||||
* origin. This is useful when you are parsing a new format of file or setting
|
||||
* comments for a single ConfigValue.
|
||||
*
|
||||
* @param origin the origin set on the returned value
|
||||
* @return the new ConfigValue with the given origin
|
||||
*/
|
||||
|
@ -424,7 +424,7 @@ final class Parser {
|
||||
}
|
||||
|
||||
private SimpleConfigOrigin lineOrigin() {
|
||||
return ((SimpleConfigOrigin) baseOrigin).setLineNumber(lineNumber);
|
||||
return ((SimpleConfigOrigin) baseOrigin).withLineNumber(lineNumber);
|
||||
}
|
||||
|
||||
private ConfigException parseError(String message) {
|
||||
@ -559,13 +559,13 @@ final class Parser {
|
||||
// "foo.bar" not also to "foo"
|
||||
ListIterator<String> i = keys.listIterator(keys.size());
|
||||
String deepest = i.previous();
|
||||
AbstractConfigObject o = new SimpleConfigObject(value.origin().setComments(null),
|
||||
AbstractConfigObject o = new SimpleConfigObject(value.origin().withComments(null),
|
||||
Collections.<String, AbstractConfigValue> singletonMap(
|
||||
deepest, value));
|
||||
while (i.hasPrevious()) {
|
||||
Map<String, AbstractConfigValue> m = Collections.<String, AbstractConfigValue> singletonMap(
|
||||
i.previous(), o);
|
||||
o = new SimpleConfigObject(value.origin().setComments(null), m);
|
||||
o = new SimpleConfigObject(value.origin().withComments(null), m);
|
||||
}
|
||||
|
||||
return o;
|
||||
|
@ -70,7 +70,8 @@ final class SimpleConfigOrigin implements ConfigOrigin {
|
||||
return newResource(resource, null);
|
||||
}
|
||||
|
||||
SimpleConfigOrigin setLineNumber(int lineNumber) {
|
||||
@Override
|
||||
public SimpleConfigOrigin withLineNumber(int lineNumber) {
|
||||
if (lineNumber == this.lineNumber && lineNumber == this.endLineNumber) {
|
||||
return this;
|
||||
} else {
|
||||
@ -84,7 +85,8 @@ final class SimpleConfigOrigin implements ConfigOrigin {
|
||||
this.originType, url != null ? url.toExternalForm() : null, this.commentsOrNull);
|
||||
}
|
||||
|
||||
SimpleConfigOrigin setComments(List<String> comments) {
|
||||
@Override
|
||||
public SimpleConfigOrigin withComments(List<String> comments) {
|
||||
if (ConfigImplUtil.equalsHandlingNull(comments, this.commentsOrNull)) {
|
||||
return this;
|
||||
} else {
|
||||
@ -97,13 +99,13 @@ final class SimpleConfigOrigin implements ConfigOrigin {
|
||||
if (ConfigImplUtil.equalsHandlingNull(comments, this.commentsOrNull) || comments == null) {
|
||||
return this;
|
||||
} else if (this.commentsOrNull == null) {
|
||||
return setComments(comments);
|
||||
return withComments(comments);
|
||||
} else {
|
||||
List<String> merged = new ArrayList<String>(comments.size()
|
||||
+ this.commentsOrNull.size());
|
||||
merged.addAll(comments);
|
||||
merged.addAll(this.commentsOrNull);
|
||||
return setComments(merged);
|
||||
return withComments(merged);
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,13 +113,13 @@ final class SimpleConfigOrigin implements ConfigOrigin {
|
||||
if (ConfigImplUtil.equalsHandlingNull(comments, this.commentsOrNull) || comments == null) {
|
||||
return this;
|
||||
} else if (this.commentsOrNull == null) {
|
||||
return setComments(comments);
|
||||
return withComments(comments);
|
||||
} else {
|
||||
List<String> merged = new ArrayList<String>(comments.size()
|
||||
+ this.commentsOrNull.size());
|
||||
merged.addAll(this.commentsOrNull);
|
||||
merged.addAll(comments);
|
||||
return setComments(merged);
|
||||
return withComments(merged);
|
||||
}
|
||||
}
|
||||
|
||||
@ -550,18 +552,4 @@ final class SimpleConfigOrigin implements ConfigOrigin {
|
||||
Map<SerializedField, Object> fields = applyFieldsDelta(baseFields, delta);
|
||||
return fromFields(fields);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigOrigin withComments(List<String> comments) {
|
||||
return this.setComments(comments);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigOrigin withLineNumber(int lineNumber) {
|
||||
if (this.originType == OriginType.GENERIC) {
|
||||
//This type should not have a lineNumber.
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
return this.setLineNumber(lineNumber);
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ final class Tokenizer {
|
||||
this.allowComments = allowComments;
|
||||
this.buffer = new LinkedList<Integer>();
|
||||
lineNumber = 1;
|
||||
lineOrigin = this.origin.setLineNumber(lineNumber);
|
||||
lineOrigin = this.origin.withLineNumber(lineNumber);
|
||||
tokens = new LinkedList<Token>();
|
||||
tokens.add(Tokens.START);
|
||||
whitespaceSaver = new WhitespaceSaver();
|
||||
@ -254,7 +254,7 @@ final class Tokenizer {
|
||||
|
||||
private static ConfigOrigin lineOrigin(ConfigOrigin baseOrigin,
|
||||
int lineNumber) {
|
||||
return ((SimpleConfigOrigin) baseOrigin).setLineNumber(lineNumber);
|
||||
return ((SimpleConfigOrigin) baseOrigin).withLineNumber(lineNumber);
|
||||
}
|
||||
|
||||
// ONE char has always been consumed, either the # or the first /, but
|
||||
@ -446,7 +446,7 @@ final class Tokenizer {
|
||||
else if (c == '\n') {
|
||||
// keep the line number accurate
|
||||
lineNumber += 1;
|
||||
lineOrigin = origin.setLineNumber(lineNumber);
|
||||
lineOrigin = origin.withLineNumber(lineNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@ -549,7 +549,7 @@ final class Tokenizer {
|
||||
// newline tokens have the just-ended line number
|
||||
Token line = Tokens.newLine(lineOrigin);
|
||||
lineNumber += 1;
|
||||
lineOrigin = origin.setLineNumber(lineNumber);
|
||||
lineOrigin = origin.withLineNumber(lineNumber);
|
||||
return line;
|
||||
} else {
|
||||
Token t;
|
||||
|
Loading…
Reference in New Issue
Block a user