View Javadoc
1   /*
2    *    Copyright 2009-2023 the original author or authors.
3    *
4    *    Licensed under the Apache License, Version 2.0 (the "License");
5    *    you may not use this file except in compliance with the License.
6    *    You may obtain a copy of the License at
7    *
8    *       https://www.apache.org/licenses/LICENSE-2.0
9    *
10   *    Unless required by applicable law or agreed to in writing, software
11   *    distributed under the License is distributed on an "AS IS" BASIS,
12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *    See the License for the specific language governing permissions and
14   *    limitations under the License.
15   */
16  package org.apache.ibatis.submitted.custom_collection_handling;
17  
18  import java.util.ArrayList;
19  import java.util.Collection;
20  import java.util.Iterator;
21  import java.util.List;
22  import java.util.ListIterator;
23  
24  public class CustomCollection<T> {
25  
26    private final List<T> data = new ArrayList<>();
27  
28    public <K> K[] toArray(K[] a) {
29      return data.toArray(a);
30    }
31  
32    public Object[] toArray() {
33      return data.toArray();
34    }
35  
36    public List<T> subList(int fromIndex, int toIndex) {
37      return data.subList(fromIndex, toIndex);
38    }
39  
40    public int size() {
41      return data.size();
42    }
43  
44    public T set(int index, T element) {
45      return data.set(index, element);
46    }
47  
48    public boolean retainAll(Collection<?> c) {
49      return data.retainAll(c);
50    }
51  
52    public boolean removeAll(Collection<?> c) {
53      return data.removeAll(c);
54    }
55  
56    public T remove(int index) {
57      return data.remove(index);
58    }
59  
60    public boolean remove(Object o) {
61      return data.remove(o);
62    }
63  
64    public ListIterator<T> listIterator(int index) {
65      return data.listIterator(index);
66    }
67  
68    public ListIterator<T> listIterator() {
69      return data.listIterator();
70    }
71  
72    public int lastIndexOf(Object o) {
73      return data.lastIndexOf(o);
74    }
75  
76    public Iterator<T> iterator() {
77      return data.iterator();
78    }
79  
80    public boolean isEmpty() {
81      return data.isEmpty();
82    }
83  
84    public int indexOf(Object o) {
85      return data.indexOf(o);
86    }
87  
88    @Override
89    public int hashCode() {
90      return data.hashCode();
91    }
92  
93    public T get(int index) {
94      return data.get(index);
95    }
96  
97    @Override
98    public boolean equals(Object o) {
99      if (!(o instanceof CustomCollection)) {
100       return false;
101     }
102     return data.equals(((CustomCollection) o).data);
103   }
104 
105   public boolean containsAll(Collection<?> c) {
106     return data.containsAll(c);
107   }
108 
109   public boolean contains(Object o) {
110     return data.contains(o);
111   }
112 
113   public void clear() {
114     data.clear();
115   }
116 
117   public boolean addAll(int index, Collection<? extends T> c) {
118     return data.addAll(index, c);
119   }
120 
121   public boolean addAll(Collection<? extends T> c) {
122     return data.addAll(c);
123   }
124 
125   public void add(int index, T element) {
126     data.add(index, element);
127   }
128 
129   public boolean add(T e) {
130     return data.add(e);
131   }
132 
133 }