cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject git commit: updated refs/heads/master to 89017a7
Date Wed, 30 Jul 2014 17:36:44 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 42a861e59 -> 89017a7d7


CS-19072: got rid of unneeded type casting when apply pagination to different resources


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/89017a7d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/89017a7d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/89017a7d

Branch: refs/heads/master
Commit: 89017a7d7b134993cfab45840de0dc481552e2a2
Parents: 42a861e
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Wed Jul 30 10:33:45 2014 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Wed Jul 30 10:33:45 2014 -0700

----------------------------------------------------------------------
 .../configuration/ConfigurationManagerImpl.java | 10 ++++------
 .../com/cloud/network/NetworkServiceImpl.java   |  5 ++---
 .../com/cloud/network/vpc/VpcManagerImpl.java   | 20 ++++++++------------
 utils/src/com/cloud/utils/StringUtils.java      | 10 +++++-----
 4 files changed, 19 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/89017a7d/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 388fc06..bcd87da 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -4487,18 +4487,16 @@ public class ConfigurationManagerImpl extends ManagerBase implements
Configurati
             }
 
             // Now apply pagination
-            List<?> wPagination = StringUtils.applyPagination(supportedOfferings, cmd.getStartIndex(),
cmd.getPageSizeVal());
+            List<? extends NetworkOffering> wPagination = StringUtils.applyPagination(supportedOfferings,
cmd.getStartIndex(), cmd.getPageSizeVal());
             if (wPagination != null) {
-                @SuppressWarnings("unchecked")
-                Pair<List<? extends NetworkOffering>, Integer> listWPagination
= new Pair<List<? extends NetworkOffering>, Integer>((List<NetworkOffering>)
wPagination, offerings.size());
+                Pair<List<? extends NetworkOffering>, Integer> listWPagination
= new Pair<List<? extends NetworkOffering>, Integer>(wPagination, offerings.size());
                 return listWPagination;
             }
             return new Pair<List<? extends NetworkOffering>, Integer>(supportedOfferings,
supportedOfferings.size());
         } else {
-            List<?> wPagination = StringUtils.applyPagination(offerings, cmd.getStartIndex(),
cmd.getPageSizeVal());
+            List<? extends NetworkOffering> wPagination = StringUtils.applyPagination(offerings,
cmd.getStartIndex(), cmd.getPageSizeVal());
             if (wPagination != null) {
-                @SuppressWarnings("unchecked")
-                Pair<List<? extends NetworkOffering>, Integer> listWPagination
= new Pair<List<? extends NetworkOffering>, Integer>((List<NetworkOffering>)
wPagination, offerings.size());
+                Pair<List<? extends NetworkOffering>, Integer> listWPagination
= new Pair<List<? extends NetworkOffering>, Integer>(wPagination, offerings.size());
                 return listWPagination;
             }
             return new Pair<List<? extends NetworkOffering>, Integer>(offerings,
offerings.size());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/89017a7d/server/src/com/cloud/network/NetworkServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java
index 4ac1bea..9d1fc66 100755
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@ -1623,10 +1623,9 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService
{
         }
 
         //Now apply pagination
-        List<?> wPagination = StringUtils.applyPagination(networksToReturn, cmd.getStartIndex(),
cmd.getPageSizeVal());
+        List<? extends Network> wPagination = StringUtils.applyPagination(networksToReturn,
cmd.getStartIndex(), cmd.getPageSizeVal());
         if (wPagination != null) {
-            @SuppressWarnings("unchecked")
-            Pair<List<? extends Network>, Integer> listWPagination = new Pair<List<?
extends Network>, Integer>((List<NetworkVO>) wPagination, networksToReturn.size());
+            Pair<List<? extends Network>, Integer> listWPagination = new Pair<List<?
extends Network>, Integer>(wPagination, networksToReturn.size());
             return listWPagination;
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/89017a7d/server/src/com/cloud/network/vpc/VpcManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
index 5a90233..d58c0a4 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -671,18 +671,16 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
                 }
             }
 
