Class DenyAction
java.lang.Object
org.cojen.boxtin.DenyAction
Specifies the action to take when access to an operation is denied.
-
Method Summary
Modifier and TypeMethodDescriptioncheck(MethodHandleInfo predicate) Returns this deny action but with a predicate check to determine if the operation should actually be allowed.static DenyActioncustom(MethodHandleInfo mhi) Returns a deny action which performs a custom operation.static DenyActionempty()Returns a deny action which returns an empty instance.static DenyActionReturns a deny action which throws an exception without a message.static DenyActionReturns a deny action which throws an exception with an optional message.static DenyActionReturns a deny action which throws an exception without a message.static DenyActionReturns a deny action which throws an exception with an optional message.static DenyActionstandard()Returns the standard deny action, which throws aSecurityExceptionwithout a message.static DenyActionReturns a deny action which returns a specific value, possibly null.
-
Method Details
-
standard
Returns the standard deny action, which throws aSecurityExceptionwithout a message. -
exception
Returns a deny action which throws an exception without a message. -
exception
Returns a deny action which throws an exception with an optional message. -
exception
Returns a deny action which throws an exception without a message. -
exception
Returns a deny action which throws an exception with an optional message. -
value
Returns a deny action which returns a specific value, possibly null. If the value is incompatible with the actual value type, then null, 0, false, or void is returned instead.Note: This action has no effect for constructors, and if configured as such, the standard action is used instead.
- Throws:
IllegalArgumentException- if the given value isn't null, a boxed primitive, or a string
-
empty
Returns a deny action which returns an empty instance. Types supported are arrays,String,Optional,Iterable,Collection,Stream, and any of the empty variants supported by theCollectionsclass. Otherwise, a new instance is created using a no-arg constructor, possibly resulting in aLinkageErrorat runtime. If the actual type is primitive, then 0, false or void is returned instead.Note: This action has no effect for constructors, and if configured as such, the standard action is used instead.
-
custom
Returns a deny action which performs a custom operation. The parameters given to the custom method are theCaller(optional), the non-null instance (if applicable), and the original method parameters. The return type must exactly match the original method's return type. If the original method has more parameters than the custom method, the trailing ones are dropped. If the custom method type is incompatible, then aSecurityExceptionorWrongMethodTypeExceptioncan be thrown instead.Note: This action has no effect for constructors, unless the custom operation throws an exception. If it doesn't throw an exception, a
SecurityExceptionis thrown instead. -
check
Returns this deny action but with a predicate check to determine if the operation should actually be allowed. The parameters given to the predicate are theCaller(optional), the non-null instance (if applicable), and the original method parameters. The return type must be boolean. If the original method has more parameters than the predicate, the trailing ones are dropped. If the predicate format is incompatible, then aSecurityExceptionorWrongMethodTypeExceptioncan be thrown instead.- Parameters:
predicate- the predicate checking method which returns true when the operation is allowed- Throws:
IllegalArgumentException- if the predicate doesn't return a booleanIllegalStateException- if this action is already checked
-