use of me.retrodaredevil.solarthing.type.cache.packets.DefaultIdentificationCacheDataPacket in project solarthing by wildmountainfarms.
the class DefaultIdentificationCacheCreator method createFrom.
@Override
public IdentificationCacheDataPacket<T> createFrom(String sourceId, List<InstancePacketGroup> packetGroups, Instant periodStart, Duration periodDuration) {
Class<U> acceptedType = identificationCacheNodeCreator.getAcceptedType();
Map<String, Map<IdentifierFragment, List<TimestampedPacket<U>>>> mappedPackets = convertPackets(packetGroups, acceptedType);
Map<IdentifierFragment, List<TimestampedPacket<U>>> identifierFragmentMap = mappedPackets.getOrDefault(sourceId, Collections.emptyMap());
List<IdentificationCacheNode<T>> nodes = new ArrayList<>(identifierFragmentMap.size());
for (Map.Entry<IdentifierFragment, List<TimestampedPacket<U>>> entry : identifierFragmentMap.entrySet()) {
IdentifierFragment identifierFragment = entry.getKey();
List<TimestampedPacket<U>> packets = entry.getValue();
IdentificationCacheNode<T> node = identificationCacheNodeCreator.create(identifierFragment, packets, periodStart, periodDuration);
nodes.add(node);
}
return new DefaultIdentificationCacheDataPacket<>(periodStart.toEpochMilli(), periodDuration.toMillis(), sourceId, identificationCacheNodeCreator.getCacheName(), nodes);
}
Aggregations