use of me.retrodaredevil.solarthing.rest.graphql.packets.nodes.PacketNode in project solarthing by wildmountainfarms.
the class PacketUtil method convertPackets.
/**
* @return A mutable list of packets of a certain type
*/
@SuppressWarnings("unchecked")
public static <T> List<PacketNode<T>> convertPackets(List<? extends FragmentedPacketGroup> packetGroups, Class<T> acceptClass, PacketFilter filter) {
List<PacketNode<T>> r = new ArrayList<>();
for (FragmentedPacketGroup packetGroup : packetGroups) {
for (Packet packet : packetGroup.getPackets()) {
if (!acceptClass.isInstance(packet)) {
continue;
}
int fragmentId = packetGroup.getFragmentId(packet);
String sourceId = packetGroup.getSourceId(packet);
long dateMillis = packetGroup.getDateMillisOrKnown(packet);
PacketNode<T> packetNode = new PacketNode<>((T) packet, dateMillis, sourceId, fragmentId);
if (filter.keep(packetNode)) {
r.add(packetNode);
}
}
}
return r;
}
Aggregations