private static List generateTableSpec()

in spanner-data-validator-java/src/main/java/com/google/migration/JDBCToSpannerDVTWithHash.java [776:809]


  private static List<TableSpec> generateTableSpec(DVTOptionsCore options) {
    String tableSpecJson = options.getTableSpecJson();
    String sessionFileJson = options.getSessionFileJson();
    List<TableSpec> tableSpecListFromTableSpecJson = null;
    List<TableSpec> tableSpecListFromSessionFileJson = null;
    if (!Helpers.isNullOrEmpty(sessionFileJson)) {
      tableSpecListFromSessionFileJson = TableSpecList.getFromSessionFile(options);
    }
    if(!Helpers.isNullOrEmpty(tableSpecJson)) {
      tableSpecListFromTableSpecJson = TableSpecList.getFromJsonFile(options.getProjectId(), tableSpecJson);
    }
    List<TableSpec> tableSpecs = new ArrayList<>();
    if (tableSpecListFromSessionFileJson != null && tableSpecListFromTableSpecJson != null) {
      LOG.warn("Session file and tableSpec have both been specified! TableSpec will take "
          + "precedence over session file for the tables for which it is defined!!");
      List<String> tableNamesFromTableSpecJson = tableSpecListFromTableSpecJson.stream()
          .map(TableSpec::getTableName)
          .collect(Collectors.toList());

      List<TableSpec> filteredTableSpecs = tableSpecListFromSessionFileJson.stream()
          .filter(tableSpec -> !tableNamesFromTableSpecJson.contains(tableSpec.getTableName()))
          .collect(Collectors.toList());

      tableSpecs.addAll(filteredTableSpecs);
      tableSpecs.addAll(tableSpecListFromTableSpecJson);
    } else if (!Helpers.isNullOrEmpty(tableSpecJson)) {
      tableSpecs = tableSpecListFromTableSpecJson;
    } else if (!Helpers.isNullOrEmpty(sessionFileJson)) {
      tableSpecs = tableSpecListFromSessionFileJson;
    } else {
      tableSpecs = getTableSpecs();
    }
    return tableSpecs;
  }