-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename AudioSearchSourceManager to AudioSearchManager
- Loading branch information
Showing
6 changed files
with
69 additions
and
69 deletions.
There are no files selected for viewing
49 changes: 7 additions & 42 deletions
49
main/src/main/java/com/github/topi314/lavasearch/AudioSearchManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,19 @@ | ||
package com.github.topi314.lavasearch; | ||
|
||
import com.github.topi314.lavasearch.result.AudioSearchResult; | ||
import kotlin.annotations.jvm.ReadOnly; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class AudioSearchManager { | ||
public interface AudioSearchManager { | ||
|
||
private final List<AudioSearchSourceManager> sourceManagers; | ||
|
||
public AudioSearchManager() { | ||
this.sourceManagers = new ArrayList<>(); | ||
} | ||
|
||
public void registerSourceManager(AudioSearchSourceManager sourceManager) { | ||
sourceManagers.add(sourceManager); | ||
} | ||
|
||
@Nullable | ||
public <T extends AudioSearchSourceManager> T source(Class<T> klass) { | ||
for (var sourceManager : sourceManagers) { | ||
if (klass.isAssignableFrom(sourceManager.getClass())) { | ||
return klass.cast(sourceManager); | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public List<AudioSearchSourceManager> getSourceManagers() { | ||
return this.sourceManagers; | ||
} | ||
|
||
public void shutdown() { | ||
for (var sourceManager : this.sourceManagers) { | ||
sourceManager.shutdown(); | ||
} | ||
} | ||
@NotNull | ||
String getSourceName(); | ||
|
||
@Nullable | ||
public AudioSearchResult loadSearch(String query, Set<AudioSearchResult.Type> types) { | ||
for (var sourceManager : this.sourceManagers) { | ||
var searchResults = sourceManager.loadSearch(query, types); | ||
if (searchResults != null) { | ||
return searchResults; | ||
} | ||
} | ||
return null; | ||
} | ||
AudioSearchResult loadSearch(@NotNull String query, @NotNull @ReadOnly Set<AudioSearchResult.Type> types); | ||
|
||
void shutdown(); | ||
} |
19 changes: 0 additions & 19 deletions
19
main/src/main/java/com/github/topi314/lavasearch/AudioSearchSourceManager.java
This file was deleted.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
main/src/main/java/com/github/topi314/lavasearch/SearchManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.github.topi314.lavasearch; | ||
|
||
import com.github.topi314.lavasearch.result.AudioSearchResult; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
public class SearchManager { | ||
|
||
private final List<AudioSearchManager> sourceManagers; | ||
|
||
public SearchManager() { | ||
this.sourceManagers = new ArrayList<>(); | ||
} | ||
|
||
public void registerSourceManager(AudioSearchManager sourceManager) { | ||
sourceManagers.add(sourceManager); | ||
} | ||
|
||
@Nullable | ||
public <T extends AudioSearchManager> T source(Class<T> klass) { | ||
for (var sourceManager : sourceManagers) { | ||
if (klass.isAssignableFrom(sourceManager.getClass())) { | ||
return klass.cast(sourceManager); | ||
} | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public List<AudioSearchManager> getSourceManagers() { | ||
return this.sourceManagers; | ||
} | ||
|
||
public void shutdown() { | ||
for (var sourceManager : this.sourceManagers) { | ||
sourceManager.shutdown(); | ||
} | ||
} | ||
|
||
@Nullable | ||
public AudioSearchResult loadSearch(String query, Set<AudioSearchResult.Type> types) { | ||
for (var sourceManager : this.sourceManagers) { | ||
var searchResults = sourceManager.loadSearch(query, types); | ||
if (searchResults != null) { | ||
return searchResults; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
} |
4 changes: 2 additions & 2 deletions
4
plugin-api/src/main/java/com/github/topi314/lavasearch/api/SearchManagerConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
package com.github.topi314.lavasearch.api | ||
|
||
import com.github.topi314.lavasearch.AudioSearchManager | ||
import com.github.topi314.lavasearch.SearchManager | ||
|
||
interface SearchManagerConfiguration { | ||
fun configure(manager: AudioSearchManager): AudioSearchManager | ||
fun configure(manager: SearchManager): SearchManager | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters