Skip to content

Commit

Permalink
chore: change to use java.util.Set to avoid duplication
Browse files Browse the repository at this point in the history
Signed-off-by: Maximillian Arruda <dearrudam@gmail.com>
  • Loading branch information
dearrudam committed May 23, 2023
1 parent 8fa340c commit df9e22a
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import org.eclipse.jnosql.communication.Configurations;
import org.eclipse.jnosql.communication.Settings;

import java.util.ArrayList;
import java.util.List;
import java.util.LinkedHashSet;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Stream;

import static java.util.Arrays.asList;
Expand All @@ -41,7 +41,7 @@ public abstract class CouchbaseConfiguration {
protected String index;

protected String collection;
protected List<String> collections = new ArrayList<>();
protected Set<String> collections = new LinkedHashSet<>();


protected void update(Settings settings) {
Expand Down Expand Up @@ -75,8 +75,8 @@ private String getIndex(Settings settings) {
.map(Object::toString).orElse(null);
}

private List<String> getCollections(Settings settings) {
List<String> collections = new ArrayList<>();
private Set<String> getCollections(Settings settings) {
Set<String> collections = new LinkedHashSet<>();
settings.get(CouchbaseConfigurations.COLLECTIONS)
.map(Object::toString).stream()
.flatMap(s -> Stream.of(s.split(",\\s*")))
Expand Down Expand Up @@ -159,7 +159,7 @@ public void addCollection(String collection) {
*/
public CouchbaseSettings toCouchbaseSettings() {
return new CouchbaseSettings(this.host, this.user, this.password,
this.scope, this.index, this.collection, this.collections);
this.scope, this.index, this.collection, this.collections.stream().toList());
}

@Override
Expand Down

0 comments on commit df9e22a

Please sign in to comment.