List of usage examples for java.util LinkedHashMap entrySet
public Set<Map.Entry<K, V>> entrySet()
From source file:com.github.jknack.extend.Extend.java
/** * Converts an object to a {@link Map}. The resulting map is the union of the bean properties and * all the extra properties.//from w w w . ja v a2 s . co m * * @param source The object to extend. Required. * @param properties The extra property set. Required. * @param <T> The source type. * @return A new immutable map. */ @SuppressWarnings("unchecked") public static <T> Map<String, Object> map(final T source, final Map<String, Object> properties) { notNull(source, "The source object is required."); notNull(properties, "The properties is required"); final BeanMap beanMap = BeanMap.create(source); return new AbstractMap<String, Object>() { @Override public Object put(final String key, final Object value) { return null; } @Override public Object get(final Object key) { Object value = properties.get(key); return value == null ? beanMap.get(key) : value; } @Override public Set<Entry<String, Object>> entrySet() { LinkedHashMap<String, Object> mergedProperties = new LinkedHashMap<String, Object>(beanMap); mergedProperties.putAll(properties); return mergedProperties.entrySet(); } }; }
From source file:com.cburch.logisim.gui.main.SelectionAttributes.java
private static boolean isSame(LinkedHashMap<Attribute<Object>, Object> attrMap, Attribute<?>[] oldAttrs, Object[] oldValues) {/*w w w . jav a 2s. co m*/ if (oldAttrs.length != attrMap.size()) { return false; } else { int j = -1; for (Map.Entry<Attribute<Object>, Object> entry : attrMap.entrySet()) { j++; Attribute<Object> a = entry.getKey(); if (!oldAttrs[j].equals(a) || j >= oldValues.length) return false; Object ov = oldValues[j]; Object nv = entry.getValue(); if (ov == null ? nv != null : !ov.equals(nv)) return false; } return true; } }
From source file:org.broadinstitute.gatk.engine.recalibration.BQSRGatherer.java
/** * Gathers the input recalibration reports into a single report. * * @param inputs Input recalibration GATK reports * @return gathered recalibration GATK report */// w ww. ja v a 2s.c o m public static GATKReport gatherReport(final List<File> inputs) { final SortedSet<String> allReadGroups = new TreeSet<String>(); final LinkedHashMap<File, Set<String>> inputReadGroups = new LinkedHashMap<File, Set<String>>(); // Get the read groups from each input report for (final File input : inputs) { final Set<String> readGroups = RecalibrationReport.getReadGroups(input); inputReadGroups.put(input, readGroups); allReadGroups.addAll(readGroups); } // Log the read groups that are missing from specific inputs for (Map.Entry<File, Set<String>> entry : inputReadGroups.entrySet()) { final File input = entry.getKey(); final Set<String> readGroups = entry.getValue(); if (allReadGroups.size() != readGroups.size()) { // Since this is not completely unexpected, more than debug, but less than a proper warning. logger.info(MISSING_READ_GROUPS + ": " + input.getAbsolutePath()); for (final Object readGroup : CollectionUtils.subtract(allReadGroups, readGroups)) { logger.info(" " + readGroup); } } } RecalibrationReport generalReport = null; for (File input : inputs) { final RecalibrationReport inputReport = new RecalibrationReport(input, allReadGroups); if (inputReport.isEmpty()) { continue; } if (generalReport == null) generalReport = inputReport; else generalReport.combine(inputReport); } if (generalReport == null) throw new ReviewedGATKException(EMPTY_INPUT_LIST); generalReport.calculateQuantizedQualities(); return generalReport.createGATKReport(); }
From source file:com.streamsets.pipeline.stage.lib.hive.HiveMetastoreUtil.java
/** * Opposite operation of extractInnerMapFromTheList. * It takes LinkedHashMap and generate a Field that contains the list. * This is to send metadata record to HMS target. * This function is called to for partition type list and partition value list. *///from w w w . ja v a 2 s .co m private static <T> Field generateInnerFieldFromTheList(LinkedHashMap<String, T> original, String innerPairFirstFieldName, String innerPairSecondFieldName, boolean isSecondFieldHiveType) throws StageException { List<Field> columnList = new LinkedList<>(); for (Map.Entry<String, T> pair : original.entrySet()) { Map<String, Field> entry = new LinkedHashMap<>(); entry.put(innerPairFirstFieldName, Field.create(pair.getKey())); if (isSecondFieldHiveType) { entry.put(innerPairSecondFieldName, Field .create(HiveType.getFieldTypeForHiveType((HiveType) pair.getValue()), pair.getValue())); } else { entry.put(innerPairSecondFieldName, Field.create(pair.getValue().toString())); //stored value is "INT". need to fix this } columnList.add(Field.create(entry)); } return !columnList.isEmpty() ? Field.create(columnList) : null; }
From source file:org.deegree.tools.feature.gml.ApplicationSchemaTool.java
private static String shortenName(String s, LinkedHashMap<String, String> rules) { String shortened = s;/*w w w . ja v a 2 s . c o m*/ for (Entry<?, ?> rule : rules.entrySet()) { String from = (String) rule.getKey(); String to = (String) rule.getValue(); shortened = shortened.replaceAll(from, to); } return shortened; }
From source file:org.gumtree.vis.mask.ChartMaskingUtilities.java
public static void drawShapes(Graphics2D g2, Rectangle2D imageArea, LinkedHashMap<Shape, Color> shapeList, JFreeChart chart) {/*from ww w .jav a2 s .c om*/ if (shapeList == null) { return; } for (Entry<Shape, Color> shapeEntry : shapeList.entrySet()) { Shape shape = shapeEntry.getKey(); Color color = shapeEntry.getValue(); drawShape(g2, imageArea, shape, color, chart); } }
From source file:gov.llnl.lc.smt.command.fabric.SmtFabric.java
public static String getErrorNodeSummary(OSM_FabricDeltaAnalyzer fda, LinkedHashMap<String, IB_Link> links, boolean includeStaticErrors) { OSM_Fabric fabric = fda.getDelta().getFabric2(); StringBuffer buff = new StringBuffer(); LinkedHashMap<String, OSM_Node> allNodes = fabric.getOSM_Nodes(); OSM_Node n = null;// w w w.j a v a 2 s. co m for (Map.Entry<String, OSM_Node> entry : allNodes.entrySet()) { n = entry.getValue(); // are there any dynamic errors on this node? if (SmtNode.getNumPortErrors(fda, n, includeStaticErrors) > 0) { buff.append(SmtNode.getPortsHeader(fabric, n.getNodeGuid())); buff.append(" " + SmtNode.getErrorPortSummary(fda, n, links, includeStaticErrors) + SmtConstants.NEW_LINE); } } return buff.toString() + SmtConstants.NEW_LINE; }
From source file:eulermind.importer.LineNode.java
private static void reduceTextLineSiblingsToSubTree(LineNode root) { if (root.getChildCount() == 0) { return;/*www .j ava 2 s. c o m*/ } if ((root.getChildAt(0)).isBlank()) { for (int i = 0; i < root.getChildCount(); i++) { reduceTextLineSiblingsToSubTree(root.getChildAt(i)); } return; } Object[] indentStatistics = getIndentStatistics(root); int minIndent = (Integer) indentStatistics[0]; int maxIndent = (Integer) indentStatistics[1]; LinkedHashMap<Integer, Integer> indentCountMap = (LinkedHashMap<Integer, Integer>) indentStatistics[2]; Map.Entry<Integer, Integer> indentCounts[] = indentCountMap.entrySet().toArray(new Map.Entry[0]); //? if (indentCounts[indentCounts.length - 1].getKey() == minIndent) { brokenSentencesToTree(root); } else { nestingListToTree(root, maxIndent, minIndent); } }
From source file:com.qwarz.graph.process.GraphProcess.java
public static void createUpdateNodes(GraphBase base, LinkedHashMap<String, GraphNode> nodes, Boolean upsert) throws IOException, URISyntaxException, ServerException { if (nodes == null || nodes.isEmpty()) return;/*from w w w . jav a2 s . c o m*/ GraphProcessInterface graphImpl = getImplementation(base.data); if (upsert != null && upsert) { // If the nodes already exists, we merge them Map<String, GraphNode> dbNodes = graphImpl.getNodes(base, nodes.keySet()); if (dbNodes != null) { for (Map.Entry<String, GraphNode> entry : nodes.entrySet()) { GraphNode dbNode = dbNodes.get(entry.getKey().intern()); if (dbNode != null) entry.getValue().add(dbNode); } } } graphImpl.createUpdateNodes(base, nodes); }
From source file:org.gumtree.vis.mask.ChartMaskingUtilities.java
public static void drawMasks(Graphics2D g2, Rectangle2D imageArea, LinkedHashMap<AbstractMask, Color> maskList, AbstractMask selectedMask, JFreeChart chart, double fontSizeRate) { if (maskList == null) { return;//from ww w .j ava 2 s . c o m } for (Entry<AbstractMask, Color> maskEntry : maskList.entrySet()) { AbstractMask mask = maskEntry.getKey(); if (mask instanceof Abstract2DMask) { Color fillColor = mask.isInclusive() ? Hist2DPanel.MASK_INCLUSIVE_COLOR : Hist2DPanel.MASK_EXCLUSIVE_COLOR; drawMaskRectangle(g2, imageArea, (Abstract2DMask) mask, (Abstract2DMask) selectedMask, chart, fontSizeRate, fillColor); } else if (mask instanceof RangeMask) { // Color fillColor = maskEntry.getValue(); Color fillColor = mask.isInclusive() ? Plot1DPanel.MASK_INCLUSIVE_COLOR : Plot1DPanel.MASK_EXCLUSIVE_COLOR; drawDomainMask(g2, imageArea, (RangeMask) mask, (RangeMask) selectedMask, chart, fontSizeRate, fillColor); } } }