本文整理汇总了Java中java.lang.AssertionError类的典型用法代码示例。如果您正苦于以下问题:Java AssertionError类的具体用法?Java AssertionError怎么用?Java AssertionError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AssertionError类属于java.lang包,在下文中一共展示了AssertionError类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerOpt
import java.lang.AssertionError; //导入依赖的package包/类
/**
* Register a command line option.
* @param c Single character designator for this option. It cannot be '-'.
* @param s Full word designator for this option. This can be null, in which case
* no long designator will exist for this option.
* @param ve If REQUIRED, a value will be expected with this option. If
* OPTIONAL a value will be accepted if it is seen.
* @throws AssertionError if there is no short option, or if this option has already been
* used.
*/
public void registerOpt(char c, String s, ValueExpected ve)
{
if (c == '-') {
throw new AssertionError("CmdLineParser: '-' is not a legal single character designator.");
}
Character cc = Character.valueOf(c);
if (mShort.put(cc, ve) != null) {
throw new AssertionError("CmdLineParser: You have already registered option " + cc.toString());
}
if (mLong != null) {
if (mLong.put(s, cc) != null) {
throw new AssertionError("CmdLineParser: You have already registered option " + s);
}
}
}
示例2: insert_context
import java.lang.AssertionError; //导入依赖的package包/类
private synchronized int insert_context(BluetoothDevice dev) {
String addr = dev.getAddress();
if (addr_ctx.containsKey(addr)) {
throw new AssertionError("Trying to reinsert context for " + addr);
}
int context = new_context();
ctx_dev.put(context, dev);
addr_ctx.put(addr, context);
path_ctx.put(PATH_PREFIX + context, context);
return context;
}
示例3: check
import java.lang.AssertionError; //导入依赖的package包/类
/** Throw an AssertionError if the boolean parameter is not true. */
public static void check(boolean b, String message) {
if( ! b )
throw new AssertionError(message) ; }