List of usage examples for com.google.common.collect Maps newLinkedHashMap
public static <K, V> LinkedHashMap<K, V> newLinkedHashMap()
From source file:org.artifactory.descriptor.repo.jaxb.VirtualRepositoriesMapAdapter.java
@Override public Map<String, VirtualRepoDescriptor> unmarshal(Wrappper wrapper) throws Exception { Map<String, VirtualRepoDescriptor> virtualRepositoriesMap = Maps.newLinkedHashMap(); for (VirtualRepoDescriptor repository : wrapper.getList()) { String key = repository.getKey(); VirtualRepoDescriptor repo = virtualRepositoriesMap.put(key, repository); //Test for repositories with the same key if (repo != null) { //Throw an error since jaxb swallows exceptions throw new Error("Duplicate virtual repository key in configuration: " + key + "."); }/*from w ww . j a v a 2s .c o m*/ } return virtualRepositoriesMap; }
From source file:org.terasology.persistence.typeHandling.mathTypes.Region3iTypeHandler.java
@Override public PersistedData serialize(Region3i value, SerializationContext context) { Map<String, PersistedData> map = Maps.newLinkedHashMap(); map.put(MIN_FIELD, context.create(value.min(), Vector3i.class)); map.put(SIZE_FIELD, context.create(value.size(), Vector3i.class)); return context.create(map); }
From source file:org.jclouds.elastichosts.functions.ListOfKeyValuesDelimitedByBlankLinesToListOfMaps.java
@Override public List<Map<String, String>> apply(String from) { List<Map<String, String>> maps = Lists.newArrayList(); for (String listOfKeyValues : Splitter.on("\n\n").split(from)) { if (!"".equals(listOfKeyValues)) { Map<String, String> map = Maps.newLinkedHashMap(); for (String keyValueLine : Splitter.on('\n').split(listOfKeyValues)) { if (!"".equals(keyValueLine)) { int firstIndex = keyValueLine.indexOf(' '); String key = keyValueLine.substring(0, firstIndex); String value = keyValueLine.substring(firstIndex + 1).replace("\\n", "\n"); map.put(key, value); }// w w w . j ava2s . c o m } if (map.size() != 0) maps.add(map); } } return maps; }
From source file:org.gradle.language.base.internal.model.DefaultVariantsMetaData.java
public static VariantsMetaData extractFrom(BinarySpec spec, ModelSchemaStore schemaStore) { Map<String, Object> variants = Maps.newLinkedHashMap(); ImmutableMap.Builder<String, ModelType<?>> dimensionTypesBuilder = ImmutableMap.builder(); ModelSchema<?> schema = schemaStore.getSchema(((BinarySpecInternal) spec).getPublicType()); if (schema instanceof ModelStructSchema) { VariantAspect variantAspect = ((ModelStructSchema<?>) schema).getAspect(VariantAspect.class); if (variantAspect != null) { for (ModelProperty<?> property : variantAspect.getDimensions()) { // note: it's not the role of this class to validate that the annotation is properly used, that // is to say only on a getter returning String or a Named instance, so we trust the result of // the call Object value = property.getPropertyValue(spec); variants.put(property.getName(), value); dimensionTypesBuilder.put(property.getName(), property.getType()); }//from ww w. j a va2 s.co m } } return new DefaultVariantsMetaData(Collections.unmodifiableMap(variants), dimensionTypesBuilder.build()); }
From source file:org.apache.brooklyn.location.jclouds.JcloudsLocationResolver.java
private static Map<String, ProviderMetadata> getProvidersMap() { Map<String, ProviderMetadata> result = Maps.newLinkedHashMap(); for (ProviderMetadata p : Providers.all()) { result.put(p.getId(), p);//from w w w . j a v a 2s. c o m } return ImmutableMap.copyOf(result); }
From source file:com.baidu.rigel.biplatform.ma.resource.utils.LiteOlapViewUtils.java
/** * /* w ww .j av a 2 s . c o m*/ * @param liteOlapArea * @param schema * @return MetaData */ public static MetaData parseMetaData(LiteOlapExtendArea liteOlapArea, Schema schema) { LogicModel logicModel = liteOlapArea.getLogicModel(); MetaData metaData = new MetaData(); Map<String, LiteOlapDim> liteOlapDims = Maps.newLinkedHashMap(); Map<String, LiteOlapInd> liteOlapInds = Maps.newLinkedHashMap(); /** * LiteOlapDim */ for (Item item : liteOlapArea.getCandDims().values()) { LiteOlapDim dim = parseDim(item, schema, false); liteOlapDims.put(dim.getName(), dim); } /** * LiteOlapInd */ for (Item item : liteOlapArea.getCandInds().values()) { LiteOlapInd ind = parseInd(item, schema, false); liteOlapInds.put(ind.getName(), ind); } /** * LiteOlapDim */ for (Item item : logicModel.getItems()) { OlapElement element = ReportDesignModelUtils.getDimOrIndDefineWithId(schema, item.getCubeId(), item.getOlapElementId()); if (element instanceof Dimension) { LiteOlapDim dim = parseDim(item, schema, false); liteOlapDims.put(dim.getName(), dim); } else if (element instanceof Measure) { LiteOlapInd ind = parseInd(item, schema, false); liteOlapInds.put(ind.getName(), ind); } } metaData.setCubeNames(new String[] { liteOlapArea.getCubeId() }); metaData.setDims(liteOlapDims.values().toArray(new LiteOlapDim[0])); metaData.setInds(liteOlapInds.values().toArray(new LiteOlapInd[0])); metaData.setSelectCubeNum(1); return metaData; }
From source file:org.jclouds.elasticstack.functions.ListOfKeyValuesDelimitedByBlankLinesToListOfMaps.java
@Override public List<Map<String, String>> apply(String from) { List<Map<String, String>> maps = Lists.newArrayList(); for (String listOfKeyValues : Splitter.on("\n\n").split(from)) { if (!"".equals(listOfKeyValues)) { Map<String, String> map = Maps.newLinkedHashMap(); for (String keyValueLine : Splitter.on('\n').split(listOfKeyValues)) { if (!"".equals(keyValueLine)) { int firstIndex = keyValueLine.indexOf(' '); if (firstIndex != -1) { String key = keyValueLine.substring(0, firstIndex); String value = keyValueLine.substring(firstIndex + 1).replace("\\n", "\n"); map.put(key, value); }//www. j av a2 s. c om } } if (map.size() != 0) maps.add(map); } } return maps; }
From source file:com.netflix.explorers.model.MenuItem.java
public MenuItem addChild(MenuItem child) { if (this.children == null) this.children = Maps.newLinkedHashMap(); this.children.put(child.getName(), child); return this; }
From source file:com.google.template.soy.data.SoyMapData.java
public SoyMapData() { map = Maps.newLinkedHashMap(); }
From source file:org.jpmml.evaluator.TargetUtil.java
/** * Evaluates the {@link Targets} element for {@link MiningFunctionType#REGRESSION regression} models. */// ww w . j a v a 2 s . c om static public Map<FieldName, ? extends Number> evaluateRegression(Map<FieldName, ? extends Number> predictions, ModelEvaluationContext context) { ModelEvaluator<?> modelEvaluator = context.getModelEvaluator(); Targets targets = modelEvaluator.getTargets(); if (targets == null || Iterables.isEmpty(targets)) { return predictions; } Map<FieldName, Number> result = Maps.newLinkedHashMap(); Collection<? extends Map.Entry<FieldName, ? extends Number>> entries = predictions.entrySet(); for (Map.Entry<FieldName, ? extends Number> entry : entries) { FieldName key = entry.getKey(); Number value = entry.getValue(); Target target = modelEvaluator.getTarget(key); if (target != null) { if (value == null) { value = getDefaultValue(target); } // End if if (value != null) { value = processValue(target, value); } } result.put(key, value); } return result; }