List of usage examples for java.util List addAll
boolean addAll(Collection<? extends E> c);
From source file:Main.java
public static <T> List<T> concat(List<T> collection1, List<T> collection2) { if (isEmpty(collection1)) { return collection2; }//from ww w . j ava2 s . c o m if (isEmpty(collection2)) { return collection1; } collection1.addAll(collection2); return collection1; }
From source file:net.eledge.android.toolkit.StringArrayUtils.java
public static String[] toArray(SparseArray<List<String>> sparseArray) { List<String> list = new ArrayList<>(); if ((sparseArray != null) && (sparseArray.size() > 0)) { for (int i = 0; i < sparseArray.size(); i++) { list.addAll(sparseArray.valueAt(i)); }//from ww w . jav a 2s. co m } return list.toArray(new String[list.size()]); }
From source file:ClassUtil.java
/** * Retrieves all interfaces implemented by a specified interface * including all recursively extended interfaces and the classes supplied * int the parameter.//from w w w. jav a2s. com * @param childInterfaces a set of interfaces * @return Class[] an array of interfaces that includes those specifed * in childInterfaces plus all of those interfaces' super interfaces */ public static Class[] getSuperInterfaces(Class[] childInterfaces) { List allInterfaces = new ArrayList(); for (int i = 0; i < childInterfaces.length; i++) { allInterfaces.add(childInterfaces[i]); allInterfaces.addAll(Arrays.asList(getSuperInterfaces(childInterfaces[i].getInterfaces()))); } return (Class[]) allInterfaces.toArray(new Class[allInterfaces.size()]); }
From source file:Main.java
public static List<Node> getChildElementsByTagName(NodeList nodes, String tagName) { List<Node> list = new ArrayList<Node>(); for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); if (node instanceof Element) list.addAll(getChildElementsByTagName(node, tagName)); }/*w w w . ja va 2 s. c o m*/ return list; }
From source file:Main.java
/** * @param domainsAtt//from www .j a va2 s .c o m * @return */ private static String[] getPropsAtts(String domainsAtt) { List<String> propsAtts = new ArrayList<String>(); String[] result = new String[propsAtts.size()]; propsAtts.addAll(BASE_PROPS_ATTS); if (domainsAtt == null) return propsAtts.toArray(result); char c; int p = 0; while (p < domainsAtt.length()) { c = domainsAtt.charAt(p); switch (c) { case ' ': case '\t': p++; break; case '(': p = parseParens(domainsAtt, ++p); break; case 'a': p = parsePropsDomain(domainsAtt, ++p, propsAtts); break; default: throw new RuntimeException("Unexpected character \"" + c + "\" at position " + p + 1 + " in domains attribute value \"" + domainsAtt + "\"" + ". Expected space, '(', or 'a'."); } } result = new String[propsAtts.size()]; return propsAtts.toArray(result); }
From source file:com.cnksi.core.tools.utils.Collections3.java
/** * a+bList./*from w w w . j av a2 s. c om*/ */ public static <T> List<T> union(final Collection<T> a, final Collection<T> b) { List<T> result = new ArrayList<T>(a); result.addAll(b); return result; }
From source file:cz.muni.fi.editor.database.test.helpers.AbstractDAOTest.java
protected static void checkMethods(Class testClass, Class testingInterface) { Set<String> testMethods = new HashSet<>(); for (Method m : testClass.getDeclaredMethods()) { if (m.isAnnotationPresent(Test.class)) { testMethods.add(m.getName()); }//from w w w.j a va 2 s . c om } List<String> targetMethods = new ArrayList<>( Arrays.asList("create", "update", "getById", "delete", "getAll", "getClassType")); targetMethods.addAll(new ArrayList<>(Arrays.asList(testingInterface.getDeclaredMethods())).stream() .map(m -> m.getName()).collect(Collectors.toList())); testMethods.forEach(targetMethods::remove); Assert.assertEquals("Following method(s) are missing in DAO test :" + targetMethods.toString(), 0, targetMethods.size()); }
From source file:ch.puzzle.itc.mobiliar.presentation.resourcesedit.DataProviderHelper.java
/** * Converts a Map to a List filled with its entries. This is needed since very few if any JSF iteration * components are able to iterate over a map. * * @see http://stackoverflow.com/questions/8552804/uirepeat-doesnt-work-with-map *///from w w w .jav a 2s . c o m public static <T, S> List<Map.Entry<T, S>> mapToList(Map<T, S> map) { if (map == null) { return null; } List<Map.Entry<T, S>> list = new ArrayList<>(); Set<Map.Entry<T, S>> entrySet = map.entrySet(); list.addAll(entrySet); return list; }
From source file:com.lithium.flow.matcher.StringMatchers.java
@Nonnull public static StringMatcher fromList(@Nonnull List<String> list) { Multimap<String, String> multimap = HashMultimap.create(); for (String value : list) { int index = value.indexOf(':'); if (index == -1 || index >= value.length() - 1) { multimap.put("exact", value); } else {/* www .j a v a 2 s.c o m*/ int index2 = value.indexOf("?["); int index3 = value.indexOf("]:", index2); if (index2 > -1 && index3 > -1 && index2 < index) { index = index2 + 1; } String type = value.substring(0, index); String param = value.substring(index + 1); multimap.put(type, param); } } List<StringMatcher> quickMatchers = Lists.newArrayList(); quickMatchers.addAll(buildList(multimap, "len", LenStringMatcher::new)); Collection<String> exacts = multimap.get("exact"); if (exacts.size() == 1) { quickMatchers.add(new ExactStringMatcher(exacts.iterator().next())); } else if (exacts.size() > 1) { quickMatchers.add(new ExactSetStringMatcher(Sets.newHashSet(exacts))); } quickMatchers.addAll(buildList(multimap, "prefix", PrefixStringMatcher::new)); quickMatchers.addAll(buildList(multimap, "suffix", SuffixStringMatcher::new)); quickMatchers.addAll(buildList(multimap, "contains", ContainsStringMatcher::new)); List<StringMatcher> lowerMatchers = Lists.newArrayList(); lowerMatchers.addAll(buildList(multimap, "lower.prefix", PrefixStringMatcher::new)); lowerMatchers.addAll(buildList(multimap, "lower.suffix", SuffixStringMatcher::new)); lowerMatchers.addAll(buildList(multimap, "lower.contains", ContainsStringMatcher::new)); List<StringMatcher> regexMatchers = Lists.newArrayList(); regexMatchers.addAll(buildList(multimap, "regex", RegexStringMatcher::new)); regexMatchers.addAll(buildList(multimap, "lower.regex", LowerRegexStringMatcher::new)); List<StringMatcher> allMatchers = Lists.newArrayList(); allMatchers.add(buildComposite(quickMatchers, false)); allMatchers.add(buildComposite(lowerMatchers, true)); allMatchers.add(buildComposite(regexMatchers, false)); return buildComposite(allMatchers, false); }
From source file:Main.java
/** * // ww w . j a va 2 s.c om * @return */ public static Object[] flatternMultipleValues(Object[] values) { if (values == null || values.length == 0) return new Object[0]; List flattern = new ArrayList(); for (int i = 0; i < values.length; i++) { if (values[i] instanceof Object[]) { Object[] flatternObj = (Object[]) values[i]; flattern.addAll(Arrays.asList(flatternMultipleValues(flatternObj))); } else { flattern.add(values[i]); } } return flattern.toArray(); }