amarkevich commented on a change in pull request #419: [CXF-7743] wadl2java: 
generate throws declaration for fault response
URL: https://github.com/apache/cxf/pull/419#discussion_r190556386
 
 

 ##########
 File path: 
tools/wadlto/jaxrs/src/main/java/org/apache/cxf/tools/wadlto/jaxrs/SourceGenerator.java
 ##########
 @@ -1203,20 +1211,26 @@ private void writeJaxrResponse(StringBuilder sbCode, 
Set<String> imports) {
         sbCode.append(Response.class.getSimpleName()).append(" ");
     }
 
-    private Element getOKResponse(List<Element> responseEls) {
-        for (int i = 0; i < responseEls.size(); i++) {
-            String statusValue = responseEls.get(i).getAttribute("status");
-            if (statusValue.length() == 0) {
-                return responseEls.get(i);
-            }
-            String[] statuses = statusValue.split("\\s");
-            for (String status : statuses) {
-                if (HTTP_OK_STATUSES.contains(status)) {
-                    return responseEls.get(i);
+    private static Element getOKResponse(List<Element> responseEls) {
+        final List<Element> result = getResponses(responseEls, 
HTTP_OK_STATUSES);
+        return !result.isEmpty() ? result.get(0) : null;
+    }
+
+    private static List<Element> getErrorResponses(List<Element> responseEls) {
+        return getResponses(responseEls, HTTP_ERROR_STATUSES);
+    }
+
+    private static List<Element> getResponses(List<Element> responseEls, 
Predicate<Integer> checker) {
+        final List<Element> result = new ArrayList<>();
+        for (Element responseEl : responseEls) {
+            for (String statusValue : 
responseEl.getAttribute("status").split("\\s")) {
 
 Review comment:
   getAttribute returns empty string in case attribute missing; 
statusValue.isEmpty() -> 200

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to