mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-02 05:02:10 -07:00
Add keyStream() API to registries (#12479)
This commit is contained in:
@@ -525,6 +525,13 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||
*/
|
||||
Stream<T> stream();
|
||||
|
||||
/**
|
||||
* Returns a new stream, which contains all registry keys, which are registered to the registry.
|
||||
*
|
||||
* @return a stream of all registry keys
|
||||
*/
|
||||
Stream<NamespacedKey> keyStream();
|
||||
|
||||
/**
|
||||
* Attempts to match the registered object with the given key.
|
||||
* <p>
|
||||
@@ -591,6 +598,11 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||
return this.map.values().iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<NamespacedKey> keyStream() {
|
||||
return this.map.keySet().stream();
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
@Deprecated(since = "1.20.6", forRemoval = true)
|
||||
public Class<T> getType() {
|
||||
@@ -606,6 +618,11 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
||||
return StreamSupport.stream(this.spliterator(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<NamespacedKey> keyStream() {
|
||||
return stream().map(this::getKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return Iterables.size(this);
|
||||
|
Reference in New Issue
Block a user