public String getNextOpId(OpCode opCode, String userDefinedId) {
    if (StringUtils.isNotBlank(userDefinedId) && !ID_PATTERN.matcher(userDefinedId).matches()) {
      throw new SamzaException("Operator ID must not contain spaces or special characters: " + userDefinedId);
    }

    ApplicationConfig applicationConfig = new ApplicationConfig(getConfig());
    String nextOpId = String.format("%s-%s-%s-%s",
        applicationConfig.getAppName(),
        applicationConfig.getAppId(),
        opCode.name().toLowerCase(),
        StringUtils.isNotBlank(userDefinedId) ? userDefinedId.trim() : String.valueOf(nextOpNum));
    if (!operatorIds.add(nextOpId)) {
      throw new SamzaException(
          String.format("Found duplicate operator ID %s in the graph. Operator IDs must be unique.", nextOpId));
    }
    nextOpNum++;
    return nextOpId;
  }
Gets the unique ID for the next operator in the graph. The ID is of the following format:
jobName-jobId-opCode-(userDefinedId|nextOpNum);

@param opCode the {@link OpCode} of the next operator
@param userDefinedId the optional user-provided name of the next operator or null
@return the unique ID for the next operator in the graph
samza-core/src/main/java/org/apache/samza/application/descriptors/StreamApplicationDescriptorImpl.java