List of usage examples for org.apache.commons.collections4.map LinkedMap LinkedMap
public LinkedMap(final Map<? extends K, ? extends V> map)
From source file:com.haulmont.cuba.gui.data.GroupInfo.java
public GroupInfo(LinkedMap groupingValues) { this.groupingValues = new LinkedMap(groupingValues); //noinspection unchecked groupProperty = (P) groupingValues.get(groupingValues.size() - 1); }
From source file:com.yahoo.elide.core.ResourceLineage.java
/** * Extends a lineage with a new resource. * @param sharedLineage the shared lineage * @param next the next//from www . ja v a 2 s. com */ public ResourceLineage(ResourceLineage sharedLineage, PersistentResource next) { resourceMap = new LinkedMap<>(sharedLineage.resourceMap); addRecord(next); }
From source file:com.yahoo.elide.core.ResourceLineage.java
/** * Extends a lineage with a new resource that has an alias. An alias is useful if * there are two objects in the lineage with the same type or class. The resource * lineage does not allow two resources to have the same name. As long as one of the two * resources can be given an alias (by annotation), then two objects with the same type/class * can exist in the lineage. This case is likely to be uncommon. * @param sharedLineage the shared lineage * @param next the next/*from ww w .ja v a 2s . c om*/ * @param nextAlias the next alias */ public ResourceLineage(ResourceLineage sharedLineage, PersistentResource next, String nextAlias) { resourceMap = new LinkedMap<>(sharedLineage.resourceMap); addRecord(next, nextAlias); }
From source file:net.sf.jasperreports.crosstabs.design.JRDesignCrosstab.java
@Override public Object clone() { JRDesignCrosstab clone = (JRDesignCrosstab) super.clone(); if (parametersList != null) { clone.parametersList = new ArrayList<JRCrosstabParameter>(parametersList.size()); clone.parametersMap = new HashMap<String, JRCrosstabParameter>(parametersList.size()); for (int i = 0; i < parametersList.size(); i++) { JRCrosstabParameter parameter = JRCloneUtils.nullSafeClone(parametersList.get(i)); clone.parametersList.add(parameter); clone.parametersMap.put(parameter.getName(), parameter); }//from www . j a v a 2s . c o m } clone.parametersMapExpression = JRCloneUtils.nullSafeClone(parametersMapExpression); clone.dataset = JRCloneUtils.nullSafeClone(dataset); clone.lineBox = lineBox.clone(clone); // keep group and measure cloned variables to reuse the clone instances // in the variables list Map<JRVariable, JRVariable> clonedVariables = new HashMap<JRVariable, JRVariable>(); if (rowGroups != null) { clone.rowGroups = new ArrayList<JRCrosstabRowGroup>(rowGroups.size()); clone.rowGroupsMap = new HashMap<String, Integer>(rowGroups.size()); for (int i = 0; i < rowGroups.size(); i++) { JRDesignCrosstabRowGroup group = (JRDesignCrosstabRowGroup) rowGroups.get(i); JRDesignCrosstabRowGroup groupClone = (JRDesignCrosstabRowGroup) group.clone(clone); clone.rowGroups.add(groupClone); clone.rowGroupsMap.put(groupClone.getName(), i); adjustCrosstabReference(clone, (JRDesignCellContents) groupClone.getTotalHeader()); adjustCrosstabReference(clone, (JRDesignCellContents) groupClone.getHeader()); if (group.designVariable != null) { clonedVariables.put(group.designVariable, groupClone.designVariable); } } } if (columnGroups != null) { clone.columnGroups = new ArrayList<JRCrosstabColumnGroup>(columnGroups.size()); clone.columnGroupsMap = new HashMap<String, Integer>(columnGroups.size()); for (int i = 0; i < columnGroups.size(); i++) { JRDesignCrosstabColumnGroup group = (JRDesignCrosstabColumnGroup) columnGroups.get(i); JRDesignCrosstabColumnGroup groupClone = (JRDesignCrosstabColumnGroup) group.clone(clone); clone.columnGroups.add(groupClone); clone.columnGroupsMap.put(groupClone.getName(), i); adjustCrosstabReference(clone, (JRDesignCellContents) groupClone.getCrosstabHeader()); adjustCrosstabReference(clone, (JRDesignCellContents) groupClone.getTotalHeader()); adjustCrosstabReference(clone, (JRDesignCellContents) groupClone.getHeader()); if (group.designVariable != null) { clonedVariables.put(group.designVariable, groupClone.designVariable); } } } if (measures != null) { clone.measures = new ArrayList<JRCrosstabMeasure>(measures.size()); clone.measuresMap = new HashMap<String, Integer>(measures.size()); for (int i = 0; i < measures.size(); i++) { JRDesignCrosstabMeasure measure = (JRDesignCrosstabMeasure) measures.get(i); JRDesignCrosstabMeasure clonedMeasure = JRCloneUtils.nullSafeClone(measure); clone.measures.add(clonedMeasure); clone.measuresMap.put(clonedMeasure.getName(), i); if (clonedMeasure.designVariable != null) { clonedVariables.put(measure.designVariable, clonedMeasure.designVariable); } } } if (variablesList != null) { clone.variablesList = new LinkedMap<String, JRVariable>(variablesList.size()); for (Iterator<?> it = variablesList.values().iterator(); it.hasNext();) { JRVariable variable = (JRVariable) it.next(); // check whether the variable was already cloned as part of a group or measure JRVariable variableClone = clonedVariables.get(variable); if (variableClone == null) { variableClone = JRCloneUtils.nullSafeClone(variable); } clone.variablesList.put(variableClone.getName(), variableClone); } } if (cellsList != null) { clone.cellsList = new ArrayList<JRCrosstabCell>(cellsList.size()); clone.cellsMap = new HashMap<Pair<String, String>, JRCrosstabCell>(cellsList.size()); for (int i = 0; i < cellsList.size(); i++) { JRCrosstabCell cell = JRCloneUtils.nullSafeClone(cellsList.get(i)); adjustCrosstabReference(clone, (JRDesignCellContents) cell.getContents()); clone.cellsList.add(cell); clone.cellsMap.put(new Pair<String, String>(cell.getRowTotalGroup(), cell.getColumnTotalGroup()), cell); } } // clone not preprocessed clone.crossCells = null; clone.whenNoDataCell = JRCloneUtils.nullSafeClone(whenNoDataCell); adjustCrosstabReference(clone, clone.whenNoDataCell); clone.titleCell = JRCloneUtils.nullSafeClone(titleCell); if (clone.titleCell != null) { adjustCrosstabReference(clone, clone.titleCell.getDesignCellContents()); } clone.headerCell = JRCloneUtils.nullSafeClone(headerCell); adjustCrosstabReference(clone, clone.headerCell); return clone; }
From source file:net.sf.jasperreports.crosstabs.design.JRDesignCrosstab.java
@SuppressWarnings("deprecation") private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject();//from w w w. jav a 2 s. com if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_7_2) { runDirectionValue = RunDirectionEnum.getByValue(runDirection); } if (lineBox == null) { lineBox = new JRBaseLineBox(this); } // this will work as long as SequencedHashMap is part of commons collections // we could also look at PSEUDO_SERIAL_VERSION_UID if (variablesList.getClass().getName().equals("org.apache.commons.collections.SequencedHashMap")) { // converting to the new type variablesList = new LinkedMap<String, JRVariable>(variablesList); } }
From source file:org.apache.wicket.MarkupContainer.java
/** * Puts the {@code child} component into the list of children of this markup container. If a * component existed with the same {@code child.getId()} it is replaced and the old component is * returned./*from w w w . j ava2 s . c om*/ * * When a component is replaced, the internal structure of the children is not modified, so we * don't have to update the internal {@link #modCounter} in those circumstances. When a * component is added, we do have to increase the {@link #modCounter} to notify iterators of * this change. * * @param child * The child * @return Any component that was replaced */ private Component children_put(final Component child) { if (children == null) { children = child; // it is an addtion, so we need to notify the iterators of this change. modCounter++; return null; } if (children instanceof Component) { /* first see if the child replaces the existing child */ Component oldChild = children(); if (oldChild.getId().equals(child.getId())) { children = child; return oldChild; } else { /* * the put doesn't replace the existing child, so we need to increase the children * storage to a list and add the existing and new child to it */ Component originalChild = children(); List<Component> newChildren = new ArrayList<>(INITIAL_CHILD_LIST_CAPACITY); newChildren.add(originalChild); newChildren.add(child); children = newChildren; // it is an addtion, so we need to notify the iterators of this change. modCounter++; return null; } } if (children instanceof List) { List<Component> childrenList = children(); // first see if the child replaces an existing child for (int i = 0; i < childrenList.size(); i++) { Component curChild = childrenList.get(i); if (curChild.getId().equals(child.getId())) { return childrenList.set(i, child); } } // it is an addtion, so we need to notify the iterators of this change. modCounter++; /* * If it still fits in the allotted number of items of a List, just add it, otherwise * change the internal data structure to a Map for speedier lookups. */ if (childrenList.size() < MAPIFY_THRESHOLD) { childrenList.add(child); } else { Map<String, Component> newChildren = new LinkedMap<>(MAPIFY_THRESHOLD * 2); for (Component curChild : childrenList) { newChildren.put(curChild.getId(), curChild); } newChildren.put(child.getId(), child); children = newChildren; } return null; } Map<String, Component> childrenMap = children(); Component oldChild = childrenMap.put(child.getId(), child); if (oldChild == null) { // it is an addtion, so we need to notify the iterators of this change. modCounter++; } return oldChild; }
From source file:phex.http.HTTPHeaderGroup.java
public HTTPHeaderGroup(HTTPHeaderGroup headers) { headerFields = new LinkedMap(headers.headerFields); lenient = headers.lenient; }
From source file:phex.http.HTTPHeaderGroup.java
public HTTPHeaderGroup(int size, boolean lenient) { this.lenient = lenient; headerFields = new LinkedMap(size); }