MethodHandles.TableSwitch(MethodHandle, MethodHandle[]) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Creates a table switch method handle, which can be used to switch over a set of target method handles, based on a given target index, called selector.
[Android.Runtime.Register("tableSwitch", "(Ljava/lang/invoke/MethodHandle;[Ljava/lang/invoke/MethodHandle;)Ljava/lang/invoke/MethodHandle;", "", ApiSince=34)]
public static Java.Lang.Invoke.MethodHandle? TableSwitch(Java.Lang.Invoke.MethodHandle? fallback, params Java.Lang.Invoke.MethodHandle[]? targets);
[<Android.Runtime.Register("tableSwitch", "(Ljava/lang/invoke/MethodHandle;[Ljava/lang/invoke/MethodHandle;)Ljava/lang/invoke/MethodHandle;", "", ApiSince=34)>]
static member TableSwitch : Java.Lang.Invoke.MethodHandle * Java.Lang.Invoke.MethodHandle[] -> Java.Lang.Invoke.MethodHandle
Parameters
- fallback
- MethodHandle
the fallback method handle that is called when the selector is not within the range [0, N).
- targets
- MethodHandle[]
array of target method handles.
Returns
the table switch method handle.
- Attributes
Remarks
Creates a table switch method handle, which can be used to switch over a set of target method handles, based on a given target index, called selector. For a selector value of n, where n falls in the range [0, N), and where N is the number of target method handles, the table switch method handle will invoke the n-th target method handle from the list of target method handles. For a selector value that does not fall in the range [0, N), the table switch method handle will invoke the given fallback method handle. All method handles passed to this method must have the same type, with the additional requirement that the leading parameter be of type int. The leading parameter represents the selector. Any trailing parameters present in the type will appear on the returned table switch method handle as well. Any arguments assigned to these parameters will be forwarded, together with the selector value, to the selected method handle when invoking it.
Java reference for java.lang.invoke.MethodHandles.tableSwitch.