List of usage examples for java.util List addAll
boolean addAll(Collection<? extends E> c);
From source file:Main.java
/** * Assign or make new list from source list. Use ArrayList for new list. * /* ww w. j av a 2 s.c om*/ * @param src * @param dst * @return */ public static <T> List<T> instanceList(List<T> src, List<T> dst) { List<T> ret = null; if (src != null) { if (dst == null) { dst = new ArrayList<>(); } dst.clear(); dst.addAll(src); ret = dst; } return ret; }
From source file:io.gumga.application.GumgaUntypedRepository.java
/** * Pegar todos os atributos de uma classe * @param classe objeto que voce deseja pegar os atributos * @return dados da pesquisa//from w w w. ja v a 2 s . c om * @throws SecurityException */ public static List<Field> getTodosAtributos(Class classe) throws SecurityException { List<Field> aRetornar = new ArrayList<>(); if (!classe.getSuperclass().equals(Object.class)) { aRetornar.addAll(getTodosAtributos(classe.getSuperclass())); } aRetornar.addAll(Arrays.asList(classe.getDeclaredFields())); return aRetornar; }
From source file:org.commonjava.maven.firth.client.ArtifactClient.java
public static ArtifactClient load(final String baseUrl, final String mapsBasePath, final String packagePathFormat, final String source, final String version) throws IOException { final HttpClient http = HttpClientBuilder.create().build(); // Assume something like: http://download.devel.redhat.com/brewroot/artifact-maps/rcm-mw-tools-build/1234/composition.json final String compsUrl = PathUtils.normalize(baseUrl, mapsBasePath, source, version, "composition.json"); final ObjectMapper om = new ObjectMapper(); HttpGet request = new HttpGet(compsUrl); HttpResponse response = http.execute(request); SourceComposition comp;/*from w w w . j a v a 2 s . c o m*/ if (response.getStatusLine().getStatusCode() == 200) { comp = om.readValue(response.getEntity().getContent(), SourceComposition.class); } else { throw new IOException("Failed to read composition from: " + compsUrl); } final List<String> manifestSources = new ArrayList<String>(); manifestSources.add(source); manifestSources.addAll(comp.getComposedOf()); final List<SourceManifest> manifests = new ArrayList<SourceManifest>(); for (final String src : manifestSources) { // Assume something like: http://download.devel.redhat.com/brewroot/artifact-maps/rcm-mw-tools-build/1234/manifest.json final String manifestUrl = PathUtils.normalize(baseUrl, mapsBasePath, src, version, "manifest.json"); request = new HttpGet(manifestUrl); response = http.execute(request); if (response.getStatusLine().getStatusCode() == 200) { final SourceManifest manifest = om.readValue(response.getEntity().getContent(), SourceManifest.class); manifests.add(manifest); } else { throw new IOException("Failed to read manifest from: " + manifestUrl); } } final ArtifactMap am = new ArtifactMap(packagePathFormat, manifests); return new ArtifactClient(baseUrl, am, http); }
From source file:apm.common.utils.Collections3.java
/** * a+bList./*from w w w . j a v a 2 s .c o m*/ */ 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:com.dayatang.weekly.domain.VehicleUsage.java
/** * ?//from w ww . ja va 2 s . c o m * @param report * @return */ public static VehicleUsage getLastOneOf(WeeklyReport report) { QuerySettings<VehicleUsage> settings = QuerySettings.create(VehicleUsage.class).eq("report", report) .desc("id"); List<VehicleUsage> results = new ArrayList<VehicleUsage>(); results.addAll(getRepository().find(settings)); return results.size() > 0 ? results.get(0) : null; }
From source file:edu.uci.ics.hyracks.algebricks.rewriter.rules.PushSelectDownRule.java
private static boolean propagateSelectionRec(Mutable<ILogicalOperator> sigmaRef, Mutable<ILogicalOperator> opRef2) throws AlgebricksException { AbstractLogicalOperator op2 = (AbstractLogicalOperator) opRef2.getValue(); if (op2.getInputs().size() != 1 || op2.getOperatorTag() == LogicalOperatorTag.DATASOURCESCAN) { return false; }//from w w w. j a va 2s .c o m SelectOperator sigma = (SelectOperator) sigmaRef.getValue(); LinkedList<LogicalVariable> usedInSigma = new LinkedList<LogicalVariable>(); sigma.getCondition().getValue().getUsedVariables(usedInSigma); LinkedList<LogicalVariable> produced2 = new LinkedList<LogicalVariable>(); VariableUtilities.getProducedVariables(op2, produced2); if (OperatorPropertiesUtil.disjoint(produced2, usedInSigma)) { // just swap opRef2.setValue(sigma); sigmaRef.setValue(op2); List<Mutable<ILogicalOperator>> sigmaInpList = sigma.getInputs(); sigmaInpList.clear(); sigmaInpList.addAll(op2.getInputs()); List<Mutable<ILogicalOperator>> op2InpList = op2.getInputs(); op2InpList.clear(); op2InpList.add(opRef2); propagateSelectionRec(opRef2, sigma.getInputs().get(0)); return true; } return false; }
From source file:com.intel.podm.allocation.strategy.matcher.LocalStorageMatcher.java
private static List<LocalStorage> getStorageUnderComputerSystem(ComputerSystem computerSystem) { List<LocalStorage> localStorage = computerSystem.getAdapters().stream().map(Adapter::getDevices) .flatMap(Collection::stream).collect(toList()); localStorage.addAll(computerSystem.getSimpleStorages().stream().map(SimpleStorage::getDevices) .flatMap(Collection::stream).collect(toList())); return localStorage; }
From source file:Main.java
/** * Returns all the components (and their children) associated to the given container. * * @param container Container/* w w w.j av a2 s . c o m*/ * @return {@code Component} list * @since 0.3.0 */ public static List<Component> getAllComponents(Container container) { List<Component> out = new LinkedList<Component>(); for (Component comp : container.getComponents()) { out.add(comp); if (comp instanceof Container) out.addAll(getAllComponents((Container) comp)); } return out; }
From source file:Main.java
public static int binarySearchIndex(Collection<?> collection, Object value) { if ((value instanceof Comparable)) { List valueList; if ((collection instanceof List)) { valueList = (List) collection; } else {//from w w w. j av a2s. c o m valueList = new ArrayList(); valueList.addAll(collection); } return Collections.binarySearch(valueList, value); } return searchIndex(collection, value); }
From source file:com.cassius.spring.assembly.test.common.toolbox.LogFormatUtil.java
/** * Format string./* w w w . j a va 2 s. c o m*/ * * @param message the message * @param logs the logs * @return the string */ public static String format(String message, String[] logs) { List<String> stringSet = new ArrayList<String>(); stringSet.add(message); stringSet.addAll(Arrays.asList(logs)); String[] result = new String[stringSet.size()]; result = stringSet.toArray(result); return format(result); }