/** * Extracts the list of logical table names from the url table path segment and generates a set of logical table * objects based on it. * * @param tableName logical table corresponding to the table name specified in the URL * @param tableDictionary Logical table dictionary contains the map of valid table names and table objects. * * @return Set of logical table objects. * @throws BadApiRequestException if an invalid table is requested or the logical table dictionary is empty. */ protected LinkedHashSet<LogicalTable> generateTables(String tableName, LogicalTableDictionary tableDictionary) throws BadApiRequestException { LinkedHashSet<LogicalTable> generated = tableDictionary.values().stream() .filter(logicalTable -> tableName == null || tableName.equals(logicalTable.getName())) .collect(Collectors.toCollection(LinkedHashSet::new)); // Check if logical tables exist with the requested logical table name if (generated.isEmpty()) { String msg; if (tableDictionary.isEmpty()) { msg = EMPTY_DICTIONARY.logFormat("Logical Table"); } else { msg = TABLE_UNDEFINED.logFormat(tableName); } LOG.error(msg); throw new BadApiRequestException(msg); } LOG.trace("Generated set of logical tables: {}", generated); return generated; }