IdMap.java
net.minecraft.core.IdMap
信息
- 全限定名:net.minecraft.core.IdMap
- 类型:public interface
- 包:net.minecraft.core
- 源码路径:src/main/java/net/minecraft/core/IdMap.java
- 起始行号:L5
- 继承:Iterable
- 职责:
TODO
字段/常量
DEFAULT- 类型:
int - 修饰符:
package-private - 源码定位:
L6 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
- 无
方法
下面的方法块按源码顺序生成。
int getId(T thing) @ L8
- 方法名:getId
- 源码定位:L8
- 返回类型:int
- 修饰符:package-private
参数:
- thing: T
说明:
TODO
T byId(int id) @ L10
- 方法名:byId
- 源码定位:L10
- 返回类型:T
- 修饰符:package-private
参数:
- id: int
说明:
TODO
default T byIdOrThrow(int id) @ L12
- 方法名:byIdOrThrow
- 源码定位:L12
- 返回类型:T
- 修饰符:default
参数:
- id: int
说明:
TODO
default int getIdOrThrow(T value) @ L21
- 方法名:getIdOrThrow
- 源码定位:L21
- 返回类型:int
- 修饰符:default
参数:
- value: T
说明:
TODO
int size() @ L30
- 方法名:size
- 源码定位:L30
- 返回类型:int
- 修饰符:package-private
参数:
- 无
说明:
TODO
代码
public interface IdMap<T> extends Iterable<T> {
int DEFAULT = -1;
int getId(T thing);
@Nullable T byId(int id);
default T byIdOrThrow(int id) {
T result = this.byId(id);
if (result == null) {
throw new IllegalArgumentException("No value with id " + id);
} else {
return result;
}
}
default int getIdOrThrow(T value) {
int id = this.getId(value);
if (id == -1) {
throw new IllegalArgumentException("Can't find id for '" + value + "' in map " + this);
} else {
return id;
}
}
int size();
}引用的其他类
- 无