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

com.heliorm.impl.AliasTable Maven / Gradle / Ivy

The newest version!
package com.heliorm.impl;

import com.heliorm.Database;
import com.heliorm.Field;
import com.heliorm.Index;
import com.heliorm.Table;

import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;

/**
 * @author gideon
 */
public final class AliasTable implements Table {

    private final Database database;
    private final Table table;
    private Set> subs;

    public AliasTable(Database database, Table table) {
        this.database = database;
        this.table = table;
    }

    @Override
    public Class getObjectClass() {
        return table.getObjectClass();
    }

    @Override
    public List> getFields() {
        return table.getFields();
    }

    @Override
    public Optional> getPrimaryKey() {
        return table.getPrimaryKey();
    }

    @Override
    public String getSqlTable() {
        return table.getSqlTable();
    }

    @Override
    public Set> getSubTables() {
        if (subs == null) {
            subs = new HashSet<>();
            for (Table sub : table.getSubTables()) {
                subs.add(new AliasTable<>(database, sub));
            }
        }
        return subs;
    }

    @Override
    public Database getDatabase() {
        return database;
    }

    @Override
    public boolean isAbstract() {
        return table.isAbstract();
    }

    @Override
    public boolean isRecord() {
        return table.isRecord();
    }

    @Override
    public List> getIndexes() {
        return table.getIndexes();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy