ExpectedException.java 1.71 KB
Newer Older
Kim Gyeongeun committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
package jp.agentec.sinaburocast.common.exception;

/**
 * Exceptionクラス 運用時に予期される例外スーパークラス
 * 
 *
 */
public class ExpectedException extends Exception {

	private static final long serialVersionUID = 1L;
	private transient Object[] args = null;

	private transient String code;
	
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public void setArgs(Object[] args) {
		this.args = args;
	}

	public Object[] getArgs() {
		return args;
	}

	public ExpectedException(String message) {
		super(message);
		this.code = "";
	}

	public ExpectedException(String message , String code) {
		super(message);
		this.code = code;
	}

	/**
	 * エラーメッセージに引数が必要な場合に使用する
	 * 
	 * @param objects エラーメッセージに使用する引数
	 */
	public ExpectedException(Object...objects) {
		super();
		//引数の配列化
		this.args = new Object[objects.length];
		System.arraycopy(objects, 0, this.args, 0, objects.length);
	}

	/**
	 * エラーメッセージに引数が必要な場合に使用する
	 * 
	 * @param message
	 * @param objects エラーメッセージに使用する引数
	 */
	public ExpectedException(String message, Object...objects ) {
		super(message);
		//引数の配列化
		System.arraycopy(objects, 0, this.args, 0, objects.length);		
	}

	/**
	 * エラーメッセージに引数が必要な場合に使用する
	 * 
	 * @param cause
	 * @param objects エラーメッセージに使用する引数
	 */
	public ExpectedException(Throwable cause, Object...objects ) {
		super(cause);
		//引数の配列化
		System.arraycopy(objects, 0, this.args, 0, objects.length);		
	}


}