public class Then extends Object
在withException(String)等默认抛出异常的方法中,
当CA的返回值为Boolean.TRUE 时,则会抛出异常
如果有特殊要求 可使用with(Consumer)进行手动处理
| 构造器和说明 |
|---|
Then() |
| 限定符和类型 | 方法和说明 |
|---|---|
static <T extends RuntimeException> |
createInstance(Class<T> clazz,
String message)
必须实现此构造器RuntimeException#Throwable(String)
|
static void |
setDefaultException(@NonNull Class<? extends RuntimeException> defaultException)
设置全局默认异常
必须实现此构造器RuntimeException#Throwable(String)
|
String |
toString() |
void |
with(Consumer<Boolean> function)
将Value返回 手动处理
|
void |
withArithmeticException(String msg)
抛出算数异常
|
void |
withClassNotFoundException(String msg)
抛出class未找到异常
|
void |
withCustomException(Class<? extends RuntimeException> clazz,
String msg)
抛出自定义Exception
|
void |
withDefaultException(String msg)
使用默认的exception
|
void |
withException(Exception exception)
通常来说不建议这样使用 因为不管是true还是false都会创建这个异常对象
|
void |
withException(String msg)
抛出异常
|
void |
withFileNotFoundException(String msg)
抛出文件未找到异常
|
void |
withIndexOutOfBoundsException(String msg)
抛出下标越界异常
|
void |
withNullPointException(String msg)
抛出空指针异常
|
void |
withRuntimeException(RuntimeException exception)
通常来说不建议这样使用 因为不管是true还是false都会创建这个异常对象
|
void |
withRuntimeException(String msg)
抛出运行时异常
|
public static void setDefaultException(@NonNull
@NonNull Class<? extends RuntimeException> defaultException)
public void withDefaultException(String msg)
msg - public void withCustomException(Class<? extends RuntimeException> clazz, String msg)
public void withRuntimeException(String msg)
public void withNullPointException(String msg)
public void withFileNotFoundException(String msg) throws FileNotFoundException
public void withClassNotFoundException(String msg) throws ClassNotFoundException
public void withIndexOutOfBoundsException(String msg)
public void withArithmeticException(String msg)
public void withRuntimeException(RuntimeException exception)
public void withException(Exception exception) throws Exception
Exceptionpublic static <T extends RuntimeException> T createInstance(Class<T> clazz, String message)
Copyright © 2020. All rights reserved.