Class BaseRepositoryInterfaceGenerator
java.lang.Object
io.helidon.data.codegen.common.BaseGenerator
io.helidon.data.codegen.common.BaseRepositoryInterfaceGenerator
- All Implemented Interfaces:
RepositoryInterfaceGenerator
- Direct Known Subclasses:
BaseRepositoryMethodsGenerator
public abstract class BaseRepositoryInterfaceGenerator
extends BaseGenerator
implements RepositoryInterfaceGenerator
Data repository interface code generator base class.
-
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
ConstructorsModifierConstructorDescriptionprotectedBaseRepositoryInterfaceGenerator(RepositoryInfo repositoryInfo, ClassModel.Builder classModel, CodegenContext codegenContext, PersistenceGenerator persistenceGenerator) Creates an instance of data repository interface code generator base class. -
Method Summary
Modifier 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
-
BaseRepositoryInterfaceGenerator
protected BaseRepositoryInterfaceGenerator(RepositoryInfo repositoryInfo, ClassModel.Builder classModel, CodegenContext codegenContext, PersistenceGenerator persistenceGenerator) Creates an instance of data repository interface code generator base class.- Parameters:
repositoryInfo- data repository interface infoclassModel- target class buildercodegenContext- code processing and generation contextpersistenceGenerator- persistence provider specific generator
-
-
Method Details
-
optionalOfNullable
GenerateOptional.ofNullable(Object)call.- Parameters:
builder- method buildercontent- additional statement content
-
optionalFromQuery
protected static void optionalFromQuery(Method.Builder builder, Consumer<Method.Builder> content, TypeName executorType) Generate<T> Optional<T> RepositoryExecutor#optionalFromQuery(List<T>)call. This is Jakarta Persistence 3.1 workaround until this line can use Jakarta Persistence 3.2 item-or-null APIs.- Parameters:
builder- method buildercontent- additional statement contentexecutorType- repository executor type
-
call
protected static void call(Method.Builder builder, Consumer<Method.Builder> content, String identifier) GenerateCallablecall.- Parameters:
builder- method buildercontent- additional statement contentidentifier-Callableinstance identifier
-
run
protected static void run(Method.Builder builder, Consumer<Method.Builder> content, String identifier) GenerateRunnablerun.- Parameters:
builder- method buildercontent- additional statement contentidentifier-Callableinstance identifier
-
extendsType
Generate<type> extends <extended>generic type.- Parameters:
type- extending typeextended- type being extended- Returns:
extendsgeneric type
-
repositoryInfo
Data repository interface info.- Returns:
- data repository interface descriptor
-
classModel
Target implementing class model builder.- Returns:
- class model builder
-
codegenContext
Code processing and generation context.- Returns:
- codegen context
-
persistenceGenerator
Specific persistence provider generator. Repository interface implementing class is defined byPersistenceGeneratorbut it content (e.g. implemented data repository interfaces) are defined byRepositoryGeneratorwhich holds individual instances ofRepositoryInterfaceGeneratorclasses.PersistenceGeneratorprovides persistence provider specific code for data repository interface implementing code.- Returns:
- persistence provider generator
-
queryBuilder
Query code builder from persistence provider generator.- Returns:
- query code builder
-
statementGenerator
Persistence provider specific code snippets generator.- Returns:
- code snippets generator
-
methodWarning
Log method generation warning.- Parameters:
methodInfo- method infomessage- warning message
-