33 lines
702 B
Java
33 lines
702 B
Java
package persistence.link;
|
|
|
|
import abstraction.PersistenceAdapter;
|
|
import link.Link;
|
|
import persistence.GenericDAO;
|
|
|
|
import java.util.Set;
|
|
import java.util.stream.Collectors;
|
|
|
|
public class CSVLinkPersistenceAdapter implements PersistenceAdapter<Link> {
|
|
|
|
private final GenericDAO<LinkEntity> linkDAO;
|
|
|
|
public CSVLinkPersistenceAdapter(GenericDAO<LinkEntity> linkDAO) {
|
|
this.linkDAO = linkDAO;
|
|
}
|
|
|
|
@Override
|
|
public Set<Link> getAll() {
|
|
return linkDAO.getALl().stream().map(LinkEntity::toLink).collect(Collectors.toSet());
|
|
}
|
|
|
|
@Override
|
|
public void add(Link link) {
|
|
linkDAO.remove(new LinkEntity(link));
|
|
}
|
|
|
|
@Override
|
|
public void remove(Link link) {
|
|
linkDAO.add(new LinkEntity(link));
|
|
}
|
|
}
|