添加 equalsCode 方法

dev
ZhouXY108 2024-03-15 09:19:56 +08:00
parent 7f80a411db
commit 9a0b6404cb
3 changed files with 14 additions and 0 deletions

View File

@ -16,6 +16,8 @@
package xyz.zhouxy.plusone.commons.base; package xyz.zhouxy.plusone.commons.base;
import java.util.Objects;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
/** /**
@ -28,4 +30,8 @@ import javax.annotation.Nonnull;
public interface IWithCode<T> { public interface IWithCode<T> {
@Nonnull @Nonnull
T getCode(); T getCode();
default boolean equalsCode(T code) {
return Objects.equals(getCode(), code);
}
} }

View File

@ -25,4 +25,8 @@ package xyz.zhouxy.plusone.commons.base;
*/ */
public interface IWithIntCode { public interface IWithIntCode {
int getCode(); int getCode();
default boolean equalsCode(int code) {
return getCode() == code;
}
} }

View File

@ -25,4 +25,8 @@ package xyz.zhouxy.plusone.commons.base;
*/ */
public interface IWithLongCode { public interface IWithLongCode {
long getCode(); long getCode();
default boolean equalsCode(long code) {
return getCode() == code;
}
} }