top.cutexingluo.tools.common.opt.OptData Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xingtools-core Show documentation
Show all versions of xingtools-core Show documentation
xingtools 核心,包括各种接口,实体类和工具类
package top.cutexingluo.tools.common.opt;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
/**
* @author XingTian
* @version 1.0.0
* @date 2024/3/22 17:05
* @since 1.0.4
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class OptData extends OptRes {
protected Meta meta;
public OptData(T value) {
super(value);
}
public OptData() {
}
public OptData(T value, Class clazz) {
super(value, clazz);
}
public OptData(@NotNull OptRes optRes) {
this(optRes.value, optRes.clazz, null);
}
public OptData(@NotNull OptRes optRes, Meta meta) {
this(optRes.value, optRes.clazz, meta);
}
public OptData(T value, Class clazz, Meta meta) {
super(value, clazz);
this.meta = meta;
}
/**
* 组装值
*
* @param value 值
* @param meta Meta
* @since 1.0.5
*/
@NotNull
public static OptData of(T value, Meta meta) {
OptData data = new OptData<>(value);
data.setMeta(meta);
return data;
}
/**
* 重写 toString 方法
*
* @since 1.0.5
*/
@Override
public String toString() {
return "OptData{" +
"value=" + value +
", clazz=" + clazz +
", meta=" + meta +
'}';
}
@NotNull
@Contract("_ -> new")
public static OptData of(OptRes optRes) {
return new OptData<>(optRes);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy