Class BaseRepositoryMethodsGenerator
java.lang.Object
io.helidon.data.codegen.common.BaseGenerator
io.helidon.data.codegen.common.BaseRepositoryInterfaceGenerator
io.helidon.data.codegen.common.BaseRepositoryMethodsGenerator
- All Implemented Interfaces:
RepositoryInterfaceGenerator
Data repository interface code generator base class for methods generators.
-
Field Summary
Fields inherited from class BaseGenerator
BIG_DECIMAL, BIG_INTEGER, CLASS_WILDCARD, ENTITIES, ENTITY, EXECUTOR, GENERIC_T, GENERIC_WILDCARD, ID, ITERABLE_T, ITERABLE_T_ENTITIES, LIST_T, LIST_T_ENTITIES, NUMBER, OBJECT, T, T_ENTITYModifier and TypeFieldDescriptionprotected static final TypeNameBigDecimaltype.protected static final TypeNameBigIntegertype.protected static final TypeNameType of theClass<?>.protected static final StringLocal entities Collection variable.protected static final StringLocal entity variable.protected static final StringLocal executor variable.protected static final StringName of the generic typeT.protected static final StringName of the generic type?.protected static final StringLocal id variable.protected static final TypeNameType of theIterable<T>.protected static final ParameterIterable<T> entitiesmethod parameter.protected static final TypeNameType of theList<T>.protected static final ParameterList<T> entitiesmethod parameter.protected static final TypeNameNumbertype.protected static final TypeNameType of theObject.protected static final TypeNameType of the generic typeT.protected static final ParameterT entitymethod parameter. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseRepositoryMethodsGenerator(RepositoryInfo repositoryInfo, ClassModel.Builder classModel, CodegenContext codegenContext, PersistenceGenerator persistenceGenerator) Creates an instance of data repository interface code generator base class for methods generators. -
Method Summary
Modifier and TypeMethodDescriptionprotected MethodParamsgenerateHeader(Method.Builder builder, TypedElementInfo methodInfo) Generate method header matching interface prototype and return method parameters.protected static TypeNamegenericReturnTypeArgument(TypedElementInfo methodInfo) protected static booleanisListOrCollection(TypeName typeName) protected static booleanCheck whether providedTypeNameisio.helidon.data.Page.protected static booleanCheck whether providedTypeNameisio.helidon.data.Slice.protected static booleanisSliceOrPage(TypeName typeName) protected static booleanprotected static StringparamElementName(TypedElementInfo param) Retrieve name of the method parameter from providedTypedElementInfoparam.protected abstract voidprocessParam(MethodParams.Builder builder, TypedElementInfo paramInfo) Process method parameter.Methods inherited from class BaseRepositoryInterfaceGenerator
call, classModel, codegenContext, extendsType, methodWarning, optionalFromQuery, optionalOfNullable, persistenceGenerator, queryBuilder, repositoryInfo, run, statementGeneratorModifier and TypeMethodDescriptionprotected static voidcall(Method.Builder builder, Consumer<Method.Builder> content, String identifier) GenerateCallablecall.protected ClassModel.BuilderTarget implementing class model builder.protected CodegenContextCode processing and generation context.protected static TypeArgumentextendsType(String type, TypeName extended) Generate<type> extends <extended>generic type.protected voidmethodWarning(TypedElementInfo methodInfo, String message) Log method generation warning.protected static voidoptionalFromQuery(Method.Builder builder, Consumer<Method.Builder> content, TypeName executorType) Generate<T> Optional<T> RepositoryExecutor#optionalFromQuery(List<T>)call.protected static voidoptionalOfNullable(Method.Builder builder, Consumer<Method.Builder> content) GenerateOptional.ofNullable(Object)call.protected PersistenceGeneratorSpecific persistence provider generator.protected PersistenceGenerator.QueryBuilderQuery code builder from persistence provider generator.protected RepositoryInfoData repository interface info.protected static voidrun(Method.Builder builder, Consumer<Method.Builder> content, String identifier) GenerateRunnablerun.protected PersistenceGenerator.StatementGeneratorPersistence provider specific code snippets generator.Methods inherited from class BaseGenerator
decreasePadding, identifier, increasePadding, initializedVariable, nullValue, returnStatement, statement, throwException, throwException, valueModifier and TypeMethodDescriptionprotected static voiddecreasePadding(Method.Builder builder, int count) Decrease padding.protected static voididentifier(Method.Builder builder, String identifier) Generate identifier.protected static voidincreasePadding(Method.Builder builder, int count) Increase padding.protected static voidinitializedVariable(Method.Builder builder, TypeName type, String name, Consumer<Method.Builder> value) Generate initialized variable.protected static voidnullValue(Method.Builder builder) Generatenullvalue.protected static voidreturnStatement(Method.Builder builder, Consumer<Method.Builder> content) Generate return statement.protected static voidstatement(Method.Builder builder, Consumer<Method.Builder> content) Generate statement.protected static voidthrowException(Method.Builder builder, TypeName type, String message) Generatethrow new <type>(<message>)for an exception.protected static voidthrowException(Method.Builder builder, TypeName type, Consumer<Method.Builder> message) Generatethrow new <type>(<message>)for an exception.protected static voidvalue(Method.Builder builder, String value) Generate value.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface RepositoryInterfaceGenerator
generate
-
Constructor Details
-
BaseRepositoryMethodsGenerator
protected BaseRepositoryMethodsGenerator(RepositoryInfo repositoryInfo, ClassModel.Builder classModel, CodegenContext codegenContext, PersistenceGenerator persistenceGenerator) Creates an instance of data repository interface code generator base class for methods generators.- Parameters:
repositoryInfo- data repository interface infoclassModel- target class buildercodegenContext- code processing and generation contextpersistenceGenerator- persistence provider specific generator
-
-
Method Details
-
genericReturnTypeArgument
ExtractTypeNameof generic argument from providedTypedElementInfomethodInforeturn type. Retrieves generic argument from single generic argument types likeListorStream- Parameters:
methodInfo- method info- Returns:
TypeNameof generic argument
-
isListOrCollection
- Parameters:
typeName- type to check- Returns:
- value of
truewhen providedTypeNameisListorCollection, value offalseotherwise
-
isStream
-
isSlice
-
isPage
-
isSliceOrPage
-
paramElementName
Retrieve name of the method parameter from providedTypedElementInfoparam.- Parameters:
param- method parameter info- Returns:
- name of the method parameter
-
generateHeader
Generate method header matching interface prototype and return method parameters.- Parameters:
builder- method buildermethodInfo- method info- Returns:
- method parameters
-
processParam
Process method parameter. Extending class must implement this method to properly handle each parameter of the generated method.- Parameters:
builder- method builderparamInfo- method parameter info
-