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

com.teradata.tempto.fulfillment.table.TableManager Maven / Gradle / Ivy

There is a newer version: 1.40
Show newest version
/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.teradata.tempto.fulfillment.table;

import com.teradata.tempto.fulfillment.table.MutableTableRequirement.State;
import com.teradata.tempto.internal.fulfillment.table.TableName;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import static com.teradata.tempto.fulfillment.table.MutableTableRequirement.State.LOADED;
import static com.teradata.tempto.fulfillment.table.TableManagerDispatcher.getTableManagerDispatcher;

/**
 * Provides functionality of creating/dropping tables based on {@link TableDefinition}.
 */
public interface TableManager
{
    @Retention(RetentionPolicy.RUNTIME)
    @Target({ElementType.TYPE})
    @interface Descriptor
    {

        Class tableDefinitionClass();
        String type();

    }

    default TableInstance createImmutable(T tableDefinition) {
        return createImmutable(tableDefinition, tableDefinition.getTableHandle());
    }

    TableInstance createImmutable(T tableDefinition, TableHandle tableHandle);

    default TableInstance createMutable(T tableDefinition)
    {
        return createMutable(tableDefinition, LOADED);
    }

    default TableInstance createMutable(T tableDefinition, State state)
    {
        return createMutable(tableDefinition, state, tableDefinition.getTableHandle());
    }

    TableInstance createMutable(T tableDefinition, State state, TableHandle tableHandle);

    void dropTable(TableName tableName);

    void dropAllMutableTables();

    static  TableInstance createImmutableTable(T tableDefinition)
    {
        return getTableManagerDispatcher().getTableManagerFor(tableDefinition).createImmutable(tableDefinition);
    }

    static  TableInstance createMutableTable(T tableDefinition, State state)
    {
        return getTableManagerDispatcher().getTableManagerFor(tableDefinition).createMutable(tableDefinition, state);
    }

    static  TableInstance createMutableTable(T tableDefinition)
    {
        return getTableManagerDispatcher().getTableManagerFor(tableDefinition).createMutable(tableDefinition);
    }

    String getDatabaseName();

    Class getTableDefinitionClass();
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy