ppamorim

Untitled

Mar 7th, 2015
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.47 KB | None | 0 0
  1. /*
  2.  * Copyright (C) 2015 Pedro Paulo de Amorim.
  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.  * http://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 com.ppamorim.library;
  17.  
  18. import java.lang.reflect.Type;
  19. import java.util.ArrayList;
  20. import java.util.List;
  21. import java.util.Vector;
  22.  
  23. /**
  24.  * Return a instance of a new paramerized list
  25.  *
  26.  * @author Pedro Paulo de Amorim.
  27.  */
  28. public final class Mocky<T> {
  29.  
  30.   //public T object(T type) {
  31.   //
  32.   //}
  33.  
  34.   public ArrayList arrayList(T type, int size) {
  35.     ArrayList<T> arrayList = new ArrayList<>(size);
  36.     for(int i = 0; i < size; i++) {
  37.       arrayList.add(type);
  38.     }
  39.     return arrayList;
  40.   }
  41.  
  42.   public List<T> list(T type, int size) {
  43.     List<T> list = new ArrayList<>(size);
  44.     for(int i = 0; i < size; i++) {
  45.       list.add(type);
  46.     }
  47.     return list;
  48.   }
  49.  
  50.   public Vector<T> vector(T type, int size) {
  51.     Vector<T> list = new Vector<>(size);
  52.     for(int i = 0; i < size; i++) {
  53.       list.add(type);
  54.     }
  55.     return list;
  56.   }
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment