@Override
 public void filterInChannel(PacketList inChannel, PacketList source) {
   if (inChannel == inClaimsCeded) {
     if (source.size() > 0) {
       inClaimsCeded.addAll(
           ClaimFilterUtilities.filterClaimsByOriginalOrigin(inClaimsGross, source));
     }
   } else {
     super.filterInChannel(inChannel, source);
   }
 }
  public void doCalculation() {
    if (inUnderwritingInfoGross.isEmpty() && !inUnderwritingInfoCeded.isEmpty()) {
      throw new IllegalStateException("UnderwritingInfoMerger.onlyCededUnderwritingInfo");
    }

    /* The map contains the gross UwInfo as keys and the ceded as values */
    if (anyOutChannelWired()) {
      // Using a LinkedHashMap ensures that all outUwInfo* lists will be sorted according to the
      // inUwInfoGross list.
      Map<UnderwritingInfo, CededUnderwritingInfo> grossMergedCededPairs =
          new LinkedHashMap<UnderwritingInfo, CededUnderwritingInfo>(
              inUnderwritingInfoGross.size());
      for (UnderwritingInfo grossUnderwritingInfo : inUnderwritingInfoGross) {
        if (grossMergedCededPairs.containsKey(
            grossUnderwritingInfo.getOriginalUnderwritingInfo())) {
          throw new IllegalArgumentException("UnderwritingInfoMerger.doubleInformation");
        }
        grossMergedCededPairs.put(grossUnderwritingInfo.getOriginalUnderwritingInfo(), null);
        outUnderwritingInfoGross.add(grossUnderwritingInfo);
      }
      if (isSenderWired(outUnderwritingInfoCeded) || isSenderWired(outUnderwritingInfoNet)) {
        for (CededUnderwritingInfo cededUnderwritingInfo : inUnderwritingInfoCeded) {
          if (grossMergedCededPairs.containsKey(
              cededUnderwritingInfo.getOriginalUnderwritingInfo())) {
            CededUnderwritingInfo aggregateCededUnderwritingInfo =
                grossMergedCededPairs.get(cededUnderwritingInfo.getOriginalUnderwritingInfo());
            if (aggregateCededUnderwritingInfo == null) {
              grossMergedCededPairs.put(
                  cededUnderwritingInfo.getOriginalUnderwritingInfo(),
                  CededUnderwritingInfoPacketFactory.copy(cededUnderwritingInfo));
            } else {
              aggregateCededUnderwritingInfo.plus(cededUnderwritingInfo);
              aggregateCededUnderwritingInfo.setNumberOfPolicies(
                  cededUnderwritingInfo.getNumberOfPolicies());
              aggregateCededUnderwritingInfo.origin = this;
            }
          }
        }

        for (Map.Entry<UnderwritingInfo, CededUnderwritingInfo> entry :
            grossMergedCededPairs.entrySet()) {
          UnderwritingInfo grossUnderwritingInfo = entry.getKey();
          UnderwritingInfo netUnderwritingInfo =
              UnderwritingInfoPacketFactory.copy(grossUnderwritingInfo);
          netUnderwritingInfo.origin = this;
          netUnderwritingInfo.setOriginalUnderwritingInfo(grossUnderwritingInfo);

          CededUnderwritingInfo cededUnderwritingInfo = entry.getValue();
          if (cededUnderwritingInfo == null) {
            cededUnderwritingInfo = CededUnderwritingInfoPacketFactory.copy(netUnderwritingInfo);
            CededUnderwritingInfoUtilities.setZero(cededUnderwritingInfo);
          } else {
            netUnderwritingInfo =
                UnderwritingInfoUtilities.calculateNet(
                    grossUnderwritingInfo, cededUnderwritingInfo);
          }
          outUnderwritingInfoCeded.add(cededUnderwritingInfo);
          outUnderwritingInfoNet.add(netUnderwritingInfo);
        }
      }
      if (isSenderWired(outUnderwritingInfoCededInGrossPackets)
          && outUnderwritingInfoCeded.size() > 0) {
        for (CededUnderwritingInfo cededUnderwritingInfo : outUnderwritingInfoCeded) {
          outUnderwritingInfoCededInGrossPackets.add(
              UnderwritingInfoPacketFactory.copy(cededUnderwritingInfo));
        }
      }
    }
  }