/** * Getter for set of columns by sub-type. * * @param columnClass The class of columns to to search * @param <T> sub-type of Column to return * * @return Set of Columns */ default <T extends Column> LinkedHashSet<T> getColumns(Class<T> columnClass) { return Utils.getSubsetByType(getColumns(), columnClass); }
/** * Get the names of the metric columns from the Schema. * * @param schema Schema to extract the names from * * @return the names of the metric columns */ private Set<String> getMetricColumnNames(Schema schema) { return schema.getColumns(MetricColumn.class).stream().map(Column::getName).collect(Collectors.toSet()); } }
/** * Getter for set of dimensions. * * @return Set of Dimension */ default LinkedHashSet<Dimension> getDimensions() { return getSchema().getColumns(DimensionColumn.class).stream() .map(DimensionColumn::getDimension) .collect(Collectors.toCollection(LinkedHashSet::new)); } }
/** * Given a column type and name, return the column of the expected type. * * @param name The name on the column * @param columnClass The class of the column being retrieved * @param <T> The type of the subclass of the column being retrieved * * @return The an optional containing the column of the name and type specified, if any */ default <T extends Column> Optional<T> getColumn(String name, Class<T> columnClass) { return getColumns(columnClass).stream() .filter(column -> column.getName().equals(name)) .findFirst(); } }
.map(schema -> schema.getColumns()) .flatMap(Set::stream) .map(Column::getName)