Skip to content

Commit 2e4f724

Browse files
author
Chales Queiroz
committed
Replace Hashtable with LinkedHashMap in view response creation methods
Changed Hashtable to LinkedHashMap in various response creation methods within ViewResponseHelper class. This modification ensures an ordered iteration which is beneficial for scenarios where the insertion order of responses needs to be maintained consistently.
1 parent 7b6f452 commit 2e4f724

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

server/src/main/java/com/cloud/api/query/ViewResponseHelper.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public static List<UserVmResponse> createUserVmResponse(ResponseView view, Strin
169169

170170
public static List<DomainRouterResponse> createDomainRouterResponse(DomainRouterJoinVO... routers) {
171171
Account caller = CallContext.current().getCallingAccount();
172-
Hashtable<Long, DomainRouterResponse> vrDataList = new Hashtable<Long, DomainRouterResponse>();
172+
LinkedHashMap<Long, DomainRouterResponse> vrDataList = new LinkedHashMap<>();
173173
// Initialise the vrdatalist with the input data
174174
for (DomainRouterJoinVO vr : routers) {
175175
DomainRouterResponse vrData = vrDataList.get(vr.getId());
@@ -187,7 +187,7 @@ public static List<DomainRouterResponse> createDomainRouterResponse(DomainRouter
187187

188188
public static List<SecurityGroupResponse> createSecurityGroupResponses(List<SecurityGroupJoinVO> securityGroups) {
189189
Account caller = CallContext.current().getCallingAccount();
190-
Hashtable<Long, SecurityGroupResponse> vrDataList = new Hashtable<Long, SecurityGroupResponse>();
190+
LinkedHashMap<Long, SecurityGroupResponse> vrDataList = new LinkedHashMap<>();
191191
// Initialise the vrdatalist with the input data
192192
for (SecurityGroupJoinVO vr : securityGroups) {
193193
SecurityGroupResponse vrData = vrDataList.get(vr.getId());
@@ -205,7 +205,7 @@ public static List<SecurityGroupResponse> createSecurityGroupResponses(List<Secu
205205
}
206206

207207
public static List<ProjectResponse> createProjectResponse(EnumSet<DomainDetails> details, ProjectJoinVO... projects) {
208-
Hashtable<Long, ProjectResponse> prjDataList = new Hashtable<Long, ProjectResponse>();
208+
LinkedHashMap<Long, ProjectResponse> prjDataList = new LinkedHashMap<>();
209209
// Initialise the prjdatalist with the input data
210210
for (ProjectJoinVO p : projects) {
211211
ProjectResponse pData = prjDataList.get(p.getId());
@@ -247,7 +247,7 @@ public static List<ProjectInvitationResponse> createProjectInvitationResponse(Pr
247247
}
248248

249249
public static List<HostResponse> createHostResponse(EnumSet<HostDetails> details, HostJoinVO... hosts) {
250-
Hashtable<Long, HostResponse> vrDataList = new Hashtable<Long, HostResponse>();
250+
LinkedHashMap<Long, HostResponse> vrDataList = new LinkedHashMap<>();
251251
// Initialise the vrdatalist with the input data
252252
for (HostJoinVO vr : hosts) {
253253
HostResponse vrData = ApiDBUtils.newHostResponse(vr, details);
@@ -257,7 +257,7 @@ public static List<HostResponse> createHostResponse(EnumSet<HostDetails> details
257257
}
258258

259259
public static List<HostForMigrationResponse> createHostForMigrationResponse(EnumSet<HostDetails> details, HostJoinVO... hosts) {
260-
Hashtable<Long, HostForMigrationResponse> vrDataList = new Hashtable<Long, HostForMigrationResponse>();
260+
LinkedHashMap<Long, HostForMigrationResponse> vrDataList = new LinkedHashMap<>();
261261
// Initialise the vrdatalist with the input data
262262
for (HostJoinVO vr : hosts) {
263263
HostForMigrationResponse vrData = ApiDBUtils.newHostForMigrationResponse(vr, details);
@@ -267,7 +267,7 @@ public static List<HostForMigrationResponse> createHostForMigrationResponse(Enum
267267
}
268268

269269
public static List<VolumeResponse> createVolumeResponse(ResponseView view, VolumeJoinVO... volumes) {
270-
Hashtable<Long, VolumeResponse> vrDataList = new Hashtable<Long, VolumeResponse>();
270+
LinkedHashMap<Long, VolumeResponse> vrDataList = new LinkedHashMap<>();
271271
DecimalFormat df = new DecimalFormat("0.0%");
272272
for (VolumeJoinVO vr : volumes) {
273273
VolumeResponse vrData = vrDataList.get(vr.getId());
@@ -308,7 +308,7 @@ public static List<VolumeResponse> createVolumeResponse(ResponseView view, Volum
308308
}
309309

310310
public static List<StoragePoolResponse> createStoragePoolResponse(StoragePoolJoinVO... pools) {
311-
Hashtable<Long, StoragePoolResponse> vrDataList = new Hashtable<Long, StoragePoolResponse>();
311+
LinkedHashMap<Long, StoragePoolResponse> vrDataList = new LinkedHashMap<>();
312312
// Initialise the vrdatalist with the input data
313313
for (StoragePoolJoinVO vr : pools) {
314314
StoragePoolResponse vrData = vrDataList.get(vr.getId());
@@ -345,7 +345,7 @@ public static List<HostTagResponse> createHostTagResponse(HostTagVO... hostTags)
345345
}
346346

347347
public static List<ImageStoreResponse> createImageStoreResponse(ImageStoreJoinVO... stores) {
348-
Hashtable<Long, ImageStoreResponse> vrDataList = new Hashtable<Long, ImageStoreResponse>();
348+
LinkedHashMap<Long, ImageStoreResponse> vrDataList = new LinkedHashMap<>();
349349
// Initialise the vrdatalist with the input data
350350
for (ImageStoreJoinVO vr : stores) {
351351
ImageStoreResponse vrData = vrDataList.get(vr.getId());
@@ -362,7 +362,7 @@ public static List<ImageStoreResponse> createImageStoreResponse(ImageStoreJoinVO
362362
}
363363

364364
public static List<StoragePoolResponse> createStoragePoolForMigrationResponse(StoragePoolJoinVO... pools) {
365-
Hashtable<Long, StoragePoolResponse> vrDataList = new Hashtable<Long, StoragePoolResponse>();
365+
LinkedHashMap<Long, StoragePoolResponse> vrDataList = new LinkedHashMap<>();
366366
// Initialise the vrdatalist with the input data
367367
for (StoragePoolJoinVO vr : pools) {
368368
StoragePoolResponse vrData = vrDataList.get(vr.getId());
@@ -577,7 +577,7 @@ public static List<ZoneResponse> createDataCenterResponse(ResponseView view, Boo
577577
}
578578

579579
public static List<TemplateResponse> createTemplateResponse(EnumSet<ApiConstants.DomainDetails> detailsView, ResponseView view, TemplateJoinVO... templates) {
580-
LinkedHashMap<String, TemplateResponse> vrDataList = new LinkedHashMap<String, TemplateResponse>();
580+
LinkedHashMap<String, TemplateResponse> vrDataList = new LinkedHashMap<>();
581581
for (TemplateJoinVO vr : templates) {
582582
TemplateResponse vrData = vrDataList.get(vr.getTempZonePair());
583583
if (vrData == null) {
@@ -594,7 +594,7 @@ public static List<TemplateResponse> createTemplateResponse(EnumSet<ApiConstants
594594
}
595595

596596
public static List<TemplateResponse> createTemplateUpdateResponse(ResponseView view, TemplateJoinVO... templates) {
597-
Hashtable<Long, TemplateResponse> vrDataList = new Hashtable<Long, TemplateResponse>();
597+
LinkedHashMap<Long, TemplateResponse> vrDataList = new LinkedHashMap<>();
598598
for (TemplateJoinVO vr : templates) {
599599
TemplateResponse vrData = vrDataList.get(vr.getId());
600600
if (vrData == null) {
@@ -610,7 +610,7 @@ public static List<TemplateResponse> createTemplateUpdateResponse(ResponseView v
610610
}
611611

612612
public static List<TemplateResponse> createIsoResponse(ResponseView view, TemplateJoinVO... templates) {
613-
LinkedHashMap<String, TemplateResponse> vrDataList = new LinkedHashMap<String, TemplateResponse>();
613+
LinkedHashMap<String, TemplateResponse> vrDataList = new LinkedHashMap<>();
614614
for (TemplateJoinVO vr : templates) {
615615
TemplateResponse vrData = vrDataList.get(vr.getTempZonePair());
616616
if (vrData == null) {
@@ -626,7 +626,7 @@ public static List<TemplateResponse> createIsoResponse(ResponseView view, Templa
626626
}
627627

628628
public static List<AffinityGroupResponse> createAffinityGroupResponses(List<AffinityGroupJoinVO> groups) {
629-
Hashtable<Long, AffinityGroupResponse> vrDataList = new Hashtable<Long, AffinityGroupResponse>();
629+
LinkedHashMap<Long, AffinityGroupResponse> vrDataList = new LinkedHashMap<>();
630630
for (AffinityGroupJoinVO vr : groups) {
631631
AffinityGroupResponse vrData = vrDataList.get(vr.getId());
632632
if (vrData == null) {

0 commit comments

Comments
 (0)