Class FunctionalInterfaceLogic
- java.lang.Object
-
- com.github.javaparser.resolution.logic.FunctionalInterfaceLogic
-
public final class FunctionalInterfaceLogic extends java.lang.Object- Author:
- Federico Tomassetti
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Optional<MethodUsage>getFunctionalMethod(ResolvedReferenceTypeDeclaration typeDeclaration)Get the functional method defined by the type, if any.static java.util.Optional<MethodUsage>getFunctionalMethod(ResolvedType type)Get the functional method defined by the type, if any.static booleanisFunctionalInterfaceType(ResolvedType type)
-
-
-
Method Detail
-
getFunctionalMethod
public static java.util.Optional<MethodUsage> getFunctionalMethod(ResolvedType type)
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:
- Issue #3625
-
getFunctionalMethod
public static java.util.Optional<MethodUsage> getFunctionalMethod(ResolvedReferenceTypeDeclaration typeDeclaration)
Get the functional method defined by the type, if any.
-
isFunctionalInterfaceType
public static boolean isFunctionalInterfaceType(ResolvedType type)
-
-