All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.yahoo.bard.webservice.table.Schema Maven / Gradle / Ivy

Go to download

Fili web service library provides core capabilities for RESTful aggregation navigation, query planning and metadata

There is a newer version: 1.1.13
Show newest version
// Copyright 2017 Yahoo Inc.
// Licensed under the terms of the Apache license. Please see LICENSE.md file distributed with this work for terms.
package com.yahoo.bard.webservice.table;

import com.yahoo.bard.webservice.data.time.Granularity;
import com.yahoo.bard.webservice.util.Utils;

import java.util.LinkedHashSet;
import java.util.Optional;
import java.util.Set;

/**
 * An interface describing a table or table-like entity composed of sets of columns.
 */
public interface Schema {

    /**
     * Get all the columns underlying this Schema.
     *
     * @return The columns of this schema
     */
    Set getColumns();

    /**
     * Get the time granularity for this Schema.
     *
     * @return The time granularity of this schema
     */
    Granularity getGranularity();

    /**
     * Getter for set of columns by sub-type.
     *
     * @param columnClass  The class of columns to to search
     * @param  sub-type of Column to return
     *
     * @return Set of Columns
     */
    default  LinkedHashSet getColumns(Class columnClass) {
        return Utils.getSubsetByType(getColumns(), columnClass);
    }

    /**
     * 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  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  Optional getColumn(String name, Class columnClass) {
        return getColumns(columnClass).stream()
                .filter(column -> column.getName().equals(name))
                .findFirst();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy