Documentation
¶
Index ¶
- func AsArray(t java.JavaType) *java.JavaTypeArray
- func AsClass(t java.JavaType) *java.JavaTypeClass
- func AsMethod(t java.JavaType) *java.JavaTypeMethod
- func DeclaringTypeFQN(mi *java.MethodInvocation) string
- func GetFullyQualifiedName(t java.JavaType) string
- func Implements(t java.JavaType, interfaceFQN string) bool
- func IsAssignableTo(t java.JavaType, fqn string) bool
- func IsBool(t java.JavaType) bool
- func IsError(t java.JavaType) bool
- func IsNumeric(t java.JavaType) bool
- func IsOfClassType(t java.JavaType, fqn string) bool
- func IsString(t java.JavaType) bool
- func TypeOfExpression(expr java.Expression) java.JavaType
- type MethodMatcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsArray ¶
func AsArray(t java.JavaType) *java.JavaTypeArray
AsArray safely casts a JavaType to *JavaTypeArray, returning nil if not an array.
func AsClass ¶
func AsClass(t java.JavaType) *java.JavaTypeClass
AsClass safely casts a JavaType to *JavaTypeClass, returning nil if not a class. A JavaTypeShallowClass is unwrapped to its embedded JavaTypeClass — callers that need to distinguish ShallowClass from Class should type switch on the original JavaType, not on this accessor's result.
func AsMethod ¶
func AsMethod(t java.JavaType) *java.JavaTypeMethod
AsMethod safely casts a JavaType to *JavaTypeMethod, returning nil if not a method.
func DeclaringTypeFQN ¶
func DeclaringTypeFQN(mi *java.MethodInvocation) string
DeclaringTypeFQN extracts the declaring type's FQN from a MethodInvocation. For `fmt.Println(...)`, this returns "fmt" (the package path). For `t.Sub(...)`, this returns the type of the receiver.
func GetFullyQualifiedName ¶
GetFullyQualifiedName extracts the FQN from a JavaType. Returns "" for nil, unknown, or types without a FQN.
func Implements ¶
Implements checks if the type implements the given interface FQN. Unlike IsAssignableTo, this returns false if the type IS the interface.
func IsAssignableTo ¶
IsAssignableTo checks if the type is assignable to the target FQN. For Go, this means the type IS the target, or the type implements an interface with that FQN (structural typing).
func IsOfClassType ¶
IsOfClassType checks if the type has the exact fully qualified name.
func TypeOfExpression ¶
func TypeOfExpression(expr java.Expression) java.JavaType
TypeOfExpression extracts the JavaType from an expression node.
Types ¶
type MethodMatcher ¶
type MethodMatcher struct {
// contains filtered or unexported fields
}
MethodMatcher matches method invocations against an AspectJ-style pattern.
Pattern format: "DeclaringType MethodName(ArgType1, ArgType2, ..)"
Examples:
- "fmt Println(..)" — fmt.Println with any args
- "fmt Sprintf(string, ..)" — first arg string, rest any
- "time.Time Sub(time.Time)" — method on time.Time
- "* Sub(..)" — any type's Sub method
- "strings Contains(string, string)" — exact match
Wildcards:
- "*" in declaring type: matches any single package/type name
- "*..*" in declaring type: matches any type in any package
- ".." in args: matches zero or more arguments of any type
func NewMethodMatcher ¶
func NewMethodMatcher(pattern string) *MethodMatcher
NewMethodMatcher creates a MethodMatcher from the given pattern string. Pattern format: "DeclaringType MethodName(ArgTypes)"
func (*MethodMatcher) Matches ¶
func (m *MethodMatcher) Matches(mi *java.MethodInvocation) bool
Matches checks if the given MethodInvocation matches this pattern.
func (*MethodMatcher) MatchesMethod ¶
func (m *MethodMatcher) MatchesMethod(mt *java.JavaTypeMethod) bool
MatchesMethod checks if a JavaTypeMethod matches this pattern.
func (*MethodMatcher) MatchesName ¶
func (m *MethodMatcher) MatchesName(mi *java.MethodInvocation) bool
MatchesName checks only the declaring type and method name, ignoring arguments. Useful as a fast pre-check before deeper matching.