Skip to content

Commit 21d509a

Browse files
committed
make the code more readable, add comments
1 parent 5d758fc commit 21d509a

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

api/src/main/java/org/apache/cloudstack/api/command/admin/resource/ListCapacityCmd.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,16 @@ public void execute() {
127127
Collections.sort(capacityResponses, new Comparator<CapacityResponse>() {
128128
public int compare(CapacityResponse resp1, CapacityResponse resp2) {
129129
int res = resp1.getZoneName().compareTo(resp2.getZoneName());
130+
// Group by zone
130131
if (res != 0) {
131132
return res;
132-
} else if (getSortBy() != null) {
133-
return 0;
134-
} else {
135-
return resp1.getCapacityType().compareTo(resp2.getCapacityType());
136133
}
134+
// Sort by capacity type only if not already sorted by usage
135+
return (getSortBy() != null) ? 0 : resp1.getCapacityType().compareTo(resp2.getCapacityType());
137136
}
138137
});
139138

139+
140140
response.setResponses(capacityResponses);
141141
response.setResponseName(getCommandName());
142142
this.setResponseObject(response);

0 commit comments

Comments
 (0)