List of usage examples for com.google.common.collect Lists newArrayListWithExpectedSize
@GwtCompatible(serializable = true) public static <E> ArrayList<E> newArrayListWithExpectedSize(int estimatedSize)
From source file:com.android.tools.idea.wizard.TemplateListProvider.java
@NotNull @Override/*from ww w. ja va 2s . c om*/ public TemplateEntry[] deriveValue(ScopedStateStore state, ScopedStateStore.Key changedKey, @Nullable TemplateEntry[] currentValue) { Boolean isLauncher = state.get(AddAndroidActivityPath.KEY_IS_LAUNCHER); if (!Boolean.TRUE.equals(isLauncher)) { return myTemplates; } List<TemplateEntry> list = Lists.newArrayListWithExpectedSize(myTemplates.length); for (TemplateEntry entry : Arrays.asList(myTemplates)) { if (entry.getMetadata().getParameter(TemplateMetadata.ATTR_IS_LAUNCHER) != null) { list.add(entry); } } return ArrayUtil.toObjectArray(list, TemplateEntry.class); }
From source file:com.datatorrent.contrib.couchbase.AbstractCouchBaseInputOperator.java
@Override public Collection<Partition<AbstractCouchBaseInputOperator<T>>> definePartitions( Collection<Partition<AbstractCouchBaseInputOperator<T>>> partitions, PartitioningContext incrementalCapacity) { conf = store.getConf();//from w ww .j a va 2s. co m int numPartitions = conf.getServers().size(); List<String> list = conf.getServers(); Collection<Partition<AbstractCouchBaseInputOperator<T>>> newPartitions = Lists .newArrayListWithExpectedSize(numPartitions); KryoCloneUtils<AbstractCouchBaseInputOperator<T>> cloneUtils = KryoCloneUtils.createCloneUtils(this); for (int i = 0; i < numPartitions; i++) { AbstractCouchBaseInputOperator<T> oper = cloneUtils.getClone(); oper.setServerIndex(i); oper.setServerURIString(list.get(i)); logger.debug("oper {} urlstring is {}", i, oper.getServerURIString()); newPartitions.add(new DefaultPartition<>(oper)); } return newPartitions; }
From source file:org.attribyte.api.http.Parameter.java
@SuppressWarnings("unchecked") /**/*from w w w . j av a 2s. c o m*/ * Creates a map of parameters from a generic map. * <p> * Map values may be <code>Parameter</code>, <code>String[]</code>, or a <code>Collection</code> If * value is none of these, <code>toString</code> is used to generate a single value. * </p> */ static final Map<String, Parameter> createMap(final Map inputParameters, final Map<String, Parameter> outputMap) { if (inputParameters == null) return Maps.newHashMap(); for (final Map.Entry curr : (Iterable<Map.Entry>) inputParameters.entrySet()) { Object key = curr.getKey(); String keyStr = key.toString(); Object value = curr.getValue(); if (value instanceof Parameter) { outputMap.put(keyStr, (Parameter) value); } else if (value instanceof Collection) { Collection c = (Collection) value; List<String> values = Lists.newArrayListWithExpectedSize(c.size()); for (Object o : c) { if (o != null) { values.add(o.toString()); } } outputMap.put(keyStr, new Parameter(keyStr, values)); } else if (value instanceof String[]) { outputMap.put(keyStr, new Parameter(keyStr, (String[]) value)); } else { outputMap.put(keyStr, new Parameter(keyStr, value != null ? value.toString() : null)); } } return outputMap; }
From source file:org.gradoop.model.impl.algorithms.fsm.gspan.miners.filterrefine.functions.PartitionGSpan.java
/** * Extracts a collection of subgraphs from a collection of subgraphs with * count./*from w ww . j a v a 2 s.c o m*/ * * @param subgraphsWithCount subgraphs with count * @return subgraphs */ private Collection<DFSCode> removeCounts(Collection<WithCount<DFSCode>> subgraphsWithCount) { Collection<DFSCode> subgraphs = Lists.newArrayListWithExpectedSize(subgraphsWithCount.size()); for (WithCount<DFSCode> subgraphWithCount : subgraphsWithCount) { subgraphs.add(subgraphWithCount.getObject()); } return subgraphs; }
From source file:org.moe.designer.rendering.AppResourceRepository.java
private static List<LocalResourceRepository> computeRepositories(@NotNull final AndroidFacet facet, List<LocalResourceRepository> libraries) { List<LocalResourceRepository> repositories = Lists.newArrayListWithExpectedSize(10); LocalResourceRepository resources = ProjectResourceRepository.getProjectResources(facet, true); repositories.addAll(libraries);//from w w w.j av a2 s . c om repositories.add(resources); return repositories; }
From source file:org.eclipse.emf.ecore.xcore.scoping.XcoreImportsConfiguration.java
@Override public Iterable<JvmDeclaredType> getLocallyDefinedTypes(XtextResource resource) { List<EObject> contents = resource.getContents(); String packageName = getPackageName(resource); List<JvmDeclaredType> knownTypes = Lists.newArrayListWithExpectedSize(contents.size() / 2); for (JvmDeclaredType content : Iterables.filter(contents, JvmDeclaredType.class)) { if (Strings.equal(packageName, content.getPackageName())) { knownTypes.add(content);/*from w w w .j a va 2 s . co m*/ } } return knownTypes; }
From source file:org.jbpm.console.ng.ht.client.editors.quicknewuser.QuickNewUserPresenter.java
public List<TypeRole> getSelectedTypesRole() { List<TypeRole> selectedTypesRole = Lists .newArrayListWithExpectedSize(view.getTypeRoleList().getValue().length()); for (int i = 0; i < view.getTypeRoleList().getItemCount(); i++) { if (view.getTypeRoleList().isItemSelected(i)) { selectedTypesRole.add(new TypeRole(view.getTypeRoleList().getValue(i))); }//from w w w. j a va 2s . c om } return selectedTypesRole; }
From source file:ei.ne.ke.cassandra.cql3.template.SelectStatementBuilder.java
/** * * * @param identifier/*from w w w. j a v a2s. c om*/ * @param strTerms * @return this builder. */ public SelectStatementBuilder where(String identifier, Collection<String> ins) { Collection<Term> terms = Lists.newArrayListWithExpectedSize(ins.size()); for (String in : ins) { terms.add(new Term(in)); } relations.add(new In(new Identifier(identifier), terms)); return this; }
From source file:com.google.gdata.model.transforms.atom.AtomRssTransforms.java
private static void addEntryTransforms(MetadataRegistry registry) { registry.build(Entry.KEY, RSS).setName(ITEM); registry.build(Entry.KEY, GdAttributes.ETAG, RSS).setVisible(false); XmlWireFormatProperties properties = new XmlWireFormatProperties(); properties.setElementGenerator(new XmlGenerator.XmlElementGenerator() { @Override/*from w ww. j av a 2s .c om*/ protected List<Attribute> getAttributes(Element e, ElementMetadata<?, ?> metadata) { List<Attribute> attrs = super.getAttributes(e, metadata); if (attrs == null) { attrs = Lists.newArrayListWithExpectedSize(1); } attrs.add(new Attribute("isPermaLink", "false")); return attrs; } }); registry.build(Entry.KEY, Entry.ID, RSS).setName(GUID).setProperties(properties); registry.build(Entry.KEY, Entry.TITLE, RSS).setName(TITLE); registry.build(Entry.KEY, Entry.PUBLISHED, RSS).setName(PUB_DATE).setVirtualValue(new VirtualValue() { public Object generate(Element element, ElementMetadata<?, ?> metadata) { DateTime date = element.getTextValue(Entry.PUBLISHED); return date == null ? "" : date.toStringRfc822(); } public void parse(Element element, ElementMetadata<?, ?> metadata, Object value) throws ParseException { DateTime parsed = DateTime.parseRfc822(value.toString()); element.setTextValue(parsed); } }); XmlWireFormatProperties personProperties = new XmlWireFormatProperties(); personProperties.setElementGenerator(new XmlGenerator.XmlElementGenerator() { @Override public boolean startElement(XmlWriter xw, Element parent, Element e, ElementMetadata<?, ?> metadata) throws IOException { if (!(e instanceof Person)) { return super.startElement(xw, parent, e, metadata); } Person person = (Person) e; String email = person.getEmail(); String name = person.getName(); StringBuilder text = new StringBuilder(); boolean hasEmail = email != null; if (hasEmail) { text.append(email); } if (name != null) { if (hasEmail) { text.append(" ("); } text.append(name); if (hasEmail) { text.append(")"); } } QName xmlName = getName(e, metadata); xw.simpleElement(xmlName.getNs(), xmlName.getLocalName(), null, text.toString()); return false; } @Override public void textContent(XmlWriter xw, Element e, ElementMetadata<?, ?> metadata) { } @Override public void endElement(XmlWriter xw, Element e, ElementMetadata<?, ?> metadata) { } }); registry.build(Entry.KEY, Author.KEY, RSS).setName(AUTHOR).setProperties(personProperties); registry.build(Entry.KEY, Contributor.KEY, RSS).setName(AUTHOR).setProperties(personProperties); registry.build(Entry.KEY, Entry.RIGHTS, RSS).setVisible(false); }
From source file:com.yahoo.yqlplus.engine.internal.bytecode.types.gambit.ConstructInvocation.java
private static String createDescriptor(TypeWidget returnType, List<TypeWidget> argsWidgets) { Type rt = returnType.getJVMType(); List<Type> argTypes = Lists.newArrayListWithExpectedSize(argsWidgets.size()); for (TypeWidget argsWidget : argsWidgets) { argTypes.add(argsWidget.getJVMType()); }// w ww .ja va 2 s . c om return Type.getMethodDescriptor(rt, argTypes.toArray(new Type[argTypes.size()])); }