List of usage examples for com.google.common.collect Lists newArrayListWithCapacity
@GwtCompatible(serializable = true) public static <E> ArrayList<E> newArrayListWithCapacity(int initialArraySize)
From source file:at.molindo.esi4j.action.impl.DefaultMultiGetResponseWrapper.java
@Override public <T> List<T> getObjects(Class<T> type) { List<MultiGetItemResponseWrapper> resps = getMultiGetItemResponses(); List<T> objects = Lists.newArrayListWithCapacity(resps.size()); for (MultiGetItemResponseWrapper hit : resps) { objects.add(hit.getObject(type)); }/* w w w .j a va2s . c om*/ return objects; }
From source file:co.cask.cdap.data2.transaction.queue.inmemory.InMemoryQueueService.java
/** * Drop either all streams or all queues. * @param clearStreams if true, drops all streams, if false, clears all queues. * @param prefix if non-null, drops only queues with a name that begins with this prefix. *//*w w w .j a v a2 s. c om*/ private void resetAllQueuesOrStreams(boolean clearStreams, @Nullable String prefix) { List<QueueName> toRemove = Lists.newArrayListWithCapacity(queues.size()); for (QueueName queueName : queues.keySet()) { if ((clearStreams && queueName.isStream()) || (!clearStreams && queueName.isQueue())) { if (prefix == null || queueName.toString().startsWith(prefix)) { toRemove.add(queueName); } } } for (QueueName queueName : toRemove) { queues.remove(queueName); } }
From source file:co.cask.hydrator.common.RecordConverter.java
private List<Object> convertArray(Object values, Schema elementSchema) throws IOException { List<Object> output; if (values instanceof List) { List<Object> valuesList = (List<Object>) values; output = Lists.newArrayListWithCapacity(valuesList.size()); for (Object value : valuesList) { output.add(convertField(value, elementSchema)); }/* ww w . j a v a 2 s . co m*/ } else { Object[] valuesArr = (Object[]) values; output = Lists.newArrayListWithCapacity(valuesArr.length); for (Object value : valuesArr) { output.add(convertField(value, elementSchema)); } } return output; }
From source file:com.opengamma.web.analytics.MarketDataSpecificationJsonReader.java
public static List<MarketDataSpecification> buildSpecifications(String json) { try {//from w w w . ja v a 2 s. co m JSONArray array = new JSONArray(json); List<MarketDataSpecification> specs = Lists.newArrayListWithCapacity(array.length()); for (int i = 0; i < array.length(); i++) { specs.add(buildSpecification(array.getJSONObject(i))); } return specs; } catch (JSONException e) { throw new IllegalArgumentException("Failed to parse MarketDataSpecification JSON", e); } }
From source file:gg.uhc.uhc.modules.reset.resetters.PlayerResetter.java
/** * Creates actions to reset each of the players * * @param players the players to create for * @param key the cache key to store the actions under *//* ww w .ja va 2 s .c o m*/ public List<Action> createActions(String key, Collection<Player> players) { List<Action> actions = Lists.newArrayListWithCapacity(players.size()); for (Player player : players) { actions.add(getActionForPlayer(player)); } setCache(key, actions); return actions; }
From source file:org.apache.hadoop.hdfs.XAttrHelper.java
/** * Build xattr name with prefix as <code>XAttr</code> list. *///w w w . ja v a 2 s .c o m public static List<XAttr> buildXAttrAsList(String name) { XAttr xAttr = buildXAttr(name); List<XAttr> xAttrs = Lists.newArrayListWithCapacity(1); xAttrs.add(xAttr); return xAttrs; }
From source file:com.google.gitiles.Renderer.java
protected Renderer(Function<String, URL> resourceMapper, Map<String, String> globals, String staticPrefix, URL customTemplates) {/* ww w. j a v a2 s . c om*/ checkNotNull(staticPrefix, "staticPrefix"); List<URL> allTemplates = Lists.newArrayListWithCapacity(SOY_FILENAMES.size() + 1); for (String filename : SOY_FILENAMES) { allTemplates.add(resourceMapper.apply(filename)); } if (customTemplates != null) { allTemplates.add(customTemplates); } else { allTemplates.add(resourceMapper.apply("DefaultCustomTemplates.soy")); } templates = ImmutableList.copyOf(allTemplates); Map<String, String> allGlobals = Maps.newHashMap(); for (Map.Entry<String, String> e : STATIC_URL_GLOBALS.entrySet()) { allGlobals.put(e.getKey(), staticPrefix + e.getValue()); } allGlobals.putAll(globals); this.globals = ImmutableMap.copyOf(allGlobals); }
From source file:com.isotrol.impe3.nr.api.CategoriesCriteria.java
/** * Applies some criteria./* ww w .j av a 2s. c o m*/ * @param type Filter type. * @param values Values to add. If empty, no operation if performed. * @return The filter builder for method chaining. * @throws NullPointerException if the type or any of the values is {@code null}. */ public final Builder apply(FilterType type, UUID... values) { checkNotNull(values, "The filter values to apply must be provided"); List<Optional<UUID>> list = Lists.newArrayListWithCapacity(values.length); for (UUID id : values) { list.add(Optional.fromNullable(id)); } return apply(type, list); }
From source file:org.apache.tez.runtime.api.impl.GroupInputSpec.java
@Override public void readFields(DataInput in) throws IOException { groupName = StringInterner.weakIntern(Text.readString(in)); int numMembers = in.readInt(); groupVertices = Lists.newArrayListWithCapacity(numMembers); for (int i = 0; i < numMembers; ++i) { groupVertices.add(StringInterner.weakIntern(Text.readString(in))); }/*from w ww . j ava 2 s . c o m*/ mergedInputDescriptor = new InputDescriptor(); mergedInputDescriptor.readFields(in); }
From source file:org.jenkinsci.plugins.workflow.support.concurrent.ListFuture.java
/** * Constructor./* w ww . j av a 2 s .co m*/ * * @param futures all the futures to build the list from * @param allMustSucceed whether a single failure or cancellation should * propagate to this future * @param listenerExecutor used to run listeners on all the passed in * futures. */ ListFuture(final ImmutableList<? extends ListenableFuture<? extends V>> futures, final boolean allMustSucceed, final Executor listenerExecutor) { this.futures = futures; this.values = Lists.newArrayListWithCapacity(futures.size()); this.allMustSucceed = allMustSucceed; this.remaining = new AtomicInteger(futures.size()); init(listenerExecutor); }