assert.java

来自「JRed is a 100% Java implementation of th」· Java 代码 · 共 42 行

JAVA
42
字号
/*
**************************************************************************
** $Header: /cvsroot/jred/jred/src/com/synchrona/util/Assert.java,v 1.1.1.1 2000/07/05 04:41:53 mpatters Exp $
**
** Copyright (C) 2000 Synchrona, Inc. All rights reserved.
**
** This file is part of JRed, a 100% Java implementation of the IrDA
** infrared communications protocols.
**
** This file may be distributed under the terms of the Synchrona Public
** License as defined by Synchrona, Inc. and appearing in the file
** LICENSE included in the packaging of this file. The Synchrona Public
** License is based on the Q Public License as defined by Troll Tech AS
** of Norway; it differs only in its use of the courts of Florida, USA
** rather than those of Oslo, Norway.
**************************************************************************
*/
package com.synchrona.util;

import java.io.PrintWriter;

public class Assert {
	private static Log s_log = new Log(new PrintWriter(System.out));

	public static void setLog(Log log) {
		s_log = log;
	}

	public static void fail(boolean bCondition, String strMessage) throws Exception {
		if ( !bCondition ) {
			s_log.error("Assertion Failed", strMessage);
			throw new Exception("Assertion Failed: " + strMessage);
		}
	}

	public static void warn(boolean bCondition, String strMessage) {
		if ( !bCondition ) {
			s_log.warn("Assertion Failed", strMessage);
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?