cn.maarlakes.enumx.Valuable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of enumx Show documentation
Show all versions of enumx Show documentation
enumx 提供枚举值的统一接口,枚举值扩展接口,以及一些常见的枚举工具方法。
The newest version!
package cn.maarlakes.enumx;
import com.alibaba.fastjson2.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonValue;
import jakarta.annotation.Nonnull;
import java.io.Serializable;
/**
* @author linjpxc
*/
public interface Valuable extends Serializable {
@Nonnull
@JsonValue
@JSONField
T value();
@Nonnull
@SuppressWarnings("unchecked")
default Class valueType() {
return (Class) this.value().getClass();
}
@Nonnull
static , V> Class getValueType(@Nonnull Class type) {
return ValueUtils.getValueType(type);
}
}