Class DispatchWriter
java.lang.Object
io.micronaut.inject.writer.DispatchWriter
- All Implemented Interfaces:
ClassOutputWriter
@Internal
@NullUnmarked
public final class DispatchWriter
extends Object
implements ClassOutputWriter
Switch based dispatch writer.
- Since:
- 4.7
- Author:
- Denis Stepanov
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDispatch target implementation writer.static interfaceDispatch target implementation writer.static final classField get dispatch target.static final classField get dispatch target.static final classField set dispatch target.static final classField set dispatch target.static final classInterceptable method invocation dispatch target.static final classMethod invocation dispatch target.static final classMethod invocation dispatch target.static final classMethod invocation dispatch target. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(ClassWriterOutputVisitor classWriterOutputVisitor) Accept a ClassWriterOutputVisitor to write this writer to disk.intaddDispatchTarget(DispatchWriter.DispatchTarget dispatchTarget) Adds new custom dispatch target.intaddGetField(FieldElement beanField) Adds new get field dispatch target.intaddMethod(TypedElement declaringType, MethodElement methodElement) Adds new method dispatch target.intaddMethod(TypedElement declaringType, MethodElement methodElement, boolean useOneDispatch) Adds new method dispatch target.intaddOrGetInterceptedMethod(TypedElement declaringType, MethodElement methodElement, MethodElement proxyMethod) Ensures an intercepted dispatch entry exists for the given method and returns its index.intaddOrGetMethod(TypedElement declaringType, MethodElement methodElement) Ensures a dispatch target exists for the given method and returns its index.intaddSetField(FieldElement beanField) Adds new set field dispatch target.@Nullable io.micronaut.sourcegen.model.MethodDefio.micronaut.sourcegen.model.MethodDefbuildDispatchMethod(io.micronaut.sourcegen.model.ClassTypeDef interceptedProxy, io.micronaut.sourcegen.model.FieldDef interceptableField) @Nullable io.micronaut.sourcegen.model.MethodDef@Nullable io.micronaut.sourcegen.model.MethodDef@Nullable io.micronaut.sourcegen.model.MethodDef@Nullable io.micronaut.sourcegen.model.MethodDefbuildPrimitiveGetMethod(String methodName, io.micronaut.sourcegen.model.TypeDef.Primitive primitiveType) @Nullable io.micronaut.sourcegen.model.MethodDefbuildPrimitiveSetMethod(String methodName, io.micronaut.sourcegen.model.TypeDef.Primitive primitiveType) @Nullable io.micronaut.sourcegen.model.MethodDefbuildPrimitiveSetVoidMethod(String methodName, io.micronaut.sourcegen.model.TypeDef.Primitive primitiveType) intfindMethodIndex(MethodElement methodElement) Finds the dispatch index for the given method.static io.micronaut.sourcegen.model.ExpressionDefgetTypeUtilsGetRequiredMethod(io.micronaut.sourcegen.model.ClassTypeDef declaringType, MethodElement methodElement) boolean
-
Constructor Details
-
DispatchWriter
-
-
Method Details
-
addSetField
Adds new set field dispatch target.- Parameters:
beanField- The field- Returns:
- the target index
-
addGetField
Adds new get field dispatch target.- Parameters:
beanField- The field- Returns:
- the target index
-
addMethod
Adds new method dispatch target.- Parameters:
declaringType- The declaring typemethodElement- The method element- Returns:
- the target index
-
addMethod
public int addMethod(TypedElement declaringType, MethodElement methodElement, boolean useOneDispatch) Adds new method dispatch target.- Parameters:
declaringType- The declaring typemethodElement- The method elementuseOneDispatch- If method should be dispatched using "dispatchOne"- Returns:
- the target index
-
addOrGetMethod
Ensures a dispatch target exists for the given method and returns its index.- Parameters:
declaringType- The declaring typemethodElement- The method element- Returns:
- The dispatch index
-
addOrGetInterceptedMethod
public int addOrGetInterceptedMethod(TypedElement declaringType, MethodElement methodElement, MethodElement proxyMethod) Ensures an intercepted dispatch entry exists for the given method and returns its index.- Parameters:
declaringType- The declaring typemethodElement- The method elementproxyMethod- The proxyMethod- Returns:
- The dispatch index for the intercepted entry
-
addDispatchTarget
Adds new custom dispatch target.- Parameters:
dispatchTarget- The dispatch target implementation- Returns:
- the target index
-
buildDispatchMethod
public io.micronaut.sourcegen.model.MethodDef buildDispatchMethod(io.micronaut.sourcegen.model.ClassTypeDef interceptedProxy, io.micronaut.sourcegen.model.FieldDef interceptableField) -
buildDispatchMethod
public @Nullable io.micronaut.sourcegen.model.MethodDef buildDispatchMethod() -
buildDispatchOneMethod
public @Nullable io.micronaut.sourcegen.model.MethodDef buildDispatchOneMethod() -
buildDispatchOneVoidMethod
public @Nullable io.micronaut.sourcegen.model.MethodDef buildDispatchOneVoidMethod() -
buildPrimitiveGetMethod
public @Nullable io.micronaut.sourcegen.model.MethodDef buildPrimitiveGetMethod(String methodName, io.micronaut.sourcegen.model.TypeDef.Primitive primitiveType) -
buildPrimitiveSetMethod
public @Nullable io.micronaut.sourcegen.model.MethodDef buildPrimitiveSetMethod(String methodName, io.micronaut.sourcegen.model.TypeDef.Primitive primitiveType) -
buildPrimitiveSetVoidMethod
public @Nullable io.micronaut.sourcegen.model.MethodDef buildPrimitiveSetVoidMethod(String methodName, io.micronaut.sourcegen.model.TypeDef.Primitive primitiveType) -
buildGetTargetMethodByIndex
public @Nullable io.micronaut.sourcegen.model.MethodDef buildGetTargetMethodByIndex() -
getTypeUtilsGetRequiredMethod
public static io.micronaut.sourcegen.model.ExpressionDef getTypeUtilsGetRequiredMethod(io.micronaut.sourcegen.model.ClassTypeDef declaringType, MethodElement methodElement) -
accept
Description copied from interface:ClassOutputWriterAccept a ClassWriterOutputVisitor to write this writer to disk.- Specified by:
acceptin interfaceClassOutputWriter- Parameters:
classWriterOutputVisitor- TheClassWriterOutputVisitor- Throws:
IOException- if there is an error writing to disk
-
getDispatchTargets
- Returns:
- all added dispatch targets
-
findMethodIndex
Finds the dispatch index for the given method.- Parameters:
methodElement- The method element- Returns:
- The dispatch index or -1 if not tracked
-
isHasInterceptedMethod
public boolean isHasInterceptedMethod()- Returns:
- if intercepted method dispatch have been added
-