protected void doGroup() { roots = new LinkedList<>(); parents = new LinkedHashMap<>(); children = new HashMap<>(); groupItems = new HashMap<>(); itemGroups = new HashMap<>(); final Collection<K> itemIds = datasource.getItemIds(); for (final K id : itemIds) { final T item = datasource.getItem(id); GroupInfo<MetaPropertyPath> groupInfo = groupItems(0, null, roots, item, new LinkedMap()); if (groupInfo == null) { throw new IllegalStateException("Item group cannot be NULL"); } List<K> itemsIds = groupItems.computeIfAbsent(groupInfo, k -> new ArrayList<>()); itemsIds.add(id); } }
protected GroupInfo<MetaPropertyPath> groupItems(int propertyIndex, GroupInfo parent, List<GroupInfo> children, T item, final LinkedMap groupValues) { final MetaPropertyPath property = (MetaPropertyPath) groupProperties[propertyIndex++]; Object itemValue = getValueByProperty(item, property); groupValues.put(property, itemValue); GroupInfo<MetaPropertyPath> groupInfo = new GroupInfo<>(groupValues); itemGroups.put(item.getId(), groupInfo); if (!parents.containsKey(groupInfo)) { parents.put(groupInfo, parent); } if (!children.contains(groupInfo)) { children.add(groupInfo); } List<GroupInfo> groupChildren = this.children.computeIfAbsent(groupInfo, k -> new ArrayList<>()); if (propertyIndex < groupProperties.length) { groupInfo = groupItems(propertyIndex, groupInfo, groupChildren, item, groupValues); } return groupInfo; }
void addAudit( Audit audit ) throws KettleValueException { if ( auditSummaries == null ) { auditSummaries = new LinkedMap<Long, ZendeskTicketAuditHistory>(); } if ( auditSummaries.size() <= 0 ) { auditSummaries.put( audit.getId(), new ZendeskTicketAuditHistory( audit ) ); } else { try { ZendeskTicketAuditHistory newAudit = auditSummaries.get( auditSummaries.lastKey() ).createNextAudit( audit, auditSummaries ); auditSummaries.put( audit.getId(), newAudit ); } catch ( CloneNotSupportedException e ) { e.printStackTrace(); } } }
/** * Transforms a map. * <p> * The transformer itself may throw an exception if necessary. * * @param map the map to transform * @return the transformed object */ @SuppressWarnings("unchecked") protected Map<K, V> transformMap(final Map<? extends J, ? extends U> map) { if (map.isEmpty()) { return (Map<K, V>) map; } final Map<K, V> result = new LinkedMap<K, V>(map.size()); for (final Map.Entry<? extends J, ? extends U> entry : map.entrySet()) { result.put(transformKey(entry.getKey()), transformValue(entry.getValue())); } return result; }
@Override public void addItemFirst(T item) { checkNotNullArgument(item, "item is null"); internalAddItem(item, () -> { LinkedMap tmpMap = (LinkedMap) data.clone(); data.clear(); data.put(item.getId(), item); data.putAll(tmpMap); }); }
@Override public void includeItemFirst(T item) { checkNotNullArgument(item, "item is null"); internalIncludeItem(item, () -> { LinkedMap tmpMap = (LinkedMap) data.clone(); data.clear(); data.put(item.getId(), item); data.putAll(tmpMap); }); }
public MutableRetentionConfiguration() { // function map and strategy map need to preserve order. this.functionMap = new LinkedMap<>(); this.readLevelsMap = new LinkedMap<>(); this.writeLevelMap = new LinkedMap<>(); this.nameRetentionMap = new LinkedMap<>(); // this.strategies = new HashMap<>(); this.levels = new HashMap<>(); }
public ReadOnlyLinkedMapValuesView(LinkedMap parent) { this.parent = parent; }
public static Iterator createValuesIterator(LinkedMap linkedMap) { return new ReadOnlyValuesIterator(linkedMap); }
public GroupInfo(LinkedMap groupingValues) { this.groupingValues = new LinkedMap(groupingValues); //noinspection unchecked groupProperty = (P) groupingValues.get(groupingValues.size() - 1); }
/** * Empty lineage for objects rooted in the URL. */ public ResourceLineage() { resourceMap = new LinkedMap<>(); }
BucketSizeInfo(int sizeIndex) { bucketList = new LinkedMap(); freeBuckets = new LinkedMap(); completelyFreeBuckets = new LinkedMap(); this.sizeIndex = sizeIndex; }
/** * Extends a lineage with a new resource. * @param sharedLineage the shared lineage * @param next the next */ public ResourceLineage(ResourceLineage sharedLineage, PersistentResource next) { resourceMap = new LinkedMap<>(sharedLineage.resourceMap); addRecord(next); }
/** * 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 * @param nextAlias the next alias */ public ResourceLineage(ResourceLineage sharedLineage, PersistentResource next, String nextAlias) { resourceMap = new LinkedMap<>(sharedLineage.resourceMap); addRecord(next, nextAlias); }