List of usage examples for com.google.common.collect Lists newLinkedList
@GwtCompatible(serializable = true) public static <E> LinkedList<E> newLinkedList(Iterable<? extends E> elements)
From source file:org.xlrnet.metadict.web.api.ResourceDescription.java
public static List<ResourceDescription> fromBoundResourceInvokers( Set<Map.Entry<String, List<ResourceInvoker>>> bound) { Map<String, ResourceDescription> descriptions = Maps.newHashMap(); for (Map.Entry<String, List<ResourceInvoker>> entry : bound) { ResourceMethodInvoker aMethod = (ResourceMethodInvoker) entry.getValue().get(0); String basePath = aMethod.getMethod().getDeclaringClass().getAnnotation(Path.class).value(); String thisPath = Optional.ofNullable(aMethod.getMethod().getAnnotation(Path.class)) .map(a -> basePath + a.value()).orElse(basePath); if (!descriptions.containsKey(thisPath)) { descriptions.put(thisPath, new ResourceDescription(thisPath)); }/*from w w w . j a v a 2 s .c o m*/ for (ResourceInvoker invoker : entry.getValue()) { ResourceMethodInvoker methodinvoker = (ResourceMethodInvoker) invoker; descriptions.get(thisPath).addMethod(basePath, methodinvoker); } } return Lists.newLinkedList(descriptions.values()); }
From source file:com.qcadoo.testing.model.EntityListMock.java
/** * Create a new mock instance of an EntityList, containing given values, with find() method stubbed for returning * SearchCriteriaBuilder objects produced by given supplier (factory, provider). * //from www . j a v a 2 s . com * @param elements * content of new mock * @param criteriaBuilderFactory * SearchCriteriaBuilder objects supplier * @return a new instance of an EntityList mock */ public static EntityList create(final Collection<Entity> elements, final Supplier<SearchCriteriaBuilder> criteriaBuilderFactory) { return new EntityListMock(Lists.newLinkedList(elements), criteriaBuilderFactory); }
From source file:org.apache.awf.io.callback.JMXDebuggableCallbackManager.java
@Override public boolean execute() { // makes a defensive copy to avoid (1) CME (new callbacks are added this iteration) and (2) IO starvation. List<AsyncCallback> defensive = Lists.newLinkedList(callbacks); callbacks.clear();/* w w w . j av a 2s.c o m*/ for (AsyncCallback callback : defensive) { callback.onCallback(); logger.debug("Callback executed"); } return !callbacks.isEmpty(); }
From source file:com.cloudera.nav.sdk.model.entities.Dataset.java
/** * Set the schema fields belonging to this dataset * @param fields/*from ww w.j a va 2 s .c om*/ */ public void setFields(Collection<? extends DatasetField> fields) { if (getIdentity() == null) { setIdentity(generateId()); } for (DatasetField field : fields) { field.setParentId(this); } this.fields = Lists.newLinkedList(fields); }
From source file:com.mycila.inject.injector.MemberInjectorTypeListener.java
@Override public <I> void hear(final TypeLiteral<I> injectableType, TypeEncounter<I> encounter) { final Provider<? extends KeyProvider<A>> provider = encounter.getProvider(providerClass); final Provider<Injector> injectorProvider = encounter.getProvider(Injector.class); final List<Field> fields = Lists .newLinkedList(findFields(injectableType.getRawType(), annotatedBy(annotationType))); final List<Method> methods = Lists .newLinkedList(filter(findMethods(injectableType.getRawType()), annotatedBy(annotationType))); if (!fields.isEmpty() || !methods.isEmpty()) { encounter.register(new MembersInjector<I>() { @Override/*from w ww . j a v a 2 s. c o m*/ public void injectMembers(I injectee) { KeyProvider<A> keyProvider = provider.get(); // inject fields for (Field field : fields) { Object value = injectorProvider.get().getProvider( keyProvider.getKey(injectableType, field, field.getAnnotation(annotationType))) .get(); if (!field.isAccessible()) field.setAccessible(true); try { field.set(injectee, value); } catch (IllegalAccessException e) { throw new IllegalStateException( "Failed to inject field " + field + ". Reason: " + e.getMessage(), e); } } // inject methods for (Method method : methods) { List<Key<?>> parameterKeys = keyProvider.getParameterKeys(injectableType, method, method.getAnnotation(annotationType)); Object[] parameters = new Object[parameterKeys.size()]; for (int i = 0; i < parameters.length; i++) parameters[i] = injectorProvider.get().getProvider(parameterKeys.get(i)).get(); try { Proxy.invoker(method).invoke(injectee, parameters); } catch (Exception e) { throw runtime(e); } } } }); } }
From source file:eu.project.ttc.models.scored.ScoredTerm.java
/** * /*from w w w .j a v a 2 s . co m*/ * The ratio of this term appearance without any of its variants * * @return * The ratio of this term appearance without any of its variants. */ public double getTermIndependanceScore() { if (independance == -1) { Collection<TermOccurrence> occs = Lists.newLinkedList(getTerm().getOccurrences()); for (TermVariation tv : getTerm().getVariations()) { TermOccurrenceUtils.removeOverlaps(tv.getVariant().getOccurrences(), occs); } for (Term ext : getTerm().getExtensions()) { TermOccurrenceUtils.removeOverlaps(ext.getOccurrences(), occs); } independance = ((double) occs.size()) / this.getTerm().getFrequency(); } return independance; }
From source file:com.amediamanager.metrics.MetricBatcher.java
protected void sendBatch(Map<String, Collection<MetricDatum>> datums) { for (final Map.Entry<String, Collection<MetricDatum>> e : datums.entrySet()) { for (final List<MetricDatum> batch : Lists.partition(Lists.newLinkedList(e.getValue()), BATCH_SIZE)) { cloudWatch.putMetricDataAsync( new PutMetricDataRequest().withNamespace(e.getKey()).withMetricData(batch), new AsyncHandler<PutMetricDataRequest, Void>() { @Override public void onError(Exception exception) { LOG.error("PutMetricData failed", exception); LOG.info("Requeueing metric data."); queuedDatums.putAll(e.getKey(), batch); }/*from w w w .ja va 2 s . co m*/ @Override public void onSuccess(PutMetricDataRequest request, Void result) { LOG.info("Successfully put " + request.getMetricData().size() + " datums for namespace " + request.getNamespace()); LOG.debug("Request", request); } }); } } }
From source file:com.qcadoo.model.api.utils.TreeNumberingServiceImpl.java
@Override public final void generateTreeNumbers(final EntityTreeNode treeNode) { assignNumberToTreeNode(treeNode, Lists.newLinkedList(Lists.newArrayList(ROOT_NODE_NUMBER))); }
From source file:org.gradle.api.plugins.buildcomparison.gradle.internal.DefaultGradleBuildInvocationSpec.java
public void setTasks(Iterable<String> tasks) { this.tasks = tasks == null ? new LinkedList<String>() : Lists.newLinkedList(tasks); }
From source file:cc.recommenders.evaluation.io.TypeStore.java
private List<Usage> filterAndMapUsages(Predicate<ProjectFoldedUsage> pred) { Iterable<ProjectFoldedUsage> filtered = Iterables.filter(allUsages, pred); Iterable<Usage> usages = Iterables.transform(filtered, usageTransformation()); return Lists.newLinkedList(usages); }