Closed
Description
putting Try
and of
on separate lines here seems weird.
Input:
private static <T extends Group> Function<Constructor<?>, T> createInstance(Group entity) {
return ctor -> Try.of(() -> {
@SuppressWarnings("unchecked")
var ng = (T) ctor.newInstance(entity.getId(), entity.getSystemGenerated(), entity.getVersionKey());
return ng;
})
.getOrElseThrow(ex -> new RuntimeException(ex));
}
Output:
private static <T extends Group> Function<Constructor<?>, T> createInstance(Group entity) {
return ctor ->
Try
.of(() -> {
@SuppressWarnings("unchecked")
var ng = (T) ctor.newInstance(entity.getId(), entity.getSystemGenerated(), entity.getVersionKey());
return ng;
})
.getOrElseThrow(ex -> new RuntimeException(ex));
}
Expected behavior:
private static <T extends Group> Function<Constructor<?>, T> createInstance(Group entity) {
return ctor ->
Try.of(() -> {
@SuppressWarnings("unchecked")
var ng = (T) ctor.newInstance(entity.getId(), entity.getSystemGenerated(), entity.getVersionKey());
return ng;
})
.getOrElseThrow(ex -> new RuntimeException(ex));
}
or perhaps even this since the return is implicit.
return ctor -> Try.of(() -> {
Configuration:
"dependencies": {
"prettier": "^3.1.1",
"prettier-plugin-java": "^2.5.0"
}
printWidth: 120
plugins:
- prettier-plugin-java
root = true
[*]
trim_trailing_whitespace = true
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2
[*.bat]
end_of_line = crlf
Metadata
Metadata
Assignees
Labels
No labels