Skip to content

Commit adbdcd6

Browse files
committed
fix nullable warning
1 parent 772833a commit adbdcd6

2 files changed

Lines changed: 27 additions & 19 deletions

File tree

openapi-parser/src/main/java/io/openapiparser/model/v30/PathItem.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,42 +49,42 @@ public PathItem getRefObject () {
4949
}
5050

5151
public @Nullable Operation getGet () {
52-
return getOperation (GET);
52+
return getOperationOrNull(GET);
5353
}
5454

5555
public @Nullable Operation getPut () {
56-
return getOperation (PUT);
56+
return getOperationOrNull(PUT);
5757
}
5858

5959
public @Nullable Operation getPost () {
60-
return getOperation (POST);
60+
return getOperationOrNull(POST);
6161
}
6262

6363
public @Nullable Operation getDelete () {
64-
return getOperation (DELETE);
64+
return getOperationOrNull(DELETE);
6565
}
6666

6767
public @Nullable Operation getOptions () {
68-
return getOperation (OPTIONS);
68+
return getOperationOrNull(OPTIONS);
6969
}
7070

7171
public @Nullable Operation getHead () {
72-
return getOperation (HEAD);
72+
return getOperationOrNull(HEAD);
7373
}
7474

7575
public @Nullable Operation getPatch () {
76-
return getOperation (PATCH);
76+
return getOperationOrNull(PATCH);
7777
}
7878

7979
public @Nullable Operation getTrace () {
80-
return getOperation (TRACE);
80+
return getOperationOrNull(TRACE);
8181
}
8282

8383
public Map<String, Operation> getOperations () {
8484
Map<String, Operation> operations = new LinkedHashMap<>();
8585
bucket.forEach ((operation, value) -> {
8686
if (OPERATIONS.contains (operation)) {
87-
operations.put(operation, getOperation (operation));
87+
operations.put(operation, getOperation(operation));
8888
}
8989
});
9090
return Collections.unmodifiableMap (operations);
@@ -98,7 +98,11 @@ public Collection<Parameter> getParameters () {
9898
return getObjectsOrEmpty (PARAMETERS, Parameter.class);
9999
}
100100

101-
private @Nullable Operation getOperation(String property) {
101+
private Operation getOperation(String property) {
102+
return getObjectOrThrow (property, Operation.class);
103+
}
104+
105+
private @Nullable Operation getOperationOrNull(String property) {
102106
return getObjectOrNull (property, Operation.class);
103107
}
104108

openapi-parser/src/main/java/io/openapiparser/model/v31/PathItem.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,35 +51,35 @@ public PathItem getRefObject () {
5151
}
5252

5353
public @Nullable Operation getGet () {
54-
return getOperation (GET);
54+
return getOperationOrNull(GET);
5555
}
5656

5757
public @Nullable Operation getPut () {
58-
return getOperation (PUT);
58+
return getOperationOrNull(PUT);
5959
}
6060

6161
public @Nullable Operation getPost () {
62-
return getOperation (POST);
62+
return getOperationOrNull(POST);
6363
}
6464

6565
public @Nullable Operation getDelete () {
66-
return getOperation (DELETE);
66+
return getOperationOrNull(DELETE);
6767
}
6868

6969
public @Nullable Operation getOptions () {
70-
return getOperation (OPTIONS);
70+
return getOperationOrNull(OPTIONS);
7171
}
7272

7373
public @Nullable Operation getHead () {
74-
return getOperation (HEAD);
74+
return getOperationOrNull(HEAD);
7575
}
7676

7777
public @Nullable Operation getPatch () {
78-
return getOperation (PATCH);
78+
return getOperationOrNull(PATCH);
7979
}
8080

8181
public @Nullable Operation getTrace () {
82-
return getOperation (TRACE);
82+
return getOperationOrNull(TRACE);
8383
}
8484

8585
public Map<String, Operation> getOperations () {
@@ -100,7 +100,11 @@ public Collection<Parameter> getParameters () {
100100
return getObjectsOrEmpty (PARAMETERS, Parameter.class);
101101
}
102102

103-
private @Nullable Operation getOperation(String property) {
103+
private Operation getOperation(String property) {
104+
return getObjectOrThrow (property, Operation.class);
105+
}
106+
107+
private @Nullable Operation getOperationOrNull(String property) {
104108
return getObjectOrNull (property, Operation.class);
105109
}
106110

0 commit comments

Comments
 (0)