Example usage for java.util Collection add

List of usage examples for java.util Collection add

Introduction

In this page you can find the example usage for java.util Collection add.

Prototype

boolean add(E e);

Source Link

Document

Ensures that this collection contains the specified element (optional operation).

Usage

From source file:com.taobao.datasource.DataSourceConfigParser.java

public static Collection<LocalTxDataSourceDO> parse(File file) throws DocumentException {
    SAXReader reader = new SAXReader();
    Document document = reader.read(file);
    Element datasources = document.getRootElement();
    List<Element> localTxDatasources = (List<Element>) datasources.elements(LOCAL_TX_DATASOURCE);

    Collection<LocalTxDataSourceDO> result = new ArrayList<LocalTxDataSourceDO>(localTxDatasources.size());
    for (Element localTxDatasource : localTxDatasources) {
        LocalTxDataSourceDO ds = createLocalTxDataSourceDO(localTxDatasource);
        result.add(ds);
    }/*from   www  .  ja  va 2s.  c  o m*/

    return result;
}

From source file:com.wolvereness.overmapped.lib.WellOrdered.java

private static <T> void addToAllLinkedLists(final Collection<T> tokens, final Map<T, Collection<T>> map,
        final T token) {
    for (final T target : tokens) {
        Collection<T> c = map.get(target);
        if (c == null) {
            map.put(target, c = newLinkedList());
        }/*from ww  w  .ja  v  a  2s  .co  m*/
        c.add(token);
    }
}

From source file:Main.java

public static boolean addAll(final Collection<? super Byte> c, final byte[] array, final int off,
        final int len) {
    final int end = off + len;
    boolean result = false;

    for (int i = off; i < end; i++) {
        result |= c.add(array[i]);
    }// ww  w.  jav  a  2  s. c  om

    return result;
}

From source file:Main.java

public static boolean addAll(final Collection<? super Long> c, final long[] array, final int off,
        final int len) {
    final int end = off + len;
    boolean result = false;

    for (int i = off; i < end; i++) {
        result |= c.add(array[i]);
    }//ww w.  j  a va2 s  . com

    return result;
}

From source file:de.alpharogroup.collections.MapExtensions.java

/**
 * Returns a Collection from all founded keys from the given value or null if nothing found.
 *
 * @param <K>//from w w w.j av  a 2  s. c  om
 *            the generic type of the key
 * @param <V>
 *            the generic type of the value
 * @param map
 *            The Map.
 * @param value
 *            The value.
 * @return Returns the key from the given value or an empty Collection if nothing found.
 */
public static <K, V> Collection<K> getKeysFromValue(final Map<K, V> map, final V value) {
    final Collection<K> keys = new ArrayList<>();
    for (final Entry<K, V> entry : map.entrySet()) {
        final V val = entry.getValue();
        if (val.equals(value)) {
            final K key = entry.getKey();
            keys.add(key);
        }
    }
    return keys;
}

From source file:info.servertools.core.util.FileUtils.java

/**
 * Read a file into a collection of strings
 * Each line is a new collection element
 *
 * @param file//from   ww w  .  j a  va2  s.  c  o  m
 *         the file to read
 *
 * @return A collection of strings
 *
 * @throws java.io.IOException
 *         IOException
 */
public static Collection<String> readFileToString(File file) throws IOException {

    Collection<String> lines;
    try (BufferedReader br = new BufferedReader(new FileReader(file))) {
        lines = new ArrayList<>();
        String line;
        while ((line = br.readLine()) != null) {
            lines.add(line);
        }
        return lines;
    }
}

From source file:Main.java

public static boolean addAll(final Collection<? super Short> c, final short[] array, final int off,
        final int len) {
    final int end = off + len;
    boolean result = false;

    for (int i = off; i < end; i++) {
        result |= c.add(array[i]);
    }//from  w w w  .  ja  v  a2  s . c  o m

    return result;
}

From source file:Main.java

public static boolean addAll(final Collection<? super Integer> c, final int[] array, final int off,
        final int len) {
    final int end = off + len;
    boolean result = false;

    for (int i = off; i < end; i++) {
        result |= c.add(array[i]);
    }/*from ww w. j ava2s . c om*/

    return result;
}

From source file:Main.java

public static boolean addAll(final Collection<? super Float> c, final float[] array, final int off,
        final int len) {
    final int end = off + len;
    boolean result = false;

    for (int i = off; i < end; i++) {
        result |= c.add(array[i]);
    }//from   www  .  j  ava 2  s .  c  om

    return result;
}

From source file:com.sfs.whichdoctor.formatter.RevenueAnalysisFormatter.java

/**
 * Gets the collection.//from  w  ww.j  a v  a  2s.  c o  m
 *
 * @param receipt the receipt
 * @return the collection
 */
public static Collection<Object> getCollection(final ReceiptBean receipt) {

    Collection<Object> collection = new ArrayList<Object>();

    if (receipt.getPayments() != null) {
        for (PaymentBean payment : receipt.getPayments()) {
            collection.add(payment);
        }
    }
    return collection;
}