Package com.strobel.reflection.emit
Class MethodBuilder
- java.lang.Object
-
- com.strobel.reflection.MemberInfo
-
- com.strobel.reflection.MethodBase
-
- com.strobel.reflection.MethodInfo
-
- com.strobel.reflection.emit.MethodBuilder
-
- All Implemented Interfaces:
java.lang.reflect.AnnotatedElement
public final class MethodBuilder extends MethodInfo
-
-
Field Summary
Fields Modifier and Type Field Description private ReadOnlyList<AnnotationBuilder<? extends java.lang.annotation.Annotation>>
_annotations
private byte[]
_body
private TypeBuilder<?>
_declaringType
private java.lang.Object
_defaultValue
private __ExceptionInstance[]
_exceptions
private boolean
_isFinished
private int
_modifiers
private java.lang.String
_name
private int
_numberOfExceptions
private SignatureType
_signatureType
private TypeList
_thrownTypes
(package private) MethodInfo
generatedMethod
(package private) CodeGenerator
generator
(package private) GenericParameterBuilder<?>[]
genericParameterBuilders
(package private) ParameterBuilder[]
parameterBuilders
-
Fields inherited from class com.strobel.reflection.MethodInfo
_erasedMethodDefinition
-
-
Constructor Summary
Constructors Constructor Description MethodBuilder(java.lang.String name, int modifiers, Type<?> returnType, TypeList parameterTypes, TypeList thrownTypes, TypeBuilder<?> declaringType)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <A extends java.lang.annotation.Annotation>
voidaddCustomAnnotation(AnnotationBuilder<A> annotation)
java.lang.StringBuilder
appendDescription(java.lang.StringBuilder sb)
java.lang.StringBuilder
appendErasedSignature(java.lang.StringBuilder sb)
java.lang.StringBuilder
appendSignature(java.lang.StringBuilder sb)
java.lang.StringBuilder
appendSimpleDescription(java.lang.StringBuilder sb)
private static int
calculateNumberOfExceptions(__ExceptionInfo[] exceptions)
void
createMethodBody(byte[] bytecode, int size)
(package private) void
createMethodBodyHelper(CodeGenerator code)
(package private) ParameterList
createParameters()
GenericParameterBuilder<?>[]
defineGenericParameters(java.lang.String... names)
ParameterBuilder
defineParameter(int position, java.lang.String name)
<T extends java.lang.annotation.Annotation>
TgetAnnotation(java.lang.Class<T> annotationClass)
java.lang.annotation.Annotation[]
getAnnotations()
(package private) byte[]
getBody()
CodeGenerator
getCodeGenerator()
CodeGenerator
getCodeGenerator(int initialSize)
ReadOnlyList<AnnotationBuilder<? extends java.lang.annotation.Annotation>>
getCustomAnnotations()
java.lang.annotation.Annotation[]
getDeclaredAnnotations()
TypeBuilder<?>
getDeclaringType()
java.lang.Object
getDefaultValue()
java.util.List<ParameterBuilder>
getDefinedParameters()
MethodInfo
getErasedMethodDefinition()
(package private) __ExceptionInstance[]
getExceptionInstances()
TypeList
getGenericMethodParameters()
int
getModifiers()
java.lang.String
getName()
(package private) int
getNumberOfExceptions()
ParameterList
getParameters()
TypeList
getParameterTypes()
java.lang.reflect.Method
getRawMethod()
Type<?>
getReflectedType()
Type<?>
getReturnType()
SignatureType
getSignatureType()
TypeList
getThrownTypes()
boolean
isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
boolean
isFinished()
boolean
isGenericMethod()
boolean
isGenericMethodDefinition()
boolean
isTypeCreated()
(package private) void
releaseBakedStructures()
void
setDefaultValue(java.lang.Object value)
void
setParameters(TypeList types)
void
setReturnType(Type<?> type)
void
setSignature(Type<?> returnType, TypeList parameterTypes)
void
setThrownTypes(TypeList types)
(package private) void
verifyCodeGeneratorNotCreated()
(package private) void
verifyNotAbstract()
(package private) void
verifyNotGeneric()
-
Methods inherited from class com.strobel.reflection.MethodInfo
appendBriefDescription, appendErasedDescription, appendModifiers, containsGenericParameter, containsGenericParameters, emptyMethods, findBaseMethod, findOverriddenMethod, getGenericMethodDefinition, getMemberType, getTypeArguments, getTypeBindings, invoke, isAbstract, isDefault, isEquivalentTo, makeGenericMethod, makeGenericMethod
-
Methods inherited from class com.strobel.reflection.MethodBase
getCallingConvention
-
Methods inherited from class com.strobel.reflection.MemberInfo
appendGenericSignature, emptyAnnotations, equals, getAnnotationsByType, getBriefDescription, getDeclaredAnnotation, getDeclaredAnnotationsByType, getDescription, getErasedDescription, getErasedSignature, getSignature, getSimpleDescription, hashCode, invalidateCaches, isFinal, isNonPublic, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic, toString
-
-
-
-
Field Detail
-
_name
private final java.lang.String _name
-
_declaringType
private final TypeBuilder<?> _declaringType
-
_modifiers
private final int _modifiers
-
_signatureType
private SignatureType _signatureType
-
_thrownTypes
private TypeList _thrownTypes
-
_isFinished
private boolean _isFinished
-
_annotations
private ReadOnlyList<AnnotationBuilder<? extends java.lang.annotation.Annotation>> _annotations
-
_body
private byte[] _body
-
_numberOfExceptions
private int _numberOfExceptions
-
_exceptions
private __ExceptionInstance[] _exceptions
-
_defaultValue
private java.lang.Object _defaultValue
-
genericParameterBuilders
GenericParameterBuilder<?>[] genericParameterBuilders
-
parameterBuilders
ParameterBuilder[] parameterBuilders
-
generator
CodeGenerator generator
-
generatedMethod
MethodInfo generatedMethod
-
-
Constructor Detail
-
MethodBuilder
MethodBuilder(java.lang.String name, int modifiers, Type<?> returnType, TypeList parameterTypes, TypeList thrownTypes, TypeBuilder<?> declaringType)
-
-
Method Detail
-
verifyNotGeneric
void verifyNotGeneric()
-
verifyNotAbstract
void verifyNotAbstract()
-
getCodeGenerator
public CodeGenerator getCodeGenerator()
-
getCodeGenerator
public CodeGenerator getCodeGenerator(int initialSize)
-
getName
public java.lang.String getName()
- Overrides:
getName
in classMethodInfo
-
getReturnType
public Type<?> getReturnType()
- Specified by:
getReturnType
in classMethodInfo
-
getSignatureType
public SignatureType getSignatureType()
- Specified by:
getSignatureType
in classMethodBase
-
getRawMethod
public java.lang.reflect.Method getRawMethod()
- Specified by:
getRawMethod
in classMethodInfo
-
getDefaultValue
public java.lang.Object getDefaultValue()
- Overrides:
getDefaultValue
in classMethodInfo
-
setDefaultValue
public void setDefaultValue(java.lang.Object value)
-
getDeclaringType
public TypeBuilder<?> getDeclaringType()
- Specified by:
getDeclaringType
in classMemberInfo
-
getModifiers
public int getModifiers()
- Specified by:
getModifiers
in classMemberInfo
-
getParameters
public ParameterList getParameters()
- Overrides:
getParameters
in classMethodBase
-
createParameters
ParameterList createParameters()
-
getThrownTypes
public TypeList getThrownTypes()
- Overrides:
getThrownTypes
in classMethodBase
-
getParameterTypes
public TypeList getParameterTypes()
-
getDefinedParameters
public java.util.List<ParameterBuilder> getDefinedParameters()
-
isTypeCreated
public boolean isTypeCreated()
-
isFinished
public boolean isFinished()
-
setReturnType
public void setReturnType(Type<?> type)
-
verifyCodeGeneratorNotCreated
void verifyCodeGeneratorNotCreated()
-
setParameters
public void setParameters(TypeList types)
-
setThrownTypes
public void setThrownTypes(TypeList types)
-
getReflectedType
public Type<?> getReflectedType()
- Overrides:
getReflectedType
in classMemberInfo
-
addCustomAnnotation
public <A extends java.lang.annotation.Annotation> void addCustomAnnotation(AnnotationBuilder<A> annotation)
-
getCustomAnnotations
public ReadOnlyList<AnnotationBuilder<? extends java.lang.annotation.Annotation>> getCustomAnnotations()
-
getAnnotation
public <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.Class<T> annotationClass)
- Specified by:
getAnnotation
in interfacejava.lang.reflect.AnnotatedElement
- Overrides:
getAnnotation
in classMethodInfo
-
getAnnotations
@NotNull public java.lang.annotation.Annotation[] getAnnotations()
- Specified by:
getAnnotations
in interfacejava.lang.reflect.AnnotatedElement
- Overrides:
getAnnotations
in classMethodInfo
-
getDeclaredAnnotations
@NotNull public java.lang.annotation.Annotation[] getDeclaredAnnotations()
- Specified by:
getDeclaredAnnotations
in interfacejava.lang.reflect.AnnotatedElement
- Overrides:
getDeclaredAnnotations
in classMethodInfo
-
isAnnotationPresent
public boolean isAnnotationPresent(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
- Specified by:
isAnnotationPresent
in interfacejava.lang.reflect.AnnotatedElement
- Overrides:
isAnnotationPresent
in classMethodInfo
-
isGenericMethod
public boolean isGenericMethod()
- Overrides:
isGenericMethod
in classMethodInfo
-
isGenericMethodDefinition
public boolean isGenericMethodDefinition()
- Overrides:
isGenericMethodDefinition
in classMethodInfo
-
getGenericMethodParameters
public TypeList getGenericMethodParameters()
- Overrides:
getGenericMethodParameters
in classMethodInfo
-
getErasedMethodDefinition
public MethodInfo getErasedMethodDefinition()
- Overrides:
getErasedMethodDefinition
in classMethodInfo
-
appendDescription
public java.lang.StringBuilder appendDescription(java.lang.StringBuilder sb)
- Overrides:
appendDescription
in classMethodInfo
-
appendSimpleDescription
public java.lang.StringBuilder appendSimpleDescription(java.lang.StringBuilder sb)
- Overrides:
appendSimpleDescription
in classMethodInfo
-
appendErasedSignature
public java.lang.StringBuilder appendErasedSignature(java.lang.StringBuilder sb)
- Overrides:
appendErasedSignature
in classMethodInfo
-
appendSignature
public java.lang.StringBuilder appendSignature(java.lang.StringBuilder sb)
- Overrides:
appendSignature
in classMethodInfo
-
defineGenericParameters
public GenericParameterBuilder<?>[] defineGenericParameters(java.lang.String... names)
-
defineParameter
public ParameterBuilder defineParameter(int position, java.lang.String name)
-
createMethodBody
public void createMethodBody(byte[] bytecode, int size)
-
getBody
byte[] getBody()
-
getExceptionInstances
__ExceptionInstance[] getExceptionInstances()
-
getNumberOfExceptions
int getNumberOfExceptions()
-
createMethodBodyHelper
void createMethodBodyHelper(CodeGenerator code)
-
calculateNumberOfExceptions
private static int calculateNumberOfExceptions(__ExceptionInfo[] exceptions)
-
releaseBakedStructures
void releaseBakedStructures()
-
-