添加 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;
import java.util.Objects;
import javax.annotation.Nonnull;
/**
@ -28,4 +30,8 @@ import javax.annotation.Nonnull;
public interface IWithCode<T> {
@Nonnull
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 {
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 {
long getCode();
default boolean equalsCode(long code) {
return getCode() == code;
}
}