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.navigator.nodes.AndroidViewProjectNode.java
@NotNull @Override//from w w w. ja v a2s . c o m public Collection<? extends AbstractTreeNode> getChildren() { Project project = getProject(); assert project != null; ViewSettings settings = getSettings(); // add a node for every module // TODO: make this conditional on getSettings().isShowModules(), otherwise collapse them all at the root List<Module> modules = Arrays.asList(ModuleManager.getInstance(project).getModules()); List<AbstractTreeNode> children = Lists.newArrayListWithExpectedSize(modules.size()); for (Module module : modules) { if (isRootModuleWithNoSources(module)) { // exclude the root module if it doesn't have any source roots // The most common organization of Gradle projects has an empty root module that is simply a container for other modules. // If we detect such a module, then we don't show it.. continue; } AndroidFacet androidFacet = AndroidFacet.getInstance(module); NdkFacet ndkFacet = NdkFacet.getInstance(module); if (androidFacet != null && androidFacet.getAndroidModel() != null) { children.add(new AndroidModuleNode(project, module, settings, myProjectViewPane)); } else if (ndkFacet != null && ndkFacet.getNdkModuleModel() != null) { children.add(new NdkModuleNode(project, module, settings)); } else { children.add(new NonAndroidModuleNode(project, module, settings)); } } // If this is a gradle project, and its sync failed, then we attempt to show project root as a folder so that the files // are still visible. See https://code.google.com/p/android/issues/detail?id=76564 if (children.isEmpty() && isBuildWithGradle(project) && GradleSyncState.getInstance(project).lastSyncFailed()) { PsiDirectory dir = PsiManager.getInstance(project).findDirectory(project.getBaseDir()); if (dir != null) { children.add(new PsiDirectoryNode(project, dir, settings)); } } if (isBuildWithGradle(project)) { children.add(new AndroidBuildScriptsGroupNode(project, settings)); } ExternalBuildFilesGroupNode externalBuildFilesNode = new ExternalBuildFilesGroupNode(project, settings); if (!externalBuildFilesNode.getChildren().isEmpty()) { children.add(externalBuildFilesNode); } // TODO: What about files in the base project directory // TODO: Do we want to show the External Libraries Node or a Dependencies node return children; }
From source file:org.spongepowered.common.data.manipulator.immutable.tileentity.ImmutableSpongeSignData.java
@Override public DataContainer toContainer() { List<String> jsonLines = Lists.newArrayListWithExpectedSize(4); for (Text line : this.lines) { jsonLines.add(Texts.json().to(line)); }//from ww w .jav a 2 s. c om return new MemoryDataContainer().set(Keys.SIGN_LINES.getQuery(), jsonLines); }
From source file:edu.umich.robot.soar.ObjectsIL.java
@Override public void update() { List<Integer> seen = Lists.newArrayListWithExpectedSize(objMap.size()); List<VirtualObject> visibleObjects = agent.getRobotOutput().getVisibleObjects(); for (VirtualObject o : visibleObjects) { Integer id = Integer.valueOf(o.getId()); ObjectIL oil = objMap.get(id);/*from w w w. j a va2 s .c o m*/ if (oil == null) { oil = new ObjectIL(agent, o, getRoot()); objMap.put(id, oil); if (logger.isDebugEnabled()) logger.debug("Object for " + id + " created."); } if (invisibleTimestamps.containsKey(id)) { invisibleTimestamps.remove(id); oil.setVisible(true); if (logger.isDebugEnabled()) logger.debug("Object " + id + " went visible."); } oil.update(); seen.add(o.getId()); } for (Iterator<Entry<Integer, ObjectIL>> iter = objMap.entrySet().iterator(); iter.hasNext();) { Entry<Integer, ObjectIL> e = iter.next(); if (!seen.contains(e.getKey())) { Long it = invisibleTimestamps.get(e.getKey()); if (it == null) { invisibleTimestamps.put(e.getKey(), TimeUtil.utime()); e.getValue().setVisible(false); if (logger.isDebugEnabled()) logger.debug("Object " + e.getKey() + " went invisible."); } else { long ms = TimeUtil.utime() - it; if (ms > lingerMillis) { if (logger.isDebugEnabled()) { double sec = ms / (double) TimeUnit.MILLISECONDS.convert(1, TimeUnit.SECONDS); logger.debug("Object " + e.getKey() + " went invalid (" + sec + " sec)."); } invisibleTimestamps.remove(e.getKey()); e.getValue().destroy(); iter.remove(); continue; } } e.getValue().update(); } } }
From source file:org.eclipse.xtext.common.types.access.binary.asm.BinaryMethodSignature.java
public List<BinaryGenericTypeSignature> getParameterTypes() { try {//ww w.j av a2 s. c o m int i = chars.indexOf('(', offset); if (i < 0) { throw new IllegalArgumentException(); } else { i++; } if (chars.charAt(i) == ')') { return Collections.emptyList(); } List<BinaryGenericTypeSignature> result = Lists.newArrayListWithExpectedSize(3); for (;;) { if (chars.charAt(i) == ')') { return result; } int e = SignatureUtil.scanTypeSignature(chars, i); if (e < 0) { throw new IllegalArgumentException(); } result.add(new BinaryGenericTypeSignature(chars, i, e - i + 1)); i = e + 1; } } catch (ArrayIndexOutOfBoundsException e) { throw new IllegalArgumentException(); } }
From source file:defrac.intellij.projectView.DefracViewDefracNode.java
@NotNull @Override/*from ww w. j av a2s . co m*/ public Collection<AbstractTreeNode> getChildren() { final Project project = getProject(); if (project == null) { return Lists.newArrayListWithCapacity(0); } final DefracProject defracProject = getValue(); final ArrayList<AbstractTreeNode> children = Lists .newArrayListWithExpectedSize(DefracPlatform.values().length); if (defracProject == null || defracProject.isDisposed()) { setValue(null); return children; } for (final DefracPlatform platform : DefracPlatform.values()) { final List<Module> modules = defracProject.getModules(platform); if (modules.isEmpty()) { continue; } // note: we could use getParentValue apparently and don't need DefracProjectPlatform children.add(new DefracViewPlatformNode(project, DefracProjectPlatform.create(project, defracProject, platform), getSettings())); } return children; }
From source file:edu.umich.robot.soar.CarryIL.java
@Override public void update() { List<Integer> seen = Lists.newArrayListWithExpectedSize(objMap.size()); Set<VirtualObject> carriedObjects = agent.getRobotOutput().getCarriedObjects(); for (VirtualObject o : carriedObjects) { Integer id = Integer.valueOf(o.getId()); ObjectIL oil = objMap.get(id);//from w ww .j ava 2s. c o m if (oil == null) { oil = new ObjectIL(agent, o, getRoot()); objMap.put(id, oil); if (logger.isDebugEnabled()) logger.debug("Object for " + id + " created."); } if (invisibleTimestamps.containsKey(id)) { invisibleTimestamps.remove(id); oil.setVisible(true); if (logger.isDebugEnabled()) logger.debug("Object " + id + " went visible."); } oil.update(); seen.add(o.getId()); } for (Iterator<Entry<Integer, ObjectIL>> iter = objMap.entrySet().iterator(); iter.hasNext();) { Entry<Integer, ObjectIL> e = iter.next(); if (!seen.contains(e.getKey())) { Long it = invisibleTimestamps.get(e.getKey()); if (it == null) { invisibleTimestamps.put(e.getKey(), TimeUtil.utime()); e.getValue().setVisible(false); if (logger.isDebugEnabled()) logger.debug("Object " + e.getKey() + " went invisible."); } else { long ms = TimeUtil.utime() - it; if (ms > lingerMillis) { if (logger.isDebugEnabled()) { double sec = ms / (double) TimeUnit.MILLISECONDS.convert(1, TimeUnit.SECONDS); logger.debug("Object " + e.getKey() + " went invalid (" + sec + " sec)."); } invisibleTimestamps.remove(e.getKey()); e.getValue().destroy(); iter.remove(); continue; } } e.getValue().update(); } } }
From source file:edu.umn.msi.tropix.webgui.server.session.UserSessionInfoClosureImpl.java
public void apply(final SessionInfo sessionInfo) { final String gridIdentity = userSession.getGridId(); final User user = userService.createOrGetUser(gridIdentity); final User gwtUser = beanSanitizer.sanitize(user); gwtUser.setHomeFolder(beanSanitizer.sanitize(userService.getHomeFolder(user.getCagridId()))); final Group primaryGroup = userService.getPrimaryGroup(gridIdentity); final Group gwtPrimaryGroup = beanSanitizer.sanitize(primaryGroup); final Group[] groups = userService.getGroups(gridIdentity); final List<Group> gwtGroups = Lists.newArrayListWithExpectedSize(groups.length); for (Group group : groups) { gwtGroups.add(beanSanitizer.sanitize(group)); }//ww w . j a v a 2 s . co m sessionInfo.setPrimaryGroup(gwtPrimaryGroup); sessionInfo.setGroups(gwtGroups); if (gridIdentity.equals(SecurityConstants.GUEST_IDENTITY)) { sessionInfo.getModules().add(Module.GUEST); } else { sessionInfo.getModules().add(Module.USER); } if (userSession.getProxy().getGlobusCredential() != null) { sessionInfo.getModules().add(Module.GRID); } else { sessionInfo.getModules().add(Module.LOCAL); } LOG.trace("Checking if " + gridIdentity + " is admin"); if (userService.isAdmin(gridIdentity)) { sessionInfo.getModules().add(Module.ADMIN); sessionInfo.setAdmin(true); } else { sessionInfo.setAdmin(false); } sessionInfo.setUser(gwtUser); sessionInfo.setGuest(userSession.isGuest()); }
From source file:org.envirocar.server.rest.decoding.json.SensorDecoder.java
private Object parseArrayNode(JsonNode value) { List<Object> list = Lists.newArrayListWithExpectedSize(value.size()); for (int i = 0; i < value.size(); ++i) { list.add(parseNode(value.get(i))); }//from w w w . j a va 2 s .c o m return list; }
From source file:org.spongepowered.common.data.processor.data.tileentity.TileEntitySignDataProcessor.java
@Override protected Optional<List<Text>> getVal(TileEntitySign sign) { final IChatComponent[] rawLines = sign.signText; final List<Text> signLines = Lists.newArrayListWithExpectedSize(4); for (int i = 0; i < rawLines.length; i++) { signLines.add(i, rawLines[i] == null ? Text.EMPTY : SpongeTexts.toText(rawLines[i])); }/*from www. j a v a 2 s. com*/ return Optional.of(signLines); }
From source file:com.android.builder.core.JackProcessBuilder.java
@NonNull public JackProcessBuilder addImportFiles(@NonNull Collection<File> importFiles) { if (mImportFiles == null) { mImportFiles = Lists.newArrayListWithExpectedSize(importFiles.size()); }/* w w w. j a v a 2 s.com*/ mImportFiles.addAll(importFiles); return this; }