Class FunctionalInterfaceLogic
java.lang.Object
com.github.javaparser.resolution.logic.FunctionalInterfaceLogic
- Author:
- Federico Tomassetti
-
Method Summary
Modifier and TypeMethodDescriptionstatic Optional<MethodUsage> getFunctionalMethod(ResolvedReferenceTypeDeclaration typeDeclaration) Get the functional method defined by the type, if any.static Optional<MethodUsage> Get the functional method defined by the type, if any.static boolean
-
Method Details
-
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
Optional.empty()immediately without throwing an exception.Note: bounded type variables (
<T extends Runnable>) and intersection types (Runnable & Serializable) are not handled here and also returnOptional.empty(). Supporting those cases is a separate, more complex enhancement (see JLS §15.27.3).- Parameters:
type- the resolved type to inspect — may be anyResolvedTypesubclass- Returns:
- 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
- See Also:
-
getFunctionalMethod
public static Optional<MethodUsage> getFunctionalMethod(ResolvedReferenceTypeDeclaration typeDeclaration) Get the functional method defined by the type, if any. -
isFunctionalInterfaceType
-