This repository has been archived on 2022-06-01. You can view files and clone it, but cannot push or open issues or pull requests.
LinkDitch/1-Adapter/src/main/java/cli/link/LinkCliAdapter.java
qvalentin 3ef31c9c3c
All checks were successful
continuous-integration/drone/push Build is passing
all sorts of things
2022-05-16 21:09:45 +02:00

30 lines
754 B
Java

package cli.link;
import category.CategoryName;
import link.LinkDto;
import link.LinkUrl;
import link.LinkUseCase;
import user.Username;
import java.util.Set;
import java.util.stream.Collectors;
public class LinkCliAdapter {
private final LinkUseCase linkUseCase;
public LinkCliAdapter(LinkUseCase linkUseCase) {
this.linkUseCase = linkUseCase;
}
public void addLink(String url, Set<String> categoryNames, String creator) {
linkUseCase.addLink(new LinkUrl(url),
categoryNames.stream().map(CategoryName::new).collect(Collectors.toSet()),
new Username(creator));
}
public Set<String> getLinks() {
return linkUseCase.getLinks().stream().map(LinkDto::toString).collect(Collectors.toSet());
}
}