List of usage examples for java.util Collection add
boolean add(E e);
From source file:com.qrmedia.commons.persistence.hibernate.clone.HibernateEntityBeanCloner.java
private static Collection<String> getFieldNames(Collection<Field> fields) { Collection<String> fieldNames = new ArrayList<String>(fields.size()); for (Field field : fields) { fieldNames.add(field.getName()); }/* ww w .j av a 2 s.co m*/ return fieldNames; }
From source file:Main.java
public static boolean addAll(final Collection<? super Double> c, final double... array) { boolean result = false; for (final double element : array) { result |= c.add(element); }//from w w w .j ava 2 s . c o m return result; }
From source file:edu.mayo.cts2.framework.webapp.service.ServiceUtils.java
/** * Find annotations./*from w w w . j a va2 s . co m*/ * * @param <A> the generic type * @param clazz the clazz * @param annotationType the annotation type * @return the collection */ public static <A extends Annotation> Collection<A> findAnnotations(Class<?> clazz, Class<A> annotationType) { Collection<A> returnCollection = new HashSet<A>(); Assert.notNull(clazz, "Class must not be null"); A annotation = clazz.getAnnotation(annotationType); if (annotation != null) { returnCollection.add(annotation); } for (Class<?> ifc : clazz.getInterfaces()) { Collection<A> annotations = findAnnotations(ifc, annotationType); if (annotations != null) { returnCollection.addAll(annotations); } } if (!Annotation.class.isAssignableFrom(clazz)) { for (Annotation ann : clazz.getAnnotations()) { Collection<A> annotations = findAnnotations(ann.annotationType(), annotationType); if (annotations != null) { returnCollection.addAll(annotations); } } } Class<?> superClass = clazz.getSuperclass(); if (superClass == null || superClass == Object.class) { return returnCollection; } returnCollection.addAll(findAnnotations(superClass, annotationType)); return returnCollection; }
From source file:Main.java
public static boolean addAll(final Collection<? super Boolean> c, final boolean... array) { boolean result = false; for (final boolean element : array) { result |= c.add(element); }// w w w . j av a 2 s . c om return result; }
From source file:com.google.zxing.client.android.result.supplement.SupplementalInfoRetriever.java
public static void maybeInvokeRetrieval(TextView textView, ParsedResult result, Handler handler, HistoryManager historyManager, Context context) { Collection<SupplementalInfoRetriever> retrievers = new ArrayList<SupplementalInfoRetriever>(1); if (result instanceof URIParsedResult) { retrievers.add(new URIResultInfoRetriever(textView, (URIParsedResult) result, handler, historyManager, context));/* w w w . j a v a 2 s .c om*/ } else if (result instanceof ProductParsedResult) { String productID = ((ProductParsedResult) result).getProductID(); retrievers.add(new ProductResultInfoRetriever(textView, productID, handler, historyManager, context)); } else if (result instanceof ISBNParsedResult) { String isbn = ((ISBNParsedResult) result).getISBN(); retrievers.add(new ProductResultInfoRetriever(textView, isbn, handler, historyManager, context)); retrievers.add(new BookResultInfoRetriever(textView, isbn, handler, historyManager, context)); } for (SupplementalInfoRetriever retriever : retrievers) { ExecutorService executor = getExecutorService(); Future<?> future = executor.submit(retriever); // Make sure it's interrupted after a short time though executor.submit(new KillerCallable(future, 10, TimeUnit.SECONDS)); } }
From source file:org.calrissian.restdoclet.writer.swagger.SwaggerWriter.java
private static Collection<Operation> getOperations(Collection<Endpoint> endpoints) { Collection<Operation> operations = new ArrayList<Operation>(endpoints.size()); for (Endpoint endpoint : endpoints) { Collection<Parameter> params = new ArrayList<Parameter>(); for (PathVar pathVar : endpoint.getPathVars()) params.add(getParameter(pathVar)); for (QueryParam queryParam : endpoint.getQueryParams()) params.add(getParameter(queryParam)); if (endpoint.getRequestBody() != null) params.add(getParameter(endpoint.getRequestBody())); operations.add(new Operation(endpoint.getHttpMethod(), "nickname", endpoint.getShortDescription(), endpoint.getDescription(), dataType(endpoint.getType()), endpoint.getProduces(), endpoint.getConsumes(), params)); }/*from w ww. ja v a 2 s. com*/ return operations; }
From source file:com.alibaba.dragoon.common.protocol.MBeanServerMessageHandler.java
public static void addAll(Collection<Object> collection, Object[] elements) { for (int i = 0, size = elements.length; i < size; i++) { collection.add(elements[i]); }//from w ww . j av a 2 s . co m }
From source file:com.gargoylesoftware.htmlunit.javascript.host.ObjectsTest.java
/** * Returns the data for this parameterized test. * @return list of all test parameters/*from w ww.j a va 2 s . c om*/ * @throws Exception If an error occurs */ @Parameters public static Collection<Object[]> data() throws Exception { IE6_ = getObjects(BrowserVersion.INTERNET_EXPLORER_6); IE7_ = getObjects(BrowserVersion.INTERNET_EXPLORER_7); IE8_ = getObjects(BrowserVersion.INTERNET_EXPLORER_8); FF3_ = getObjects(BrowserVersion.FIREFOX_3); FF3_6_ = getObjects(BrowserVersion.FIREFOX_3_6); Assert.assertEquals(IE6_.size(), IE7_.size()); Assert.assertEquals(IE6_.size(), IE8_.size()); Assert.assertEquals(IE6_.size(), FF3_.size()); Assert.assertEquals(IE6_.size(), FF3_6_.size()); IE6_SIMULATED_ = getSimulatedObjects(BrowserVersion.INTERNET_EXPLORER_6); IE7_SIMULATED_ = getSimulatedObjects(BrowserVersion.INTERNET_EXPLORER_7); IE8_SIMULATED_ = getSimulatedObjects(BrowserVersion.INTERNET_EXPLORER_8); FF3_SIMULATED_ = getSimulatedObjects(BrowserVersion.FIREFOX_3); FF3_6_SIMULATED_ = getSimulatedObjects(BrowserVersion.FIREFOX_3_6); Assert.assertEquals(IE6_SIMULATED_.size(), IE7_SIMULATED_.size()); Assert.assertEquals(IE6_SIMULATED_.size(), IE8_SIMULATED_.size()); Assert.assertEquals(IE6_SIMULATED_.size(), FF3_SIMULATED_.size()); Assert.assertEquals(IE6_SIMULATED_.size(), FF3_6_SIMULATED_.size()); final Collection<Object[]> list = new ArrayList<Object[]>(); for (final String line : IE6_) { final String name = line.substring(0, line.indexOf(':')); list.add(new Object[] { name, BrowserVersion.INTERNET_EXPLORER_6 }); list.add(new Object[] { name, BrowserVersion.INTERNET_EXPLORER_7 }); list.add(new Object[] { name, BrowserVersion.INTERNET_EXPLORER_8 }); list.add(new Object[] { name, BrowserVersion.FIREFOX_3 }); list.add(new Object[] { name, BrowserVersion.FIREFOX_3_6 }); } return list; }
From source file:Main.java
private static void runTest() throws InterruptedException { Collection<String> syncList = Collections.synchronizedList(new ArrayList<String>(1)); List<String> list = Arrays.asList("A", "B", "C", "D"); List<Thread> threads = new ArrayList<Thread>(); for (final String s : list) { Thread thread = new Thread(new Runnable() { @Override/*w ww .ja v a2 s. c o m*/ public void run() { syncList.add(s); } }); threads.add(thread); thread.start(); } for (Thread thread : threads) { thread.join(); } System.out.println(syncList); }
From source file:mustache.specs.SpecTest.java
@SuppressWarnings("unchecked") public static Collection<Object[]> data(final Class<?> loader, final String filename) throws IOException { Constructor constructor = new Constructor(); constructor.addTypeDescription(new TypeDescription(Blog.class, "!blog")); constructor.addTypeDescription(new TypeDescription(Comment.class, "!comment")); constructor.addTypeDescription(new TypeDescription(Map.class, "!code")); Yaml yaml = new Yaml(constructor); String location = path(loader) + filename; String input = FileUtils.readFileToString(new File("src/test/resources", location)); Map<String, Object> data = (Map<String, Object>) yaml.load(input); List<Map<String, Object>> tests = (List<Map<String, Object>>) data.get("tests"); int number = 0; Collection<Object[]> dataset = new ArrayList<Object[]>(); for (Map<String, Object> test : tests) { test.put("number", number++); dataset.add(new Object[] { new Spec(test) }); }//w w w . j a v a 2 s. c o m return dataset; }