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

tech.ydb.yoj.repository.db.AbstractDelegatingTable Maven / Gradle / Ivy

Go to download

Core YOJ (YDB ORM for Java) abstractions and APIs for domain entities, repositories, transactions etc.

The newest version!
package tech.ydb.yoj.repository.db;

import com.google.common.reflect.TypeToken;
import lombok.AccessLevel;
import lombok.Getter;
import tech.ydb.yoj.databind.expression.FilterExpression;
import tech.ydb.yoj.databind.expression.OrderExpression;
import tech.ydb.yoj.repository.BaseDb;
import tech.ydb.yoj.repository.db.readtable.ReadTableParams;
import tech.ydb.yoj.repository.db.statement.Changeset;

import javax.annotation.Nullable;
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;

public abstract class AbstractDelegatingTable> implements Table {
    @Getter(AccessLevel.PROTECTED)
    private final Table target;

    protected AbstractDelegatingTable(Table target) {
        this.target = target;
    }

    protected AbstractDelegatingTable() {
        this.target = BaseDb.current(BaseDb.class).table(resolveEntityType());
    }

    @SuppressWarnings("unchecked")
    private Class resolveEntityType() {
        return (Class) (new TypeToken(getClass()) {
        }).getRawType();
    }

    @Override
    public List find(@Nullable String indexName, @Nullable FilterExpression filter, @Nullable OrderExpression orderBy, @Nullable Integer limit, @Nullable Long offset) {
        return target.find(indexName, filter, orderBy, limit, offset);
    }

    @Override
    public > List findIds(@Nullable String indexName, @Nullable FilterExpression filter, @Nullable OrderExpression orderBy, @Nullable Integer limit, @Nullable Long offset) {
        return target.findIds(indexName, filter, orderBy, limit, offset);
    }

    @Override
    public  List find(
            Class viewClass,
            @Nullable String indexName,
            @Nullable FilterExpression finalFilter,
            @Nullable OrderExpression orderBy,
            @Nullable Integer limit,
            @Nullable Long offset,
            boolean distinct
    ) {
        return target.find(viewClass, indexName, finalFilter, orderBy, limit, offset, distinct);
    }

    @Override
    public > List find(Set ids, @Nullable FilterExpression filter, @Nullable OrderExpression orderBy, @Nullable Integer limit) {
        return target.find(ids, filter, orderBy, limit);
    }

    @Override
    public > List findUncached(Set ids, @Nullable FilterExpression filter, @Nullable OrderExpression orderBy, @Nullable Integer limit) {
        return target.findUncached(ids, filter, orderBy, limit);
    }

    @Override
    public > List find(Class viewType, Set ids, @Nullable FilterExpression filter, @Nullable OrderExpression orderBy, @Nullable Integer limit) {
        return target.find(viewType, ids, filter, orderBy, limit);
    }

    @Override
    public  List find(String indexName, Set keys, @Nullable FilterExpression filter, @Nullable OrderExpression orderBy, @Nullable Integer limit) {
        return target.find(indexName, keys, filter, orderBy, limit);
    }

    @Override
    public  List find(Class viewType, String indexName, Set keys, @Nullable FilterExpression filter, @Nullable OrderExpression orderBy, @Nullable Integer limit) {
        return target.find(viewType, indexName, keys, filter, orderBy, limit);
    }

    @Override
    public long count(String indexName, FilterExpression filter) {
        return target.count(indexName, filter);
    }

    @Override
    public void update(Entity.Id id, Changeset changeset) {
        target.update(id, changeset);
    }

    @Override
    public > Stream readTable(ReadTableParams params) {
        return target.readTable(params);
    }

    @Override
    public > Stream readTableIds(ReadTableParams params) {
        return target.readTableIds(params);
    }

    @Override
    public , ID extends Entity.Id> Stream readTable(Class viewClass, ReadTableParams params) {
        return target.readTable(viewClass, params);
    }

    @Override
    public Class getType() {
        return target.getType();
    }

    @Override
    public T find(Entity.Id id) {
        return target.find(id);
    }

    @Override
    public  V find(Class viewType, Entity.Id id) {
        return target.find(viewType, id);
    }

    @Override
    public > List find(Range range) {
        return target.find(range);
    }

    @Override
    public > List findIds(Range range) {
        return target.findIds(range);
    }

    @Override
    public > List findIds(Set partialIds) {
        return target.findIds(partialIds);
    }

    @Override
    public > List find(Class viewType, Range range) {
        return target.find(viewType, range);
    }

    @Override
    public > List find(Set ids) {
        return target.find(ids);
    }

    @Override
    public > List find(Class viewType, Set ids) {
        return target.find(viewType, ids);
    }

    @Override
    public List findAll() {
        return target.findAll();
    }

    @Override
    public  List findAll(Class viewType) {
        return target.findAll(viewType);
    }

    @Override
    public long countAll() {
        return target.countAll();
    }

    @Override
    public T insert(T t) {
        return target.insert(t);
    }

    @Override
    public T save(T t) {
        return target.save(t);
    }

    @Override
    public void delete(Entity.Id id) {
        target.delete(id);
    }

    @Override
    public void deleteAll() {
        target.deleteAll();
    }

    @Override
    public Stream streamAll(int batchSize) {
        return target.streamAll(batchSize);
    }

    @Override
    public > Stream streamAll(Class viewType, int batchSize) {
        return target.streamAll(viewType, batchSize);
    }

    @Override
    public > Stream streamPartial(ID partial, int batchSize) {
        return target.streamPartial(partial, batchSize);
    }

    @Override
    public , V extends ViewId> Stream streamPartial(Class viewType, ID partial, int batchSize) {
        return target.streamPartial(viewType, partial, batchSize);
    }

    @Override
    public > Stream streamAllIds(int batchSize) {
        return target.streamAllIds(batchSize);
    }

    @Override
    public > Stream streamPartialIds(ID partial, int batchSize) {
        return target.streamPartialIds(partial, batchSize);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy