java.lang.Object
io.helidon.service.codegen.ServiceContracts
Handling of eligible contracts.
Contract is eligible if it is annotated with Service.Contract, or referenced
from service type or its super types via Service.ExternalContracts.
In case the option ServiceOptions.AUTO_ADD_NON_CONTRACT_INTERFACES is set to
true, all types are eligible (including classes and not contract annotated types).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceResult of analysis of provided contracts. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddContracts(Set<ResolvedType> contractSet, HashSet<ResolvedType> processed, TypeInfo typeInfo) Add contracts from the type (from its implemented interfaces and super types).analyseFactory(TypeName factoryInterface) Analyse the service info if it is in fact a factory of the expected type.static ServiceContractscreate(CodegenOptions options, Function<TypeName, Optional<TypeInfo>> typeInfoFactory, TypeInfo serviceInfo) Create new eligible contracts.booleanisEligible(TypeInfo contractInfo) Check if a type info is eligible to be a contract.booleanisEligible(TypeName contractType) Check if a type is eligible to be a contract.static TypeNamerequiredTypeArgument(TypeInfo typeInfo, int index) Get the desired type parameter of the type info provided.
-
Method Details
-
create
public static ServiceContracts create(CodegenOptions options, Function<TypeName, Optional<TypeInfo>> typeInfoFactory, TypeInfo serviceInfo) Create new eligible contracts.- Parameters:
options- codegen optionstypeInfoFactory- function to obtain a type info (if possible) based on type nameserviceInfo- service info to analyze- Returns:
- a new instance to check if an implemented interface or a super type is a contract or not
-
requiredTypeArgument
Get the desired type parameter of the type info provided.- Parameters:
typeInfo- type info to analyze (such as an implemented interfaceSupplier<String>index- index of the type arguments (such as0)- Returns:
- the type argument at the requested index, such as
java.lang.String - Throws:
CodegenException- in case the type argument is not available
-
isEligible
Check if a type info is eligible to be a contract.- Parameters:
contractInfo- candidate type info- Returns:
- whether the candidate is a contract or not
-
isEligible
Check if a type is eligible to be a contract.- Parameters:
contractType- candidate type- Returns:
- whether the candidate is a contract or not
-
analyseFactory
Analyse the service info if it is in fact a factory of the expected type.- Parameters:
factoryInterface- the provider we check, the provided contract must be the first type argument- Returns:
- result of the analysis
-
addContracts
public void addContracts(Set<ResolvedType> contractSet, HashSet<ResolvedType> processed, TypeInfo typeInfo) Add contracts from the type (from its implemented interfaces and super types).- Parameters:
contractSet- set of contracts to amend with the contracts of the provided type infoprocessed- set of processed contracts, to avoid infinite looptypeInfo- type info to analyze for contracts
-