-            List<?> wPagination = StringUtils.applyPagination(supportedOfferings, startIndex,
pageSizeVal);
+            List<? extends VpcOffering> wPagination = StringUtils.applyPagination(supportedOfferings,
startIndex, pageSizeVal);
             if (wPagination != null) {
-                @SuppressWarnings("unchecked")
-                Pair<List<? extends VpcOffering>, Integer> listWPagination =
new Pair<List<? extends VpcOffering>, Integer>((List<VpcOffering>) wPagination,
supportedOfferings.size());
+                Pair<List<? extends VpcOffering>, Integer> listWPagination =
new Pair<List<? extends VpcOffering>, Integer>(wPagination, supportedOfferings.size());
                 return listWPagination;
             }
             return new Pair<List<? extends VpcOffering>, Integer>(supportedOfferings,
supportedOfferings.size());
         } else {
-            List<?> wPagination = StringUtils.applyPagination(offerings, startIndex,
pageSizeVal);
+            List<? extends VpcOffering> wPagination = StringUtils.applyPagination(offerings,
startIndex, pageSizeVal);
             if (wPagination != null) {
-                @SuppressWarnings("unchecked")
-                Pair<List<? extends VpcOffering>, Integer> listWPagination =
new Pair<List<? extends VpcOffering>, Integer>((List<VpcOffering>) wPagination,
offerings.size());
+                Pair<List<? extends VpcOffering>, Integer> listWPagination =
new Pair<List<? extends VpcOffering>, Integer>(wPagination, offerings.size());
                 return listWPagination;
             }
             return new Pair<List<? extends VpcOffering>, Integer>(offerings,
offerings.size());
@@ -1128,18 +1126,16 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
                 }
             }
 
-            List<?> wPagination = StringUtils.applyPagination(supportedVpcs, startIndex,
pageSizeVal);
+            List<? extends Vpc> wPagination = StringUtils.applyPagination(supportedVpcs,
startIndex, pageSizeVal);
             if (wPagination != null) {
-                @SuppressWarnings("unchecked")
-                Pair<List<? extends Vpc>, Integer> listWPagination = new Pair<List<?
extends Vpc>, Integer>((List<Vpc>) wPagination, supportedVpcs.size());
+                Pair<List<? extends Vpc>, Integer> listWPagination = new Pair<List<?
extends Vpc>, Integer>(wPagination, supportedVpcs.size());
                 return listWPagination;
             }
             return new Pair<List<? extends Vpc>, Integer>(supportedVpcs, supportedVpcs.size());
         } else {
-            List<?> wPagination = StringUtils.applyPagination(vpcs, startIndex, pageSizeVal);
+            List<? extends Vpc> wPagination = StringUtils.applyPagination(vpcs, startIndex,
pageSizeVal);
             if (wPagination != null) {
-                @SuppressWarnings("unchecked")
-                Pair<List<? extends Vpc>, Integer> listWPagination = new Pair<List<?
extends Vpc>, Integer>((List<Vpc>) wPagination, vpcs.size());
+                Pair<List<? extends Vpc>, Integer> listWPagination = new Pair<List<?
extends Vpc>, Integer>(wPagination, vpcs.size());
                 return listWPagination;
             }
             return new Pair<List<? extends Vpc>, Integer>(vpcs, vpcs.size());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/89017a7d/utils/src/com/cloud/utils/StringUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/StringUtils.java b/utils/src/com/cloud/utils/StringUtils.java
index f4c3f9e..17b8fc0 100644
--- a/utils/src/com/cloud/utils/StringUtils.java
+++ b/utils/src/com/cloud/utils/StringUtils.java
@@ -269,16 +269,16 @@ public class StringUtils {
         return s;
     }
 
-    public static List<?> applyPagination(List<?> originalList, Long startIndex,
Long pageSizeVal) {
+    public static <T> List<T> applyPagination(List<T> originalList, Long
startIndex, Long pageSizeVal) {
         // Most likely pageSize will never exceed int value, and we need integer to partition
the listToReturn
         boolean applyPagination = startIndex != null && pageSizeVal != null
                 && startIndex <= Integer.MAX_VALUE && startIndex >=
Integer.MIN_VALUE && pageSizeVal <= Integer.MAX_VALUE
                 && pageSizeVal >= Integer.MIN_VALUE;
-        List<?> listWPagination = null;
+        List<T> listWPagination = null;
         if (applyPagination) {
             listWPagination = new ArrayList<>();
             int index = startIndex.intValue() == 0 ? 0 : startIndex.intValue() / pageSizeVal.intValue();
-            List<List<?>> partitions = StringUtils.partitionList(originalList,
pageSizeVal.intValue());
+            List<List<T>> partitions = StringUtils.partitionList(originalList,
pageSizeVal.intValue());
             if (index < partitions.size()) {
                 listWPagination = partitions.get(index);
             }
@@ -286,8 +286,8 @@ public class StringUtils {
         return listWPagination;
     }
 
-    private static List<List<?>> partitionList(List<?> originalList, int
chunkSize) {
-        List<List<?>> listOfChunks = new ArrayList<List<?>>();
+    private static <T> List<List<T>> partitionList(List<T> originalList,
int chunkSize) {
+        List<List<T>> listOfChunks = new ArrayList<List<T>>();
         for (int i = 0; i < originalList.size() / chunkSize; i++) {
             listOfChunks.add(originalList.subList(i * chunkSize, i * chunkSize + chunkSize));
         }


Mime
View raw message