matcher

package
v0.0.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

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

func GetFullyQualifiedName(t java.JavaType) string

GetFullyQualifiedName extracts the FQN from a JavaType. Returns "" for nil, unknown, or types without a FQN.

func Implements

func Implements(t java.JavaType, interfaceFQN string) bool

Implements checks if the type implements the given interface FQN. Unlike IsAssignableTo, this returns false if the type IS the interface.

func IsAssignableTo

func IsAssignableTo(t java.JavaType, fqn string) bool

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 IsBool

func IsBool(t java.JavaType) bool

IsBool checks if the type is the Go `bool` type.

func IsError

func IsError(t java.JavaType) bool

IsError checks if the type is the Go built-in `error` interface.

func IsNumeric

func IsNumeric(t java.JavaType) bool

IsNumeric checks if the type is a numeric type (int, float, etc.).

func IsOfClassType

func IsOfClassType(t java.JavaType, fqn string) bool

IsOfClassType checks if the type has the exact fully qualified name.

func IsString

func IsString(t java.JavaType) bool

IsString checks if the type is the Go `string` type.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL