Skip to content

Commit e870ea7

Browse files
committed
decrease API breakage by using Set over Collection
1 parent d2e9071 commit e870ea7

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

enigma/src/main/java/org/quiltmc/enigma/api/class_provider/ProjectClassProvider.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import java.util.ArrayList;
88
import java.util.Collection;
99
import java.util.Collections;
10+
import java.util.HashSet;
11+
import java.util.Set;
1012

1113
public class ProjectClassProvider implements ClassProvider {
1214
@Nullable
@@ -78,11 +80,11 @@ public Collection<String> getClassNames() {
7880
return this.classNames;
7981
}
8082

81-
public Collection<String> getMainClassNames() {
82-
return this.main != null ? this.main.getClassNames() : Collections.emptySet();
83+
public Set<String> getMainClassNames() {
84+
return this.main != null ? new HashSet<>(this.main.getClassNames()) : Collections.emptySet();
8385
}
8486

85-
public Collection<String> getLibraryClassNames() {
86-
return this.libraries != null ? this.libraries.getClassNames() : Collections.emptySet();
87+
public Set<String> getLibraryClassNames() {
88+
return this.libraries != null ? new HashSet<>(this.libraries.getClassNames()) : Collections.emptySet();
8789
}
8890
}

enigma/src/main/java/org/quiltmc/enigma/api/service/JarIndexerService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import org.quiltmc.enigma.api.class_provider.ProjectClassProvider;
77

88
import javax.annotation.Nullable;
9-
import java.util.Collection;
9+
import java.util.Set;
1010

1111
/**
1212
* Jar indexer services analyse jar files as they're opened to collect information about their contents.
@@ -35,7 +35,7 @@ static boolean shouldIndexLibraries(@Nullable EnigmaServiceContext<JarIndexerSer
3535
* @param classProvider a provider to translate class names into {@link ClassNode class nodes}. Contains both library and main jar classes
3636
* @param jarIndex the current jar index
3737
*/
38-
void acceptJar(Collection<String> scope, ProjectClassProvider classProvider, JarIndex jarIndex);
38+
void acceptJar(Set<String> scope, ProjectClassProvider classProvider, JarIndex jarIndex);
3939

4040
/**
4141
* Whether this indexer should be run on libraries in addition to the main project being indexed.
@@ -69,7 +69,7 @@ static JarIndexerService fromVisitor(@Nullable EnigmaServiceContext<JarIndexerSe
6969

7070
return new JarIndexerService() {
7171
@Override
72-
public void acceptJar(Collection<String> scope, ProjectClassProvider classProvider, JarIndex jarIndex) {
72+
public void acceptJar(Set<String> scope, ProjectClassProvider classProvider, JarIndex jarIndex) {
7373
for (String className : scope) {
7474
ClassNode node = classProvider.get(className);
7575
if (node != null) {

enigma/src/main/java/org/quiltmc/enigma/impl/analysis/index/AbstractJarIndex.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.quiltmc.enigma.api.translation.representation.entry.ParentedEntry;
2626
import org.quiltmc.enigma.util.I18n;
2727

28-
import java.util.Collection;
2928
import java.util.HashSet;
3029
import java.util.LinkedHashMap;
3130
import java.util.Map;
@@ -76,7 +75,7 @@ public <T extends JarIndexer> T getIndex(Class<T> clazz) {
7675
* @param classProvider a class provider containing all classes in the jar
7776
* @param progress a progress listener to track index completion
7877
*/
79-
public void indexJar(Collection<String> classNames, ClassProvider classProvider, ProgressListener progress) {
78+
public void indexJar(Set<String> classNames, ClassProvider classProvider, ProgressListener progress) {
8079
// for use in processIndex
8180
this.progress = progress;
8281

0 commit comments

Comments
 (0)