nullargumentexception.java
来自「CroftSoft Code Library是一个开源的可移植的纯Java游戏库」· Java 代码 · 共 81 行
JAVA
81 行
package com.croftsoft.core.lang;
/*********************************************************************
* Thrown to indicate that a method has been passed a null argument.
*
* <P>
*
* The static convenience method <i>check()</i> is a useful shorthand
* notation for checking whether object constructor method arguments
* are null:
* <pre><code>
* public Book ( String title )
* {
* NullArgumentException.check ( this.title = title, "null title" );
* }
* </code></pre>
*
* @author
* <A HREF="http://www.alumni.caltech.edu/~croft">David W. Croft</A>
* @version
* 2001-02-16
*********************************************************************/
public final class NullArgumentException
extends IllegalArgumentException
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
{
/*********************************************************************
* Checks whether the argument is null.
*
* @throws NullArgumentException
* If the argument is null.
*********************************************************************/
public static void check ( Object argument )
//////////////////////////////////////////////////////////////////////
{
if ( argument == null )
{
throw new NullArgumentException ( );
}
}
/*********************************************************************
* Checks whether the argument is null.
*
* @param detailMessage
* The detail message provided if a NullArgumentExcepton is created.
* @throws NullArgumentException
* If the argument is null.
*********************************************************************/
public static void check (
Object argument,
String detailMessage )
//////////////////////////////////////////////////////////////////////
{
if ( argument == null )
{
throw new NullArgumentException ( detailMessage );
}
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
public NullArgumentException ( )
//////////////////////////////////////////////////////////////////////
{
}
public NullArgumentException ( String detailMessage )
//////////////////////////////////////////////////////////////////////
{
super ( detailMessage );
}
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?