package com.github.eventasia.dynamodb;

import com.github.eventasia.framework.Aggregate;
import org.springframework.stereotype.Component;

import java.util.UUID;

@Component
public class EventasiaDynamoDBAggregateRepositoryImpl<A extends Aggregate> implements EventasiaDynamoDBAggregateRepository<A> {

    private final EventasiaDynamoDBConfig config;
    private final Class clazz;

    public EventasiaDynamoDBAggregateRepositoryImpl(EventasiaDynamoDBConfig config, Class clazz) {
        this.config = config;
        this.clazz = clazz;
    }

    @Override
    public void save(A aggregate) {
        config.getMapper().save(aggregate);
    }

    @Override
    public A get(UUID uuid) {
        return (A) config.getMapper().load(clazz, uuid);
    }
}

package com.github.eventasia.dynamodb;

import com.github.eventasia.framework.Aggregate;

import java.util.UUID;

public class EventasiaDynamoDBAggregateRepositoryImpl<A extends Aggregate> implements EventasiaDynamoDBAggregateRepository<A> {

    private final EventasiaDynamoDBConfig config;
    private final Class clazz;

    public EventasiaDynamoDBAggregateRepositoryImpl(EventasiaDynamoDBConfig config, Class clazz) {
        this.config = config;
        this.clazz = clazz;
    }

    @Override
    public void save(A aggregate) {
        config.getMapper().save(aggregate);
    }

    @Override
    public A get(UUID uuid) {
        return (A) config.getMapper().load(clazz, uuid);
    }
}

remove component annotation from dynamo repo