Skip to content

Commit

Permalink
core: shouldCopyDefaults() -> getShouldCopyDefaults() to make AutoVal…
Browse files Browse the repository at this point in the history
…ue happy
  • Loading branch information
zml2008 committed Oct 3, 2020
1 parent 06943b7 commit f5d5836
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ protected AbstractConfigurationNode(final @Nullable A parent, final A copyOf) {
*/
static <V> V storeDefault(final ConfigurationNode node, final V defValue) {
requireNonNull(defValue, "defValue");
if (node.getOptions().shouldCopyDefaults()) {
if (node.getOptions().getShouldCopyDefaults()) {
node.setValue(defValue);
}
return defValue;
}

static <V> V storeDefault(final ConfigurationNode node, final Type type, final V defValue) throws ObjectMappingException {
requireNonNull(defValue, "defValue");
if (node.getOptions().shouldCopyDefaults()) {
if (node.getOptions().getShouldCopyDefaults()) {
node.setValue(type, defValue);
}
return defValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ default String getString(final String def) {
if (value != null) {
return value;
}
if (getOptions().shouldCopyDefaults()) {
if (getOptions().getShouldCopyDefaults()) {
setValue(def);
}
return def;
Expand Down Expand Up @@ -662,7 +662,7 @@ default float getFloat(float def) {
if (val != null) {
return val;
}
if (getOptions().shouldCopyDefaults() && def != NUMBER_DEF) {
if (getOptions().getShouldCopyDefaults() && def != NUMBER_DEF) {
setValue(def);
}
return def;
Expand Down Expand Up @@ -690,7 +690,7 @@ default double getDouble(double def) {
if (val != null) {
return val;
}
if (getOptions().shouldCopyDefaults() && def != NUMBER_DEF) {
if (getOptions().getShouldCopyDefaults() && def != NUMBER_DEF) {
setValue(def);
}
return def;
Expand Down Expand Up @@ -718,7 +718,7 @@ default int getInt(int def) {
if (val != null) {
return val;
}
if (getOptions().shouldCopyDefaults() && def != NUMBER_DEF) {
if (getOptions().getShouldCopyDefaults() && def != NUMBER_DEF) {
setValue(def);
}
return def;
Expand Down Expand Up @@ -746,7 +746,7 @@ default long getLong(long def) {
if (val != null) {
return val;
}
if (getOptions().shouldCopyDefaults() && def != NUMBER_DEF) {
if (getOptions().getShouldCopyDefaults() && def != NUMBER_DEF) {
setValue(def);
}
return def;
Expand Down Expand Up @@ -774,7 +774,7 @@ default boolean getBoolean(boolean def) {
if (val != null) {
return val;
}
if (getOptions().shouldCopyDefaults()) {
if (getOptions().getShouldCopyDefaults()) {
setValue(def);
}
return def;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public ConfigurationOptions withMapFactory(final MapFactory mapFactory) {
return this;
}
return new AutoValue_ConfigurationOptions(mapFactory, getHeader(), getSerializers(), getNativeTypes(),
shouldCopyDefaults(), isImplicitInitialization());
getShouldCopyDefaults(), isImplicitInitialization());
}

/**
Expand All @@ -110,7 +110,7 @@ public ConfigurationOptions withHeader(final @Nullable String header) {
return this;
}
return new AutoValue_ConfigurationOptions(getMapFactory(), header, getSerializers(), getNativeTypes(),
shouldCopyDefaults(), isImplicitInitialization());
getShouldCopyDefaults(), isImplicitInitialization());
}

/**
Expand All @@ -133,7 +133,7 @@ public ConfigurationOptions withSerializers(final TypeSerializerCollection seria
return this;
}
return new AutoValue_ConfigurationOptions(getMapFactory(), getHeader(), serializers, getNativeTypes(),
shouldCopyDefaults(), isImplicitInitialization());
getShouldCopyDefaults(), isImplicitInitialization());
}

/**
Expand Down Expand Up @@ -211,7 +211,7 @@ public ConfigurationOptions withNativeTypes(final @Nullable Set<Class<?>> native
return this;
}
return new AutoValue_ConfigurationOptions(getMapFactory(), getHeader(), getSerializers(),
nativeTypes == null ? null : UnmodifiableCollections.copyOf(nativeTypes), shouldCopyDefaults(), isImplicitInitialization());
nativeTypes == null ? null : UnmodifiableCollections.copyOf(nativeTypes), getShouldCopyDefaults(), isImplicitInitialization());
}

/**
Expand All @@ -220,19 +220,19 @@ public ConfigurationOptions withNativeTypes(final @Nullable Set<Class<?>> native
*
* @return Whether defaults should be copied into value
*/
public abstract boolean shouldCopyDefaults();
public abstract boolean getShouldCopyDefaults();

/**
* Creates a new {@link ConfigurationOptions} instance, with the specified
* 'copy defaults' setting set, and all other settings copied from
* this instance.
*
* @see #shouldCopyDefaults() for information on what this method does
* @see #getShouldCopyDefaults() for information on what this method does
* @param shouldCopyDefaults whether to copy defaults
* @return updated options object
*/
public ConfigurationOptions withShouldCopyDefaults(final boolean shouldCopyDefaults) {
if (this.shouldCopyDefaults() == shouldCopyDefaults) {
if (this.getShouldCopyDefaults() == shouldCopyDefaults) {
return this;
}

Expand Down Expand Up @@ -267,7 +267,7 @@ public ConfigurationOptions withImplicitInitialization(final boolean implicitIni
}

return new AutoValue_ConfigurationOptions(getMapFactory(), getHeader(), getSerializers(), getNativeTypes(),
shouldCopyDefaults(), implicitInitialization);
getShouldCopyDefaults(), implicitInitialization);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ final V load0(final ConfigurationNode source, final CheckedFunction<I, V, Object
// load field into intermediate object
field.deserializer().accept(intermediate, newVal, implicitInitializer);

if (newVal == null && source.getOptions().shouldCopyDefaults()) {
if (newVal == null && source.getOptions().getShouldCopyDefaults()) {
if (unseenFields == null) {
unseenFields = new ArrayList<>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class ValueReferenceImpl<@Nullable T, N extends ScopedConfigurationNode<N>> impl
final @Nullable T possible = this.serializer.deserialize(this.type.getType(), node);
if (possible != null) {
return possible;
} else if (defaultVal != null && node.getOptions().shouldCopyDefaults()) {
} else if (defaultVal != null && node.getOptions().getShouldCopyDefaults()) {
this.serializer.serialize(this.type.getType(), defaultVal, node);
}
return defaultVal;
Expand Down

0 comments on commit f5d5836

Please sign in to comment.