mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-04 14:40:53 +00:00
List/Map emptiness checking and stream variation (#11920)
I have changed the way to check for empty maps and lists, instead of checking if the size is greater than 0, It is more understandable and faster using !x.isEmpty() method. Also, instead of using stream().filter().findFirst().isPresent(), it is recomendable using its equivalent stream().anyMatch() which as well makes it easier to understand and efficient.
This commit is contained in:
parent
0a48976ccb
commit
e159919ba5
@ -68,11 +68,11 @@ public class CodegenOperation {
|
|||||||
* @return true if parameter exists, false otherwise
|
* @return true if parameter exists, false otherwise
|
||||||
*/
|
*/
|
||||||
private static boolean nonEmpty(List<?> params) {
|
private static boolean nonEmpty(List<?> params) {
|
||||||
return params != null && params.size() > 0;
|
return params != null && !params.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean nonEmpty(Map<?, ?> params) {
|
private static boolean nonEmpty(Map<?, ?> params) {
|
||||||
return params != null && params.size() > 0;
|
return params != null && !params.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -189,7 +189,7 @@ public class CodegenOperation {
|
|||||||
* @return true if responses contain a default response, false otherwise
|
* @return true if responses contain a default response, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean getHasDefaultResponse() {
|
public boolean getHasDefaultResponse() {
|
||||||
return responses.stream().filter(response -> response.isDefault).findFirst().isPresent();
|
return responses.stream().anyMatch(response -> response.isDefault);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user