List of usage examples for com.google.common.collect Maps newLinkedHashMap
public static <K, V> LinkedHashMap<K, V> newLinkedHashMap()
From source file:brooklyn.location.cloud.CloudLocation.java
public CloudLocation() { this(Maps.newLinkedHashMap()); }
From source file:defrac.intellij.projectView.DefracViewProjectNode.java
@NotNull @Override/*w ww.jav a 2s. c om*/ public Collection<? extends AbstractTreeNode> getChildren() { // we want to collect all modules and sort them based on // (1) the fact that they have a defrac facet // (1.1) the defrac project they belong to // (2) arbitrary modules final Project project = getProject(); if (project == null) { return Collections.emptyList(); } final Set<Module> modules = getModules(project); final Map<String, DefracProject> defracModules = Maps.newLinkedHashMap(); final ArrayList<Module> normalModules = Lists.newArrayListWithCapacity(0); for (final Module module : modules) { final DefracFacet facet = DefracFacet.getInstance(module); if (facet == null) { normalModules.add(module); } else { final File settingsFile = facet.getSettingsFile(); final String key = settingsFile.getAbsolutePath(); DefracProject defracProject = defracModules.get(key); if (defracProject == null) { defracProject = DefracProject.forSettings(project, checkNotNull(VfsUtil.findFileByIoFile(settingsFile, true))); defracModules.put(key, defracProject); } defracProject.addModule(module); } } final Collection<AbstractTreeNode> defracNodes = defracModules(project, defracModules.values()); final Collection<AbstractTreeNode> normalNodes = normalModules(normalModules); final int totalNodes = defracNodes.size() + normalNodes.size(); final ArrayList<AbstractTreeNode> result = Lists.newArrayListWithExpectedSize(totalNodes); result.addAll(defracNodes); result.addAll(normalNodes); return result; }
From source file:org.jclouds.virtualbox.functions.admin.ImagesToYamlImagesFromYamlDescriptor.java
@Override public Map<Image, YamlImage> get() { Constructor constructor = new Constructor(Config.class); TypeDescription imageDesc = new TypeDescription(YamlImage.class); imageDesc.putListPropertyType("images", String.class); constructor.addTypeDescription(imageDesc); // Issue 855: testng is rev-locking us to snakeyaml 1.6 // we have to use old constructor until this is fixed Yaml yaml = new Yaml(new Loader(constructor)); Config config = (Config) yaml.load(yamlDescriptor); checkState(config != null, "missing config: class"); checkState(config.images != null, "missing images: collection"); Map<Image, YamlImage> backingMap = Maps.newLinkedHashMap(); for (YamlImage yamlImage : config.images) { backingMap.put(YamlImage.toImage.apply(yamlImage), yamlImage); }//from w w w . j a va 2 s . co m return backingMap; }
From source file:org.jpmml.evaluator.EvaluatorUtil.java
static public <K> List<Map<K, Object>> groupRows(K groupKey, List<? extends Map<K, ?>> table) { Map<Object, ListMultimap<K, Object>> groupedRows = Maps.newLinkedHashMap(); for (int i = 0; i < table.size(); i++) { Map<K, ?> row = table.get(i); Object groupValue = row.get(groupKey); ListMultimap<K, Object> groupedRow = groupedRows.get(groupValue); if (groupedRow == null) { groupedRow = ArrayListMultimap.create(); groupedRows.put(groupValue, groupedRow); }// w w w. ja v a 2 s .co m Collection<? extends Map.Entry<K, ?>> entries = row.entrySet(); for (Map.Entry<K, ?> entry : entries) { K key = entry.getKey(); Object value = entry.getValue(); groupedRow.put(key, value); } } List<Map<K, Object>> resultTable = Lists.newArrayList(); Collection<Map.Entry<Object, ListMultimap<K, Object>>> entries = groupedRows.entrySet(); for (Map.Entry<Object, ListMultimap<K, Object>> entry : entries) { Map<K, Object> resultRow = Maps.newLinkedHashMap(); resultRow.putAll((entry.getValue()).asMap()); // The value of the "group by" column is a single Object, not a Collection (ie. java.util.List) of Objects resultRow.put(groupKey, entry.getKey()); resultTable.add(resultRow); } return resultTable; }
From source file:de.iteratec.iteraplan.businesslogic.reports.query.options.TabularReporting.QStatusDataInformationSystemRelease.java
private Map<TypeOfStatus, Boolean> getStatusData() { Map<TypeOfStatus, Boolean> resultMap = Maps.newLinkedHashMap(); for (TypeOfStatus status : TypeOfStatus.values()) { if (status.equals(TypeOfStatus.CURRENT)) { resultMap.put(status, Boolean.TRUE); } else {/* www.ja v a 2 s. com*/ resultMap.put(status, Boolean.FALSE); } } return resultMap; }
From source file:com.salesforce.ide.apex.internal.core.ApexSourceUtils.java
/** * Find test classes in a given project. Test classes are annotated with @IsTest. * //from w w w. j a va 2 s .co m * @param project * @return Map of test resources whose key is the resource ID and values are test method names */ public Map<IResource, List<String>> findTestClassesInProject(IProject project) { final Map<IResource, List<String>> allTests = Maps.newLinkedHashMap(); List<IResource> projectResources = findLocalSourcesInProject(project); List<IResource> projectClasses = filterSourcesByClass(projectResources); try { for (final IResource projectResource : projectClasses) { List<String> methodNames = findTestMethodNamesInFile(projectResource); if (methodNames != null && methodNames.size() > 0) { allTests.put(projectResource, methodNames); } } } catch (Exception e) { logger.error("Encountered an issue trying to find test classes in the project", e); } return allTests; }
From source file:org.jclouds.cloudsigma.functions.MapToDriveInfo.java
@Override public DriveInfo apply(Map<String, String> from) { if (from.size() == 0) return null; DriveInfo.Builder builder = new DriveInfo.Builder(); builder.name(from.get("name")); if (from.containsKey("use")) builder.use(Splitter.on(' ').split(from.get("use"))); if (from.containsKey("status")) builder.status(DriveStatus.fromValue(from.get("status"))); builder.metrics(buildMetrics(from)); builder.user(from.get("user")); builder.encryptionCipher(from.get("encryption:cipher")); builder.uuid(from.get("drive")); if (from.containsKey("claim:type")) builder.claimType(ClaimType.fromValue(from.get("claim:type"))); if (from.containsKey("claimed")) builder.claimed(Splitter.on(' ').split(from.get("claimed"))); if (from.containsKey("tags")) builder.tags(Splitter.on(' ').split(from.get("tags"))); if (from.containsKey("readers")) builder.readers(Splitter.on(' ').split(from.get("readers"))); if (from.containsKey("size")) builder.size(Long.valueOf(from.get("size"))); Map<String, String> metadata = Maps.newLinkedHashMap(); for (Entry<String, String> entry : from.entrySet()) { if (entry.getKey().startsWith("user:")) metadata.put(entry.getKey().substring(entry.getKey().indexOf(':') + 1), entry.getValue()); }//from w w w . j a v a 2 s . c o m if (from.containsKey("use")) builder.use(Splitter.on(' ').split(from.get("use"))); if (from.containsKey("bits")) builder.bits(Integer.valueOf(from.get("bits"))); if (from.containsKey("url")) builder.url(URI.create(from.get("url"))); builder.encryptionKey(from.get("encryption:key")); builder.description(from.get("description")); builder.installNotes(from.get("install_notes")); builder.os(from.get("os")); if (from.containsKey("drive_type")) builder.driveType(Splitter.on(',').split(from.get("drive_type"))); if (from.containsKey("autoexpanding")) builder.autoexpanding(Boolean.valueOf(from.get("autoexpanding"))); if (from.containsKey("free")) builder.free(Boolean.valueOf(from.get("free"))); if (from.containsKey("type")) builder.type(DriveType.fromValue(from.get("type"))); try { return builder.build(); } catch (NullPointerException e) { logger.trace("entry missing data: %s; %s", e.getMessage(), from); return null; } }
From source file:org.ldp4j.application.ApplicationContext.java
private ApplicationContext() { this.delegate = RuntimeDelegate.getInstance(); this.references = Maps.newLinkedHashMap(); this.sessionOwner = Maps.newLinkedHashMap(); this.threadSession = Maps.newLinkedHashMap(); this.referenceQueue = new ReferenceQueue<ContextWriteSession>(); LOGGER.info("Initialized Application Context"); }
From source file:au.id.hazelwood.sos.web.controller.framework.GlobalExceptionHandler.java
private Map<String, Object> createDefaultResponseBody(Exception ex, HttpStatus status) { Map<String, Object> body = Maps.newLinkedHashMap(); body.put("status", status.value()); body.put("message", ex.getMessage()); return body;/* w w w . j a va 2 s . co m*/ }
From source file:com.preferanser.shared.domain.Editor.java
public Editor reset() { name = null;/* ww w .j av a 2 s .co m*/ description = null; firstTurn = null; players = null; widow = new Widow(); handContracts = Maps.newHashMapWithExpectedSize(Hand.PLAYING_HANDS.size()); centerCardHandMap = Maps.newLinkedHashMap(); // order is important handCardMultimap = LinkedHashMultimap.create(TableLocation.values().length, Card.values().length); return this; }