List of usage examples for java.util Collection add
boolean add(E e);
From source file:Main.java
public static <E> void addAll(Collection<E> collection, Iterator<? extends E> iterator) { while (iterator.hasNext()) { collection.add(iterator.next()); }/*from w w w . jav a2 s . com*/ }
From source file:demo.Converters.java
public static Collection<HttpMessageConverter<?>> getJaxbConverters() { Collection<HttpMessageConverter<?>> converters = new ArrayList<>(); converters.add(new JaxbOAuth2AccessTokenMessageConverter()); converters.add(new JaxbOAuth2ExceptionMessageConverter()); return converters; }
From source file:Main.java
/** * Add all the items from an iterable to a collection. * * @param <T>//from w w w . j a v a2s. c om * The type of items in the iterable and the collection * @param collection * The collection to which the items should be added. * @param items * The items to add to the collection. */ public static <T> void addAll(Collection<T> collection, Iterable<? extends T> items) { for (T item : items) { collection.add(item); } }
From source file:Main.java
final static public Collection<Object> createCollection(Object[] objects) { Collection<Object> result = createCollection(); for (int i = 0; i < objects.length; i++) { result.add(objects[i]); }/* www .ja v a 2 s . c o m*/ return result; }
From source file:Main.java
public static <O> boolean replace(Collection<O> c, O item) { if (c == null) { return false; }// ww w . j a v a2 s . co m c.remove(item); c.add(item); return true; }
From source file:Main.java
/** * Adds array members to list//from w w w . j a va2 s . c o m * @param <T> * @param list * @param array */ public static <T> Collection<T> addAll(Collection<T> list, T... array) { for (T item : array) { list.add(item); } return list; }
From source file:Main.java
/** * an alternative which returns slightly more granular info than boolean pass/fail. * @return the number of add operations which "succeed" (modify the collection) * @see Collection#addAll(Collection)/* w w w . j av a2s. co m*/ */ public static <E> int addAll(Collection<E> collection, Iterator<? extends E> add) { int retVal = 0; while (add.hasNext()) if (collection.add(add.next())) ++retVal; return retVal; }
From source file:Main.java
public static Collection<Long> toIdCollection(String idList) { if (TextUtils.isEmpty(idList)) return new ArrayList<Long>(); String[] idArray = idList.split(","); Collection<Long> ids = new ArrayList<Long>(idArray.length); for (String id : idArray) { ids.add(Long.parseLong(id)); }//from w w w . j av a2s. com return ids; }
From source file:Main.java
public static <T> void addAll(Collection<T> c, Enumeration<T> enumeration) { while (enumeration.hasMoreElements()) { c.add(enumeration.nextElement()); }//ww w . j ava2s . co m }
From source file:Main.java
public static Collection<String> convertLongsToStrings(Collection<Long> longs) { if (longs != null) { Collection<String> strings = new ArrayList<String>(longs.size()); for (long longNumber : longs) { strings.add(String.valueOf(longNumber)); }/*from www. j a va 2 s . c o m*/ return strings; } return null; }