class BasicTablesTransformer {

  public static MetadataHolder all(List<TableMetadataUnit> units) {
    List<BaseTableMetadata> tables = new ArrayList<>();
    List<SegmentMetadata> segments = new ArrayList<>();
    List<FileMetadata> files = new ArrayList<>();
    List<RowGroupMetadata> rowGroups = new ArrayList<>();
    List<PartitionMetadata> partitions = new ArrayList<>();

    for (TableMetadataUnit unit : units) {
      MetadataType metadataType = MetadataType.fromValue(unit.metadataType());
      if (metadataType == null) {
        continue;
      }
      switch (metadataType) {
        case TABLE:
          tables.add(BaseTableMetadata.builder().metadataUnit(unit).build());
          break;
        case SEGMENT:
          segments.add(SegmentMetadata.builder().metadataUnit(unit).build());
          break;
        case FILE:
          files.add(FileMetadata.builder().metadataUnit(unit).build());
          break;
        case ROW_GROUP:
          rowGroups.add(RowGroupMetadata.builder().metadataUnit(unit).build());
          break;
        case PARTITION:
          partitions.add(PartitionMetadata.builder().metadataUnit(unit).build());
          break;
        default:
          // Ignore unsupported type
          break;
      }
    }
    return new MetadataHolder(tables, segments, files, rowGroups, partitions);
  }

}