getFunctionalMethod

Get the functional method defined by the type, if any.

Per JLS §9.8, a functional interface is always an interface, which is a reference type. Primitive types, array types, and void can therefore never be functional interfaces. Passing such a type returns empty immediately without throwing an exception.

Note: bounded type variables (<T extends Runnable>) and intersection types (Runnable & Serializable) are not handled here and also return empty. Supporting those cases is a separate, more complex enhancement (see JLS §15.27.3).

Return

the single abstract method of the functional interface, or empty if the type is not a functional interface or is not a reference type at all

Parameters

type

the resolved type to inspect — may be any ResolvedType subclass

See also


Get the functional method defined by the type, if any.