T - 方法所在的对象类型,通常是接口或基类public class OptionalMethod<T> extends Object
| Modifier and Type | Method and Description |
|---|---|
Object |
invoke(T target,
Object... args)
|
Object |
invokeOptional(T target,
Object... args)
使用
args调用target上的方法。如果该方法不存在或不是公共的,
则返回null。参见invokeOptionalWithoutCheckedException(T, java.lang.Object...) |
Object |
invokeOptionalWithoutCheckedException(T target,
Object... args)
|
Object |
invokeWithoutCheckedException(T target,
Object... args)
调用
target上的方法。如果不支持该方法,则引发错误。
方法抛出的任何RuntimeException都会被抛出,已检查的异常被包装在AssertionError中 |
boolean |
isSupported(T target)
如果方法存在于提供的
target上,则返回true |
public boolean isSupported(T target)
target上,则返回truetarget - 对象public Object invokeOptional(T target, Object... args) throws InvocationTargetException
args调用target上的方法。如果该方法不存在或不是公共的,
则返回null。参见invokeOptionalWithoutCheckedException(T, java.lang.Object...)target - 对象args - 参数信息InvocationTargetException - 如果调用引发异常public Object invokeOptionalWithoutCheckedException(T target, Object... args)
target - 对象args - 参数信息public Object invoke(T target, Object... args) throws InvocationTargetException
target - 对象args - 参数信息InvocationTargetException - 如果调用引发异常public Object invokeWithoutCheckedException(T target, Object... args)
target上的方法。如果不支持该方法,则引发错误。
方法抛出的任何RuntimeException都会被抛出,已检查的异常被包装在AssertionError中target - 对象args - 参数信息Copyright © 2020. All rights reserved.