List of usage examples for java.util LinkedHashMap put
V put(K key, V value);
From source file:com.opengamma.analytics.financial.interestrate.InstrumentSingleCurveSensitivityCalculatorTest.java
private static Map<String, double[]> getSingleCurveMaturities() { final LinkedHashMap<String, double[]> maturities = new LinkedHashMap<String, double[]>(); maturities.put("libor", new double[] { 0.25 }); maturities.put("fra", new double[] { 0.51, 0.74 }); maturities.put("swap", new double[] { 1, 2, 3, 4, 5, 6, 7, 10, 15, 20, 25, 30 }); return maturities; }
From source file:com.opengamma.analytics.financial.interestrate.InstrumentSingleCurveSensitivityCalculatorTest.java
private static Map<String, double[]> getSingleCurveMarketData() { final LinkedHashMap<String, double[]> marketRates = new LinkedHashMap<String, double[]>(); marketRates.put("libor", new double[] { 0.02 }); // marketRates.put("fra", new double[] { 0.0366, 0.04705 }); marketRates.put("swap", new double[] { 0.04285, 0.03953, 0.03986, 0.040965, 0.042035, 0.04314, 0.044, 0.046045, 0.048085, 0.048925, 0.049155, 0.049195 }); return marketRates; }
From source file:com.streamsets.pipeline.stage.lib.hive.HiveMetastoreUtil.java
/** * Fill in metadata to Record. This is for new partition creation. *//*w w w. j av a 2s . com*/ public static Field newPartitionMetadataFieldBuilder(String database, String tableName, LinkedHashMap<String, String> partitionList, String location) throws StageException { LinkedHashMap<String, Field> metadata = new LinkedHashMap<>(); metadata.put(HiveMetastoreUtil.SEP + HiveMetastoreUtil.DATABASE_FIELD, Field.create(database)); metadata.put(HiveMetastoreUtil.SEP + HiveMetastoreUtil.TABLE_FIELD, Field.create(tableName)); metadata.put(HiveMetastoreUtil.SEP + HiveMetastoreUtil.LOCATION_FIELD, Field.create(location)); //fill in the partition list here metadata.put(HiveMetastoreUtil.SEP + HiveMetastoreUtil.PARTITION_FIELD, generateInnerFieldFromTheList(partitionList, PARTITION_NAME, PARTITION_VALUE, false)); return Field.create(metadata); }
From source file:com.streamsets.pipeline.stage.lib.hive.HiveMetastoreUtil.java
/** * Fill in metadata to Record. This is for new schema creation. *//*from w w w . ja v a2 s .c o m*/ public static Field newSchemaMetadataFieldBuilder(String database, String tableName, LinkedHashMap<String, HiveType> columnList, LinkedHashMap<String, HiveType> partitionTypeList, boolean internal, String location, String avroSchema) throws StageException { LinkedHashMap<String, Field> metadata = new LinkedHashMap<>(); metadata.put(HiveMetastoreUtil.SEP + HiveMetastoreUtil.DATABASE_FIELD, Field.create(database)); metadata.put(HiveMetastoreUtil.SEP + HiveMetastoreUtil.TABLE_FIELD, Field.create(tableName)); metadata.put(HiveMetastoreUtil.SEP + HiveMetastoreUtil.LOCATION_FIELD, Field.create(location)); //fill in column type list here metadata.put(HiveMetastoreUtil.SEP + HiveMetastoreUtil.COLUMNS_FIELD, generateInnerFieldFromTheList(columnList, COLUMN_NAME, COLUMN_TYPE, false)); //fill in partition type list here metadata.put(HiveMetastoreUtil.SEP + HiveMetastoreUtil.PARTITION_FIELD, generateInnerFieldFromTheList(partitionTypeList, PARTITION_NAME, PARTITION_TYPE, true)); metadata.put(HiveMetastoreUtil.SEP + HiveMetastoreUtil.INTERNAL_FIELD, Field.create(internal)); metadata.put(HiveMetastoreUtil.SEP + HiveMetastoreUtil.AVRO_SCHEMA, Field.create(avroSchema)); return Field.create(metadata); }
From source file:org.ow2.chameleon.everest.servlet.EverestServlet.java
public static Map<String, ?> flat(Map<String, String[]> params) { if (params == null) { return Collections.emptyMap(); }//from w ww .ja v a 2 s . co m LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>(); for (Map.Entry<String, String[]> entry : params.entrySet()) { if (entry.getValue() == null) { // No value. map.put(entry.getKey(), null); } else if (entry.getValue().length == 0) { map.put(entry.getKey(), Boolean.TRUE.toString()); } else if (entry.getValue().length == 1) { // Scalar parameter. map.put(entry.getKey(), entry.getValue()[0]); } else if (entry.getValue().length > 1) { // Translate to list map.put(entry.getKey(), Arrays.asList(entry.getValue())); } } return map; }
From source file:com.epam.ta.reportportal.core.widget.content.MostFailedTestCasesFilterStrategy.java
/** * Sorting result map from data by counter<br> * <b>WARNING: do not use method somewhere else except here cause complex * map value and top-20 limit</b>//from www . j a v a2 s .c o m * * @param map * @return */ @SuppressWarnings("hiding") private static <K, ComplexValue extends Comparable<? super ComplexValue>> LinkedHashMap<K, ComplexValue> sortByValue( Map<K, ComplexValue> map) { List<Map.Entry<K, ComplexValue>> list = new LinkedList<>(map.entrySet()); Collections.sort(list, Comparator.comparing(object -> (object.getValue()))); // Splitter for TOP-20 values included LinkedHashMap<K, ComplexValue> result = new LinkedHashMap<>(); int counter = 0; for (Map.Entry<K, ComplexValue> entry : list) { if (counter < ITEMS_COUNT_VALUE) { result.put(entry.getKey(), entry.getValue()); counter++; } else break; } return result; }
From source file:models.Milestone.java
/** * get milestone list by hashmap.//from ww w . j av a2s. c o m * key: milestone id * value: milestone title * * @return linkedHashMap */ public static Map<String, String> options(Long projectId) { LinkedHashMap<String, String> options = new LinkedHashMap<>(); for (Milestone milestone : findMilestones(projectId, State.ALL, "title", Direction.ASC)) { options.put(milestone.id.toString(), milestone.title); } return options; }
From source file:ca.sfu.federation.utils.IContextUtils.java
public static Map<String, INamed> getElementMap(List<INamed> Elements) { LinkedHashMap<String, INamed> map = new LinkedHashMap<String, INamed>(); Iterator e = Elements.iterator(); while (e.hasNext()) { INamed named = (INamed) e.next(); map.put(named.getName(), named); }//from w w w . j av a2 s .c om return map; }
From source file:de.tudarmstadt.ukp.dkpro.tc.core.util.ReportUtils.java
/** * Converts a map containing a matrix into a matrix * // w w w .ja v a 2 s.co m * @param aggregateMap * a map created with {@link ReportUtils#updateAggregateMatrix(Map, File)} * @see ReportUtils#updateAggregateMatrix(Map, File) * @return a table with the matrix */ public static FlexTable<String> createOverallConfusionMatrix(Map<List<String>, Double> aggregateMap) { FlexTable<String> cMTable = FlexTable.forClass(String.class); cMTable.setSortRows(false); Set<String> labelsPred = new TreeSet<String>(); Set<String> labelsAct = new TreeSet<String>(); // sorting rows/columns for (List<String> key : aggregateMap.keySet()) { labelsPred.add(key.get(0).substring(0, key.get(0).indexOf(Constants.CM_PREDICTED))); labelsAct.add(key.get(1).substring(0, key.get(1).indexOf(Constants.CM_ACTUAL))); } List<String> labelsPredL = new ArrayList<String>(labelsPred); List<String> labelsActL = new ArrayList<String>(labelsAct); // create temporary matrix double[][] tempM = new double[labelsAct.size()][labelsPred.size()]; for (List<String> key : aggregateMap.keySet()) { int c = labelsPredL.indexOf(key.get(0).substring(0, key.get(0).indexOf(Constants.CM_PREDICTED))); int r = labelsActL.indexOf(key.get(1).substring(0, key.get(1).indexOf(Constants.CM_ACTUAL))); tempM[r][c] = aggregateMap.get(key); } // convert to FlexTable for (int i = 0; i < tempM.length; i++) { LinkedHashMap<String, String> row = new LinkedHashMap<String, String>(); for (int r = 0; r < tempM[0].length; r++) { row.put(labelsPredL.get(r) + " " + Constants.CM_PREDICTED, String.valueOf(tempM[i][r])); } cMTable.addRow(labelsActL.get(i) + " " + Constants.CM_ACTUAL, row); } return cMTable; }
From source file:info.magnolia.cms.util.ServletUtil.java
/** * Returns the init parameters for a {@link javax.servlet.ServletConfig} object as a Map, preserving the order in which they are exposed * by the {@link javax.servlet.ServletConfig} object. *///from w ww . j ava 2 s. c o m public static LinkedHashMap<String, String> initParametersToMap(ServletConfig config) { LinkedHashMap<String, String> initParameters = new LinkedHashMap<String, String>(); Enumeration parameterNames = config.getInitParameterNames(); while (parameterNames.hasMoreElements()) { String parameterName = (String) parameterNames.nextElement(); initParameters.put(parameterName, config.getInitParameter(parameterName)); } return initParameters; }