-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Expand file tree
/
Copy pathRegistryElement.java
More file actions
48 lines (43 loc) · 1.19 KB
/
RegistryElement.java
File metadata and controls
48 lines (43 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package io.papermc.paper.registry;
import io.papermc.paper.registry.tag.TagKey;
import net.kyori.adventure.key.Key;
import org.bukkit.Keyed;
import org.jspecify.annotations.NullMarked;
/**
* An element of a registry which might or might not be registered.
* <p>
* For unregistered element, the equality methods exposed here will return {@code false}
* as there's no way to identify them with a key.
*
* @see RegistryKey
* @see org.bukkit.Registry
* @see org.bukkit.Registry#getKey(Keyed)
*/
@NullMarked
public interface RegistryElement<T> {
/**
* Checks whether this element is identified by the
* given key extracted from this keyed.
*
* @param type the keyed to extract the key from
* @return the result
*/
default boolean is(Keyed type) {
return this.is(type.key());
}
/**
* Checks whether this element is identified by the given key.
*
* @param type the key
* @return the result
*/
boolean is(Key type);
/**
* Checks whether this element is contained in the
* tag identified by the given tag key.
*
* @param type the tag key
* @return the result
*/
boolean is(TagKey<T> type);
}