Example usage for com.google.common.collect Maps newLinkedHashMap

List of usage examples for com.google.common.collect Maps newLinkedHashMap

Introduction

In this page you can find the example usage for com.google.common.collect Maps newLinkedHashMap.

Prototype

public static <K, V> LinkedHashMap<K, V> newLinkedHashMap() 

Source Link

Document

Creates a mutable, empty, insertion-ordered LinkedHashMap instance.

Usage

From source file:com.opengamma.financial.analytics.model.volatility.surface.black.defaultproperties.CommodityBlackVolatilitySurfaceDefaults.java

public CommodityBlackVolatilitySurfaceDefaults(final ComputationTargetType target,
        final String[] valueRequirementNames, final String... defaultsPerCurrency) {
    super(target, true);
    ArgumentChecker.notNull(defaultsPerCurrency, "defaults per currency");
    ArgumentChecker.notNull(valueRequirementNames, "value requiremement names");
    final int n = defaultsPerCurrency.length;
    ArgumentChecker.isTrue(n % 4 == 0,//  ww  w  .  j  a  v  a 2 s.  c  o m
            "Need one forward curve name, forward curve calculation method and surface name per currency");
    _valueRequirementNames = valueRequirementNames;
    _currencyToCurveName = Maps.newLinkedHashMap();
    _currencyToCurveCalculationMethodName = Maps.newLinkedHashMap();
    _currencyToSurfaceName = Maps.newLinkedHashMap();
    for (int i = 0; i < n; i += 4) {
        final String currencyPair = defaultsPerCurrency[i];
        _currencyToCurveName.put(currencyPair, defaultsPerCurrency[i + 1]);
        _currencyToCurveCalculationMethodName.put(currencyPair, defaultsPerCurrency[i + 2]);
        _currencyToSurfaceName.put(currencyPair, defaultsPerCurrency[i + 3]);
    }
}

From source file:exec.csharp.evaluation.impl.F1ByQueryType.java

private void store(String kind, QueryMode queryMode, int num, double f1) {
    Map<QueryMode, Map<Integer, BoxplotData>> modes = getOrCreate(results, kind, Maps.newLinkedHashMap());
    Map<Integer, BoxplotData> nums = getOrCreate(modes, queryMode, Maps.newLinkedHashMap());
    BoxplotData data = getOrCreate(nums, num, new BoxplotData());
    data.add(f1);//from  w ww  .  ja  va 2 s. c  o  m
}

From source file:com.googlecode.blaisemath.style.editor.AttributeSetPropertyModelTestFrame.java

/**
 * Creates new form AttributeSetPropertyModelTestFrame
 *//*  w w  w . j a  v  a2 s. co  m*/
public AttributeSetPropertyModelTestFrame() {
    initComponents();

    EditorRegistration.registerEditors();
    AttributeSet as = Styles.fillStroke(Color.white, Color.red);
    Map<String, Class<?>> asTypes = Maps.newLinkedHashMap();
    asTypes.put(Styles.FILL, Color.class);
    asTypes.put(Styles.STROKE, Color.class);
    AttributeSetPropertyModel m = new AttributeSetPropertyModel(as, asTypes);
    rollupPanel1.add("AS Test", new PropertySheet(m));

    jGraphicComponent1.addGraphic(JGraphics.point(new Point(20, 20), as));

    pack();
}

From source file:io.smartspaces.master.ui.internal.web.WebSupport.java

/**
 * Get a selection list of controllers./*from  w  w  w. jav a2 s.c  om*/
 *
 * @param controllers
 *          The controllers.
 *
 * @return List of controllers ordered by name
 */
public static Map<String, String> getControllerSelections(List<SpaceController> controllers) {
    List<SpaceController> toBeSorted = Lists.newArrayList(controllers);
    Collections.sort(toBeSorted, MasterApiUtilities.SPACE_CONTROLLER_BY_NAME_COMPARATOR);

    Map<String, String> items = Maps.newLinkedHashMap();
    for (SpaceController controller : toBeSorted) {
        items.put(controller.getId(), controller.getName());
    }

    return items;
}

From source file:net.feed_the_beast.launcher.json.JsonFactory.java

public static Object decodeElement(JsonElement e) {
    if (e instanceof JsonObject) {
        Map<String, Object> ret = Maps.newLinkedHashMap();
        for (Map.Entry<String, JsonElement> jse : ((JsonObject) e).entrySet()) {
            ret.put(jse.getKey(), decodeElement(jse.getValue()));
        }/* w w w.  j  a  v a  2 s.  c o  m*/
        return ret;
    }
    if (e instanceof JsonArray) {
        List<Object> ret = Lists.newArrayList();
        for (JsonElement jse : e.getAsJsonArray()) {
            ret.add(decodeElement(jse));
        }
        return ret;

    }
    return e.getAsString();
}

