2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdcrests.wrappers;
23 import java.io.Serializable;
24 import java.util.ArrayList;
25 import java.util.List;
28 * This class represents a generic collection wrapper to be used by paginated results.
30 * @param <T> the type parameter
32 public class GenericCollectionWrapper<T> implements Serializable {
33 private static final long serialVersionUID = 1L;
35 private List<T> results;
36 private int listCount;
39 * Instantiates a new Generic collection wrapper.
41 public GenericCollectionWrapper() {
42 this.results = new ArrayList<>();
46 * Instantiates a new Generic collection wrapper.
48 * @param list the list
49 * @param listCount the list count
51 public GenericCollectionWrapper(List<T> list, int listCount) {
52 if (!list.isEmpty()) {
54 this.listCount = listCount;
63 public List<T> getResults() {
70 * @param results the results
72 public void setResults(List<T> results) {
73 this.results = results;
79 * @return the list count
81 public int getListCount() {
88 * @param listCount the list count
90 public void setListCount(int listCount) {
91 this.listCount = listCount;
100 public boolean add(T e0) {
101 if (this.getResults().add(e0)) {
102 this.setListCount(this.getResults().size());