Skip to content

Commit

Permalink
delete class DoubleParser
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Lou <[email protected]>
  • Loading branch information
mloufra committed Jan 23, 2023
1 parent 1169cc5 commit 6703aea
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 74 deletions.

This file was deleted.

36 changes: 30 additions & 6 deletions server/src/main/java/org/opensearch/common/settings/Setting.java
Original file line number Diff line number Diff line change
Expand Up @@ -1312,8 +1312,8 @@ public FloatParser(String key, float minValue, float maxValue, boolean isFiltere
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(key);
out.writeDouble(minValue);
out.writeDouble(maxValue);
out.writeFloat(minValue);
out.writeFloat(maxValue);
out.writeBoolean(isFiltered);
}

Expand Down Expand Up @@ -1441,8 +1441,8 @@ public IntegerParser(String key, int minValue, int maxValue, boolean isFiltered)
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(key);
out.writeDouble(minValue);
out.writeDouble(maxValue);
out.writeInt(minValue);
out.writeInt(maxValue);
out.writeBoolean(isFiltered);
}

Expand Down Expand Up @@ -1562,8 +1562,8 @@ public LongParser(String key, long minValue, long maxValue, boolean isFiltered)
@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(key);
out.writeDouble(minValue);
out.writeDouble(maxValue);
out.writeLong(minValue);
out.writeLong(maxValue);
out.writeBoolean(isFiltered);
}

Expand Down Expand Up @@ -2184,6 +2184,30 @@ public static Setting<TimeValue> timeSetting(
);
}

private static class TimeValueParser implements Function<Settings, TimeValue>, Writeable {
private String key;
private TimeValue minValue;
private boolean isFiltered;

public TimeValueParser(String key, TimeValue minValue, boolean isFiltered) {
this.key = key;
this.minValue = minValue;
this.isFiltered = isFiltered;
}

@Override
public void writeTo(StreamOutput out) throws IOException {
out.writeString(key);
out.writeTimeValue(minValue);
out.writeBoolean(isFiltered);
}

@Override
public TimeValue apply(Settings t) {
return parseTimeValue(t, minValue, key, isFiltered);
}
}

public static Setting<TimeValue> timeSetting(
final String key,
Function<Settings, TimeValue> defaultValue,
Expand Down

0 comments on commit 6703aea

Please sign in to comment.