类 Objects2
- java.lang.Object
-
- net.dongliu.commons.Objects2
-
public class Objects2 extends java.lang.ObjectJdk already has one Objects class, So named as Objects2
-
-
嵌套类概要
嵌套类 修饰符和类型 类 说明 static classObjects2.ToStringHelper已过时。
-
构造器概要
构造器 构造器 说明 Objects2()
-
方法概要
所有方法 静态方法 具体方法 已过时的方法 修饰符和类型 方法 说明 static <T> Tcast(java.lang.Object value)Method for suppress generic class type cast warning.static <T> Telvis(@Nullable T value1, java.util.function.Supplier<T> supplier)Elvis operator.static <T> Telvis(@Nullable T value1, T value2)Elvis operator.static <T> TrunWith(T value, java.util.function.Consumer<T> consumer)Convenient method for manipulating object.static java.lang.StringtoString(@Nullable java.lang.Object value)已过时。static Objects2.ToStringHelpertoStringHelper(java.lang.Class<?> cls)已过时。
-
-
-
方法详细资料
-
cast
public static <T> T cast(java.lang.Object value)
Method for suppress generic class type cast warning. Usage:var list = Objects2.
- >cast(value);
- 类型参数:
T- the class type
-
elvis
public static <T> T elvis(@Nullable T value1, T value2)Elvis operator. If value1 is not null, use return value1; else return values2.- 类型参数:
T- the value type- 返回:
- non-null value
- 抛出:
java.lang.NullPointerException- if value2 is null
-
runWith
public static <T> T runWith(T value, java.util.function.Consumer<T> consumer)Convenient method for manipulating object.Pojo pojo = runWith(new Pojo(), p -> {p.setX(x); p.setY(y);})
-
elvis
public static <T> T elvis(@Nullable T value1, java.util.function.Supplier<T> supplier)Elvis operator. If value1 is not null, use return value1; else use value calculate by supplier- 类型参数:
T- the value type- 参数:
supplier- to calculate non-null value- 返回:
- non-null value
- 抛出:
java.lang.NullPointerException- if supplier is null or produce null value
-
toStringHelper
@Deprecated public static Objects2.ToStringHelper toStringHelper(java.lang.Class<?> cls)
已过时。Get a ToStringHelper to convert specific type object to string.
-
toString
@Deprecated public static java.lang.String toString(@Nullable java.lang.Object value)
已过时。Convert object to string, by concat each filed name and value, using reflection.Implementation Details: This method use a internal weak ToStringHelper cache to boost performance.
- 参数:
value- the object to convert to string- 返回:
- string represent of value
-
-