From source file:org.terasology.persistence.typeHandling.coreTypes.MappedContainerTypeHandler.java

@Override
public PersistedData serialize(T value, SerializationContext context) {
    if (value == null) {
        return context.createNull();
    }/*w  w  w  .j ava  2  s  . co  m*/
    Map<String, PersistedData> mappedData = Maps.newLinkedHashMap();
    for (Map.Entry<FieldMetadata<T, ?>, TypeHandler<?>> entry : mappedFields.entrySet()) {
        Object val = entry.getKey().getValue(value);
        TypeHandler handler = entry.getValue();
        PersistedData fieldValue = handler.serialize(val, context);
        if (fieldValue != null) {
            mappedData.put(entry.getKey().getName(), fieldValue);
        }
    }
    return context.create(mappedData);
}

From source file:io.druid.query.select.SelectResultValueBuilder.java

public Result<SelectResultValue> build() {
    // Pull out top aggregated values
    List<EventHolder> values = Lists.newArrayListWithCapacity(pQueue.size());
    Map<String, Integer> pagingIdentifiers = Maps.newLinkedHashMap();
    while (!pQueue.isEmpty()) {
        EventHolder event = pQueue.remove();
        pagingIdentifiers.put(event.getSegmentId(), event.getOffset());
        values.add(event);/*from  w w  w . j  a  v  a  2s .  c  o m*/
    }

    return new Result<SelectResultValue>(timestamp, new SelectResultValue(pagingIdentifiers, values));
}

From source file:com.mmounirou.spotirss.spotify.tracks.SpotifyHrefQuery.java

public Map<Track, String> getTrackHrefs(Set<Track> tracks) throws SpotifyException {
    Map<Track, String> result = Maps.newLinkedHashMap();
    int queryCount = 0;

    for (Track track : tracks) {
        String strHref = getFromCache(track);
        if (strHref == null) {
            if (queryCount != 0 && (queryCount % QUERY_LIMIT_BY_SECONDS) == 0) {
                try {
                    Thread.sleep(TimeUnit.SECONDS.toMillis(1));
                } catch (InterruptedException e) {
                    // DO nothing
                }// w  w  w  .j a va 2s.co m
            }

            try {
                Client client = Client.create();
                WebResource resource = client.resource("http://ws.spotify.com");
                String strXmlResult = resource.path("search/1/track")
                        .queryParam("q", URIUtil.encodePathQuery(track.getSong())).get(String.class);
                // System.out.println(strXmlResult);
                List<XTracks> xtracks = parseResult(strXmlResult);
                if (xtracks.isEmpty()) {
                    SpotiRss.LOGGER.warn(String.format("no spotify song for %s:%s",
                            Joiner.on("&").join(track.getArtists()), track.getSong()));
                } else {
                    strHref = findBestMatchingTrack(xtracks, track).getHref();
                    putInCache(track, strHref);
                    queryCount++;
                }
            } catch (IOException e) {
                throw new SpotifyException(e);
            } catch (SAXException e) {
                throw new SpotifyException(e);
            }
        }
        if (strHref != null) {
            result.put(track, strHref);
        }
    }
    return ImmutableMap.copyOf(result);
}

From source file:org.fao.geonet.services.search.FacetsService.java

@RequestMapping(value = "/{lang}/search/facet/config", produces = { MediaType.APPLICATION_JSON_VALUE })
@ResponseBody//from ww w . j av a 2  s . c  om
public Map<String, List<Facet>> getConfig() {
    Map<String, List<Facet>> results = Maps.newLinkedHashMap();
    for (SummaryType summaryType : luceneConfig.getSummaryTypes().getSummaryTypes()) {
        List<Facet> facets = Lists.newArrayList();
        for (ItemConfig itemConfig : summaryType.getItems()) {
            facets.add(new Facet(itemConfig));
        }
        results.put(summaryType.getName(), facets);
    }

    return results;
}

From source file:com.google.gdt.eclipse.designer.gpe.EntryPointsModuleFilter.java

public List<ModuleDescription> filter(List<ModuleDescription> modules) throws Exception {
    if (!isGpeGwtProject(modules)) {
        return modules;
    }//from  w  ww .j a  va 2s . co  m
    List<ModuleDescription> filtered = Lists.newArrayList();
    // prepare map id -> module
    Map<String, ModuleDescription> moduleMap = Maps.newLinkedHashMap();
    for (ModuleDescription module : modules) {
        moduleMap.put(module.getId(), module);
    }
    // add modules in same order as they are in GPE
    List<String> entryPointModules = gwtEntryPointModules(modules);
    for (String id : entryPointModules) {
        ModuleDescription module = moduleMap.remove(id);
        if (module != null) {
            filtered.add(module);
        }
    }
    // add the rest modules
    filtered.addAll(moduleMap.values());
    // done
    return filtered;
}