public void processElement()

in beam-collector/src/main/java/com/google/collector/clustering/ExtractClusterKey.java [34:58]


  public void processElement(ProcessContext ctx) {
    SecurityReport securityReport = ctx.element();
    if (securityReport == null) {
      return;
    }

    String key = null;
    switch (securityReport.getReportExtensionCase()) {
      case CSP_REPORT:
        key = buildClusterKeyForCsp(securityReport.getCspReport());
        break;
      case DEPRECATION_REPORT:
        DeprecationReport deprecationReport = securityReport.getDeprecationReport();
        String id = deprecationReport.getId();
        key = id.isBlank() || id.isEmpty() ? "blankDeprecationId" : id;
        break;
    }

    if (key == null) {
      // TODO: a new report type that we don't support has been found - report it
      return;
    }

    ctx.output(KV.of(key, securityReport));
  }