-
-
Notifications
You must be signed in to change notification settings - Fork 755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add Espresso options #1563
Conversation
return options == null | ||
? Optional.empty() | ||
: Optional.ofNullable((R) options.getOrDefault(name, null)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return options == null | |
? Optional.empty() | |
: Optional.ofNullable((R) options.getOrDefault(name, null)); | |
return Optional.ofNullable(options).map(opts -> (R) opts.getOrDefault(name, null)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
} | ||
|
||
public Map<String, Object> toMap() { | ||
return options == null ? Collections.emptyMap() : options; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return options == null ? Collections.emptyMap() : options; | |
return Optional.ofNullable(options).orElseGet(Collections::emptyMap); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
if (value instanceof Number) { | ||
toolsVersions.addProperty(name, (Number) value); | ||
} else { | ||
toolsVersions.addProperty(name, String.valueOf(value)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (value instanceof Number) { | |
toolsVersions.addProperty(name, (Number) value); | |
} else { | |
toolsVersions.addProperty(name, String.valueOf(value)); | |
} | |
toolsVersions.addProperty(name, value instanceof Number ? (Number) value : String.valueOf(value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried. Java compiler does not like that
} | ||
|
||
public JsonObject toJson() { | ||
return json == null ? new JsonObject() : json; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return json == null ? new JsonObject() : json; | |
return Optional.ofNullable(json).orElseGet(JsonObject::new); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the previous option was shorter, but changed anyway
public Optional<Map<String, Integer>> getEi() { | ||
Optional<Map<String, Object>> value = getOptionValue("ei"); | ||
return value.map((v) -> v.entrySet().stream() | ||
.collect(Collectors.toMap( | ||
Map.Entry::getKey, (entry) -> Integer.parseInt(String.valueOf(entry.getValue()))) | ||
) | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public Optional<Map<String, Integer>> getEi() { | |
Optional<Map<String, Object>> value = getOptionValue("ei"); | |
return value.map((v) -> v.entrySet().stream() | |
.collect(Collectors.toMap( | |
Map.Entry::getKey, (entry) -> Integer.parseInt(String.valueOf(entry.getValue()))) | |
) | |
); | |
} | |
public Optional<Map<String, Integer>> getEi() { | |
Optional<Map<String, Object>> value = getOptionValue("ei"); | |
return value.map((v) -> convertMapValues(v, Integer::parseInt)); | |
} | |
private <T> Map<String, T> convertMapValues(Map<String, Object> map, Function<String, T> converter) { | |
return map.entrySet().stream().collect( | |
Collectors.toMap(Map.Entry::getKey, (entry) -> converter.apply(String.valueOf(entry.getValue())))); | |
} |
and then convertMapValues
can be reused in the methods converting to Long
, Float
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
Change list
Added a separate Option class to represent Espresso driver caps and updated the related tests.
Types of changes