/** * 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); } } }
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; }
/** Throw an AssertionError if the boolean parameter is not true. */ public static void check(boolean b, String message) { if( ! b ) throw new AssertionError(message) ; }