List of usage examples for java.util Collection add
boolean add(E e);
From source file:com.enonic.cms.core.structure.menuitem.MenuItemKey.java
public static Collection<MenuItemKey> converToList(int[] array) { if ((array == null) || (array.length == 0)) { return new ArrayList<MenuItemKey>(); }/*from w w w . j a v a 2 s. c o m*/ Collection<MenuItemKey> list = new ArrayList<MenuItemKey>(array.length); for (int value : array) { list.add(new MenuItemKey(value)); } return list; }
From source file:hudson.plugins.clearcase.ucm.model.ActivitiesDelta.java
private static Collection<Activity> parseLeft(String line, Collection<Activity> left) { if (isLeftLine(line)) { left.add(parseLeftLine(line)); }//from ww w . j a va2 s . c o m return left; }
From source file:Main.java
private static <E> void iterableToCollection(Iterable<? extends E> iter, Collection<E> list) { if (iter == null) { return;/*from w w w . ja v a2 s .c o m*/ } for (E element : iter) { list.add(element); } }
From source file:hudson.plugins.clearcase.ucm.model.ActivitiesDelta.java
private static Collection<Activity> parseRight(String line, Collection<Activity> right) { if (isRightLine(line)) { right.add(parseRightLine(line)); }//from ww w . ja v a2s .c o m return right; }
From source file:Main.java
/** * Null elements are not taking into account. * @see Collections#addAll(java.util.Collection, Object[]) *//* w ww. java2s . c o m*/ @SafeVarargs public static <T> boolean addAllIgnoreNull(Collection<? super T> c, T... elements) { boolean result = false; for (T element : elements) { if (element != null) { result |= c.add(element); } } return result; }
From source file:com.anhth12.lambda.common.random.RandomManager.java
/** * @return a new, seeded {@link RandomGenerator} *///from w w w. java 2 s . c o m public static RandomGenerator getRandom() { if (useTestSeed) { // No need to track instances anymore return new Well19937c(TEST_SEED); } RandomGenerator random = new Well19937c(); Collection<RandomGenerator> instances = INSTANCES.get(); if (instances != null) { synchronized (instances) { instances.add(random); } } // else oh well, only matters in tests return random; }
From source file:org.jenkinsci.plugins.kubernetesworkflowsteps.KubeStepExecution.java
private static CloseableHttpClient getClient() throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException { if (client == null) { synchronized (client_lock) { if (client == null) { SSLContextBuilder builder = SSLContexts.custom(); builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); SSLContext sslContext = builder.build(); SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); Collection<BasicHeader> headers = new ArrayList<BasicHeader>(); headers.add(new BasicHeader(HttpHeaders.CONTENT_TYPE, "application/json")); headers.add(new BasicHeader(HttpHeaders.AUTHORIZATION, "Bearer " + env.get("BEARER_TOKEN"))); client = HttpClients.custom().setDefaultHeaders(headers).setSSLSocketFactory(sslsf).build(); }/* w w w . j a va2 s . com*/ } } return client; }
From source file:com.vmware.identity.rest.idm.server.mapper.ResourceServerMapper.java
public static Collection<ResourceServerDTO> getResourceServerDTOs(Collection<ResourceServer> resourceServers) { Validate.notNull(resourceServers, "resourceServers"); Collection<ResourceServerDTO> resourceServerDTOs = new ArrayList<ResourceServerDTO>(); for (ResourceServer resourceServer : resourceServers) { resourceServerDTOs.add(getResourceServerDTO(resourceServer)); }/* w ww . j a va 2 s .c om*/ return resourceServerDTOs; }
From source file:Main.java
public static <T> String[] compact(Collection<T> col) { Collection<String> result = new ArrayList(); for (T e : col) { String str = e.toString(); if (!str.trim().isEmpty()) result.add(str); }//from w ww .j a v a 2 s.c o m return result.toArray(new String[result.size()]); }
From source file:Main.java
public static <E> Collection<E> unique(Collection<? extends E> src, Collection<E> dest) { Set<E> set = new HashSet<>(); for (E element : src) { if (!set.contains(element)) { set.add(element);//from w w w . ja v a 2s . c o m dest.add(element); } } set.clear(); return dest; }