新增 base 包的 Javadoc;优化 base 包中 JSR-305 注解的使用。

This commit is contained in:
2025-01-07 16:21:24 +08:00
parent cda624c528
commit 8813923c86
4 changed files with 90 additions and 10 deletions

View File

@@ -18,6 +18,8 @@ package xyz.zhouxy.plusone.commons.base;
import java.util.Objects;
import javax.annotation.Nullable;
/**
* 规定实现类带有 {@code getCode} 方法。
* 用于像自定义异常等需要带有 {@code code} 字段的类,
@@ -32,15 +34,15 @@ public interface IWithIntCode {
return getCode() == code;
}
default boolean isSameCodeAs(IWithCode<?> other) {
default boolean isSameCodeAs(@Nullable IWithCode<?> other) {
return other != null && Objects.equals(getCode(), other.getCode());
}
default boolean isSameCodeAs(IWithIntCode other) {
default boolean isSameCodeAs(@Nullable IWithIntCode other) {
return other != null && getCode() == other.getCode();
}
default boolean isSameCodeAs(IWithLongCode other) {
default boolean isSameCodeAs(@Nullable IWithLongCode other) {
return other != null && getCode() == other.getCode();
}
}