X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fnorthbound%2Fnetworkconfiguration%2Fneutron%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetworkconfig%2Fneutron%2Fnorthbound%2FPaginatedRequestFactory.java;h=5f9653f9029776b6a8f75892502de265908d086e;hb=b17a51ecb983331f0e521e40f9dd2474f268de13;hp=8f05e76e1839d9c10d630635f2e4d160b43a9908;hpb=17d82f582a6bc13c78be3b19954ff8c021180e93;p=controller.git diff --git a/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/PaginatedRequestFactory.java b/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/PaginatedRequestFactory.java index 8f05e76e18..5f9653f902 100644 --- a/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/PaginatedRequestFactory.java +++ b/opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/PaginatedRequestFactory.java @@ -10,6 +10,11 @@ package org.opendaylight.controller.networkconfig.neutron.northbound; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import javax.ws.rs.core.UriInfo; import org.opendaylight.controller.networkconfig.neutron.INeutronObject; import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork; import org.opendaylight.controller.networkconfig.neutron.NeutronPort; @@ -17,12 +22,6 @@ import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet; import org.opendaylight.controller.northbound.commons.exception.BadRequestException; import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException; -import javax.ws.rs.core.UriInfo; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - public class PaginatedRequestFactory { public static class PaginationResults { @@ -35,26 +34,33 @@ public class PaginatedRequestFactory { } } - public static INeutronRequest createRequest(Integer limit, String marker, + /* + * SuppressWarnings is needed because the compiler does not understand that we + * are actually safe here. + * + * FIXME: the only caller performs a cast back, so this is not actually necessary. + */ + @SuppressWarnings("unchecked") + public static INeutronRequest createRequest(Integer limit, String marker, Boolean pageReverse, UriInfo uriInfo, List collection, Class clazz) { - PaginationResults results = _paginate(limit, marker, pageReverse, uriInfo, collection); + PaginationResults results = _paginate(limit, marker, pageReverse, uriInfo, collection); if (clazz.equals(NeutronNetwork.class)){ - return new NeutronNetworkRequest(results.collection, results.links); + return (INeutronRequest) new NeutronNetworkRequest((List) results.collection, results.links); } if (clazz.equals(NeutronSubnet.class)){ - return new NeutronSubnetRequest(results.collection, results.links); + return (INeutronRequest) new NeutronSubnetRequest((List) results.collection, results.links); } if (clazz.equals(NeutronPort.class)){ - return new NeutronPortRequest(results.collection, results.links); + return (INeutronRequest) new NeutronPortRequest((List) results.collection, results.links); } return null; } - private static PaginationResults _paginate(Integer limit, String marker, Boolean pageReverse, UriInfo uriInfo, List collection) { + private static PaginationResults _paginate(Integer limit, String marker, Boolean pageReverse, UriInfo uriInfo, List collection) { List links = new ArrayList<>(); Integer startPos = null; String startMarker; @@ -80,10 +86,12 @@ public class PaginatedRequestFactory { class MarkerObject implements INeutronObject { private String id; + @Override public String getID() { return id; } + @Override public void setID(String id) { this.id = id; } @@ -149,6 +157,6 @@ public class PaginatedRequestFactory { links.add(previous); } - return new PaginationResults(collection, links); + return new PaginationResults(collection, links); } }