-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
116 additions
and
47 deletions.
There are no files selected for viewing
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,53 @@ | ||
package mcp.mobius.waila.api; | ||
|
||
import java.util.List; | ||
|
||
import mcp.mobius.waila.api.__internal__.IApiService; | ||
import org.jetbrains.annotations.ApiStatus; | ||
|
||
/** | ||
* Registry for attaching object instances to a type and its subtypes. | ||
* | ||
* @param <T> the provider type | ||
*/ | ||
@ApiStatus.NonExtendable | ||
public interface IInstanceRegistry<T> { | ||
|
||
/** | ||
* Creates an instance registry. | ||
*/ | ||
static <T> IInstanceRegistry<T> create() { | ||
return IApiService.INSTANCE.createInstanceRegistry(false); | ||
} | ||
|
||
/** | ||
* Creates an instance registry with the priority comparison reversed. | ||
*/ | ||
static <T> IInstanceRegistry<T> createReversed() { | ||
return IApiService.INSTANCE.createInstanceRegistry(true); | ||
} | ||
|
||
/** | ||
* Registers an instance. | ||
* | ||
* @param bound the upper bound type for the instance to apply | ||
* @param instance the instance | ||
* @param priority the priority | ||
*/ | ||
void add(Class<?> bound, T instance, int priority); | ||
|
||
/** | ||
* Returns the instances that apply to the target sorted by their priority. | ||
*/ | ||
List<Entry<T>> get(Object target); | ||
|
||
@ApiStatus.NonExtendable | ||
interface Entry<T> { | ||
|
||
T instance(); | ||
|
||
int priority(); | ||
|
||
} | ||
|
||
} |
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
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
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
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
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
Oops, something went wrong.