diff --git a/src/main/java/xyz/zhouxy/plusone/commons/exception/BaseException.java b/src/main/java/xyz/zhouxy/plusone/commons/exception/BaseException.java deleted file mode 100644 index a8b91ad..0000000 --- a/src/main/java/xyz/zhouxy/plusone/commons/exception/BaseException.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2022-2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package xyz.zhouxy.plusone.commons.exception; - -import javax.annotation.Nonnull; -import java.util.Objects; - -/** - * 带错误码的异常。 - * - * @author ZhouXY - */ -public abstract class BaseException - extends Exception { - - private static final long serialVersionUID = -2546365325001947203L; - - @Nonnull - private final String type; - - protected BaseException(String type, String msg) { - super(msg); - this.type = Objects.requireNonNull(type); - } - - protected BaseException(String type, Throwable cause) { - super(cause); - this.type = Objects.requireNonNull(type); - } - - protected BaseException(String type, String msg, Throwable cause) { - super(msg, cause); - this.type = Objects.requireNonNull(type); - } - - @Nonnull - public final String getType() { - return this.type; - } -} diff --git a/src/main/java/xyz/zhouxy/plusone/commons/exception/BaseRuntimeException.java b/src/main/java/xyz/zhouxy/plusone/commons/exception/BaseRuntimeException.java deleted file mode 100644 index 6dbdf68..0000000 --- a/src/main/java/xyz/zhouxy/plusone/commons/exception/BaseRuntimeException.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2022-2023 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package xyz.zhouxy.plusone.commons.exception; - -import javax.annotation.Nonnull; -import java.util.Objects; - -/** - * 带错误码的异常。 - * - * @author ZhouXY - */ -public abstract class BaseRuntimeException extends RuntimeException { - - private static final long serialVersionUID = -6345888403567792664L; - - @Nonnull - private final String type; - - protected BaseRuntimeException(String type, String msg) { - super(msg); - this.type = Objects.requireNonNull(type); - } - - protected BaseRuntimeException(String type, Throwable cause) { - super(cause); - this.type = Objects.requireNonNull(type); - } - - protected BaseRuntimeException(String type, String msg, Throwable cause) { - super(msg, cause); - this.type = Objects.requireNonNull(type); - } - - @Nonnull - public final String getType() { - return this.type; - } -} diff --git a/src/main/java/xyz/zhouxy/plusone/commons/exception/BizException.java b/src/main/java/xyz/zhouxy/plusone/commons/exception/BizException.java deleted file mode 100644 index e21c3ce..0000000 --- a/src/main/java/xyz/zhouxy/plusone/commons/exception/BizException.java +++ /dev/null @@ -1,36 +0,0 @@ -package xyz.zhouxy.plusone.commons.exception; - -/** - * 业务异常 - * - * @author ZhouXY - */ -public class BizException extends BaseRuntimeException { - private static final long serialVersionUID = -5524759033245815405L; - - protected BizException(String type, String msg) { - super(type, msg); - } - - protected BizException(String type, Throwable cause) { - super(type, cause); - } - - protected BizException(String type, String msg, Throwable cause) { - super(type, msg, cause); - } - - private static final String DEFAULT = "0"; - - public static BizException of(String msg) { - return new BizException(DEFAULT, msg); - } - - public static BizException of(Throwable cause) { - return new BizException(DEFAULT, cause); - } - - public static BizException of(String msg, Throwable cause) { - return new BizException(DEFAULT, msg, cause); - } -} diff --git a/src/main/java/xyz/zhouxy/plusone/commons/exception/SysException.java b/src/main/java/xyz/zhouxy/plusone/commons/exception/SysException.java deleted file mode 100644 index b859696..0000000 --- a/src/main/java/xyz/zhouxy/plusone/commons/exception/SysException.java +++ /dev/null @@ -1,31 +0,0 @@ -package xyz.zhouxy.plusone.commons.exception; - -public class SysException extends BaseRuntimeException { - private static final long serialVersionUID = 8821240827443168118L; - - protected SysException(String type, String msg) { - super(type, msg); - } - - protected SysException(String type, Throwable cause) { - super(type, cause); - } - - protected SysException(String type, String msg, Throwable cause) { - super(type, msg, cause); - } - - private static final String DEFAULT = "0"; - - public static SysException of(String msg) { - return new SysException(DEFAULT, msg); - } - - public static SysException of(Throwable cause) { - return new SysException(DEFAULT, cause); - } - - public static SysException of(String msg, Throwable cause) { - return new SysException(DEFAULT, msg, cause); - } -} diff --git a/src/main/java/xyz/zhouxy/plusone/commons/exception/ThirdPartySystemException.java b/src/main/java/xyz/zhouxy/plusone/commons/exception/ThirdPartySystemException.java deleted file mode 100644 index a88227a..0000000 --- a/src/main/java/xyz/zhouxy/plusone/commons/exception/ThirdPartySystemException.java +++ /dev/null @@ -1,31 +0,0 @@ -package xyz.zhouxy.plusone.commons.exception; - -public class ThirdPartySystemException extends BaseRuntimeException { - private static final long serialVersionUID = 20240827113826L; - - protected ThirdPartySystemException(String type, String msg) { - super(type, msg); - } - - protected ThirdPartySystemException(String type, Throwable cause) { - super(type, cause); - } - - protected ThirdPartySystemException(String type, String msg, Throwable cause) { - super(type, msg, cause); - } - - private static final String DEFAULT = "0"; - - public static ThirdPartySystemException of(String msg) { - return new ThirdPartySystemException(DEFAULT, msg); - } - - public static ThirdPartySystemException of(Throwable cause) { - return new ThirdPartySystemException(DEFAULT, cause); - } - - public static ThirdPartySystemException of(String msg, Throwable cause) { - return new ThirdPartySystemException(DEFAULT, msg, cause); - } -} diff --git a/src/test/java/xyz/zhouxy/plusone/commons/SerialTests.java b/src/test/java/xyz/zhouxy/plusone/commons/SerialTests.java index c556af6..1b311d7 100644 --- a/src/test/java/xyz/zhouxy/plusone/commons/SerialTests.java +++ b/src/test/java/xyz/zhouxy/plusone/commons/SerialTests.java @@ -5,14 +5,14 @@ import java.io.ObjectStreamClass; import org.junit.jupiter.api.Test; import lombok.extern.slf4j.Slf4j; -import xyz.zhouxy.plusone.commons.exception.BaseRuntimeException; +import xyz.zhouxy.plusone.commons.exception.NoAvailableMacFoundException; @Slf4j class SerialTests { @Test void testSerialVersionUID() { - long uid = getSerialVersionUID(BaseRuntimeException.class); + long uid = getSerialVersionUID(NoAvailableMacFoundException.class); log.info("\n private static final long serialVersionUID = {}L;", uid); }