Optionull.java
net.minecraft.Optionull
信息
- 全限定名:net.minecraft.Optionull
- 类型:public class
- 包:net.minecraft
- 源码路径:src/main/java/net/minecraft/Optionull.java
- 起始行号:L10
- 职责:
TODO
字段/常量
- 无
内部类/嵌套类型
- 无
构造器
- 无
方法
下面的方法块按源码顺序生成。
public static <T> T orElse(T t, T defaultValue) @ L11
- 方法名:orElse
- 源码定位:L11
- 返回类型:
T - 修饰符:public static
参数:
- t: T
- defaultValue: T
说明:
TODO
public static <T,R> R map(T t, Function<T,R> map) @ L16
- 方法名:map
- 源码定位:L16
- 返回类型:<T,R> R
- 修饰符:public static
参数:
- t: T
- map: Function<T,R>
说明:
TODO
public static <T,R> R mapOrDefault(T t, Function<T,R> map, R defaultValue) @ L20
- 方法名:mapOrDefault
- 源码定位:L20
- 返回类型:<T,R> R
- 修饰符:public static
参数:
- t: T
- map: Function<T,R>
- defaultValue: R
说明:
TODO
public static <T,R> R mapOrElse(T t, Function<T,R> map, Supplier<R> elseSupplier) @ L24
- 方法名:mapOrElse
- 源码定位:L24
- 返回类型:<T,R> R
- 修饰符:public static
参数:
- t: T
- map: Function<T,R>
- elseSupplier: Supplier
说明:
TODO
public static <T> T first(Collection<T> collection) @ L28
- 方法名:first
- 源码定位:L28
- 返回类型:
T - 修饰符:public static
参数:
- collection: Collection
说明:
TODO
public static <T> T firstOrDefault(Collection<T> collection, T defaultValue) @ L33
- 方法名:firstOrDefault
- 源码定位:L33
- 返回类型:
T - 修饰符:public static
参数:
- collection: Collection
- defaultValue: T
说明:
TODO
public static <T> T firstOrElse(Collection<T> collection, Supplier<T> elseSupplier) @ L38
- 方法名:firstOrElse
- 源码定位:L38
- 返回类型:
T - 修饰符:public static
参数:
- collection: Collection
- elseSupplier: Supplier
说明:
TODO
public static <T> boolean isNullOrEmpty(T[] t) @ L43
- 方法名:isNullOrEmpty
- 源码定位:L43
- 返回类型:
boolean - 修饰符:public static
参数:
- t: T[]
说明:
TODO
public static boolean isNullOrEmpty(boolean[] t) @ L47
- 方法名:isNullOrEmpty
- 源码定位:L47
- 返回类型:boolean
- 修饰符:public static
参数:
- t: boolean[]
说明:
TODO
public static boolean isNullOrEmpty(byte[] t) @ L51
- 方法名:isNullOrEmpty
- 源码定位:L51
- 返回类型:boolean
- 修饰符:public static
参数:
- t: byte[]
说明:
TODO
public static boolean isNullOrEmpty(char[] t) @ L55
- 方法名:isNullOrEmpty
- 源码定位:L55
- 返回类型:boolean
- 修饰符:public static
参数:
- t: char[]
说明:
TODO
public static boolean isNullOrEmpty(short[] t) @ L59
- 方法名:isNullOrEmpty
- 源码定位:L59
- 返回类型:boolean
- 修饰符:public static
参数:
- t: short[]
说明:
TODO
public static boolean isNullOrEmpty(int[] t) @ L63
- 方法名:isNullOrEmpty
- 源码定位:L63
- 返回类型:boolean
- 修饰符:public static
参数:
- t: int[]
说明:
TODO
public static boolean isNullOrEmpty(long[] t) @ L67
- 方法名:isNullOrEmpty
- 源码定位:L67
- 返回类型:boolean
- 修饰符:public static
参数:
- t: long[]
说明:
TODO
public static boolean isNullOrEmpty(float[] t) @ L71
- 方法名:isNullOrEmpty
- 源码定位:L71
- 返回类型:boolean
- 修饰符:public static
参数:
- t: float[]
说明:
TODO
public static boolean isNullOrEmpty(double[] t) @ L75
- 方法名:isNullOrEmpty
- 源码定位:L75
- 返回类型:boolean
- 修饰符:public static
参数:
- t: double[]
说明:
TODO
代码
public class Optionull {
@Deprecated
public static <T> T orElse(@Nullable T t, T defaultValue) {
return Objects.requireNonNullElse(t, defaultValue);
}
public static <T, R> @Nullable R map(@Nullable T t, Function<T, R> map) {
return t == null ? null : map.apply(t);
}
public static <T, R> R mapOrDefault(@Nullable T t, Function<T, R> map, R defaultValue) {
return t == null ? defaultValue : map.apply(t);
}
public static <T, R> R mapOrElse(@Nullable T t, Function<T, R> map, Supplier<R> elseSupplier) {
return t == null ? elseSupplier.get() : map.apply(t);
}
public static <T> @Nullable T first(Collection<T> collection) {
Iterator<T> iterator = collection.iterator();
return iterator.hasNext() ? iterator.next() : null;
}
public static <T> T firstOrDefault(Collection<T> collection, T defaultValue) {
Iterator<T> iterator = collection.iterator();
return iterator.hasNext() ? iterator.next() : defaultValue;
}
public static <T> T firstOrElse(Collection<T> collection, Supplier<T> elseSupplier) {
Iterator<T> iterator = collection.iterator();
return iterator.hasNext() ? iterator.next() : elseSupplier.get();
}
public static <T> boolean isNullOrEmpty(T @Nullable [] t) {
return t == null || t.length == 0;
}
public static boolean isNullOrEmpty(boolean @Nullable [] t) {
return t == null || t.length == 0;
}
public static boolean isNullOrEmpty(byte @Nullable [] t) {
return t == null || t.length == 0;
}
public static boolean isNullOrEmpty(char @Nullable [] t) {
return t == null || t.length == 0;
}
public static boolean isNullOrEmpty(short @Nullable [] t) {
return t == null || t.length == 0;
}
public static boolean isNullOrEmpty(int @Nullable [] t) {
return t == null || t.length == 0;
}
public static boolean isNullOrEmpty(long @Nullable [] t) {
return t == null || t.length == 0;
}
public static boolean isNullOrEmpty(float @Nullable [] t) {
return t == null || t.length == 0;
}
public static boolean isNullOrEmpty(double @Nullable [] t) {
return t == null || t.length == 0;
}
}引用的其他类
- 无