Skip to content

Commit

Permalink
decrease API breakage by using Set over Collection
Browse files Browse the repository at this point in the history
  • Loading branch information
ix0rai committed Sep 18, 2024
1 parent d2e9071 commit e870ea7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

public class ProjectClassProvider implements ClassProvider {
@Nullable
Expand Down Expand Up @@ -78,11 +80,11 @@ public Collection<String> getClassNames() {
return this.classNames;
}

public Collection<String> getMainClassNames() {
return this.main != null ? this.main.getClassNames() : Collections.emptySet();
public Set<String> getMainClassNames() {
return this.main != null ? new HashSet<>(this.main.getClassNames()) : Collections.emptySet();
}

public Collection<String> getLibraryClassNames() {
return this.libraries != null ? this.libraries.getClassNames() : Collections.emptySet();
public Set<String> getLibraryClassNames() {
return this.libraries != null ? new HashSet<>(this.libraries.getClassNames()) : Collections.emptySet();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import org.quiltmc.enigma.api.class_provider.ProjectClassProvider;

import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Set;

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

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

return new JarIndexerService() {
@Override
public void acceptJar(Collection<String> scope, ProjectClassProvider classProvider, JarIndex jarIndex) {
public void acceptJar(Set<String> scope, ProjectClassProvider classProvider, JarIndex jarIndex) {
for (String className : scope) {
ClassNode node = classProvider.get(className);
if (node != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.quiltmc.enigma.api.translation.representation.entry.ParentedEntry;
import org.quiltmc.enigma.util.I18n;

import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
Expand Down Expand Up @@ -76,7 +75,7 @@ public <T extends JarIndexer> T getIndex(Class<T> clazz) {
* @param classProvider a class provider containing all classes in the jar
* @param progress a progress listener to track index completion
*/
public void indexJar(Collection<String> classNames, ClassProvider classProvider, ProgressListener progress) {
public void indexJar(Set<String> classNames, ClassProvider classProvider, ProgressListener progress) {
// for use in processIndex
this.progress = progress;

Expand Down

0 comments on commit e870ea7

Please sign in to comment.