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

org.seedstack.business.internal.migrate.LegacyRepositoryAdapter Maven / Gradle / Ivy

The newest version!
/*
 * Copyright © 2013-2024, The SeedStack authors 
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package org.seedstack.business.internal.migrate;

import java.util.Optional;
import java.util.stream.Stream;
import org.seedstack.business.domain.AggregateExistsException;
import org.seedstack.business.domain.AggregateNotFoundException;
import org.seedstack.business.domain.AggregateRoot;
import org.seedstack.business.domain.LegacyRepository;
import org.seedstack.business.domain.Repository;
import org.seedstack.business.specification.Specification;
import org.seedstack.business.specification.dsl.SpecificationBuilder;

class LegacyRepositoryAdapter, I> implements LegacyRepository {
    private final Repository repository;

    LegacyRepositoryAdapter(Repository repository) {
        this.repository = repository;
    }

    @Override
    public void add(A aggregate) throws AggregateExistsException {
        repository.add(aggregate);
    }

    @Override
    public Stream get(Specification specification, Option... options) {
        return repository.get(specification, options);
    }

    @Override
    public Optional get(I id) {
        return repository.get(id);
    }

    @Override
    public boolean contains(Specification specification) {
        return repository.contains(specification);
    }

    @Override
    public boolean contains(I id) {
        return repository.contains(id);
    }

    @Override
    public boolean contains(A aggregate) {
        return repository.contains(aggregate);
    }

    @Override
    public long count(Specification specification) {
        return repository.count(specification);
    }

    @Override
    public long size() {
        return repository.size();
    }

    @Override
    public boolean isEmpty() {
        return repository.isEmpty();
    }

    @Override
    public long remove(Specification specification) throws AggregateNotFoundException {
        return repository.remove(specification);
    }

    @Override
    public void remove(I id) throws AggregateNotFoundException {
        repository.remove(id);
    }

    @Override
    public void remove(A aggregate) throws AggregateNotFoundException {
        repository.remove(aggregate);
    }

    @Override
    public A update(A aggregate) throws AggregateNotFoundException {
        return repository.update(aggregate);
    }

    @Override
    public A addOrUpdate(A aggregate) {
        return repository.addOrUpdate(aggregate);
    }

    @Override
    public void clear() {
        repository.clear();
    }

    @Override
    public Class getAggregateRootClass() {
        return repository.getAggregateRootClass();
    }

    @Override
    public Class getIdentifierClass() {
        return repository.getIdentifierClass();
    }

    @Override
    public SpecificationBuilder getSpecificationBuilder() {
        return repository.getSpecificationBuilder();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy