All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nervousync.exceptions.AbstractException Maven / Gradle / Ivy

There is a newer version: 1.2.1
Show newest version
/*
 * Licensed to the Nervousync Studio (NSYC) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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
 *
 *      http://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 org.nervousync.exceptions;

import org.nervousync.commons.Globals;
import org.nervousync.utils.MultilingualUtils;
import org.nervousync.utils.ObjectUtils;

/**
 * 

Abstract Exception

*

异常抽象类

* * @author Steven Wee [email protected] * @version $Revision: 1.0.0 $ $Date: Jul 06, 2023 12:56:26 $ */ public abstract class AbstractException extends Exception { /** * Serial version UID * 序列化UID */ private static final long serialVersionUID = 3698481050554660066L; private final MultilingualUtils.Agent multiAgent = MultilingualUtils.newAgent(this.getClass()); /** * Error identified code * 错误识别代码 */ private final long errorCode; private final String detailMessage; /** *

Constructor method for NetworkInfoException

* Create a new NetworkInfoException with the specified message. *

NetworkInfoException构造方法

* 使用特定的信息创建NetworkInfoException实例对象。 * * @param errorCode Error identified code * 错误识别代码 * @param messageKey Message identify key * 信息识别键值 * @param collections given parameters of information formatter * 用于资源信息格式化的参数 */ protected AbstractException(final long errorCode, final String messageKey, final Object... collections) { super(Globals.DEFAULT_VALUE_STRING); this.errorCode = errorCode; this.detailMessage = this.multiAgent.findMessage(messageKey, collections); } /** *

Constructor method for NetworkInfoException

* Create a new NetworkInfoException with the specified message and root cause. *

NetworkInfoException构造方法

* 使用特定的信息以及异常信息对象实例创建NetworkInfoException实例对象。 * * @param errorCode Error identified code * 错误识别代码 * @param messageKey Message identify key * 信息识别键值 * @param cause The root cause * 异常信息对象实例 * @param collections given parameters of information formatter * 用于资源信息格式化的参数 */ protected AbstractException(final long errorCode, final String messageKey, final Throwable cause, final Object... collections) { super(Globals.DEFAULT_VALUE_STRING, cause); this.errorCode = errorCode; this.detailMessage = this.multiAgent.findMessage(messageKey, collections); } /** *

Getter method for error identified code

*

错误识别代码的Getter方法

* * @return Error identified code * 错误识别代码 */ public long getErrorCode() { return errorCode; } @Override public final String getMessage() { return detailMessage; } /** * (non-javadoc) * @see Object#equals(Object) */ @Override public final boolean equals(final Object other) { if (other == null) { return Boolean.FALSE; } if (this == other) { return Boolean.TRUE; } if (ObjectUtils.nullSafeEquals(other.getClass(), this.getClass())) { AbstractException otherBe = (AbstractException) other; return (ObjectUtils.nullSafeEquals(this.getMessage(), otherBe.getMessage()) && ObjectUtils.nullSafeEquals(this.getCause(), otherBe.getCause())); } return Boolean.FALSE; } /** * (non-javadoc) * @see Object#hashCode() */ @Override public final int hashCode() { return this.getMessage().hashCode(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy