Class ClassFunctionalTools

java.lang.Object
org.machanism.machai.gw.maven.tools.ClassFunctionalTools
All Implemented Interfaces:
org.machanism.machai.ai.tools.FunctionTools

public class ClassFunctionalTools extends Object implements org.machanism.machai.ai.tools.FunctionTools
Provides function-tool integrations for discovering Java classes and reading reflective metadata from the classpath of one or more Maven projects.

Instances maintain a cache of ClassInfoHolder objects keyed by Maven project base directory, allowing tool invocations to resolve classes relative to the current working project.

  • Constructor Details

    • ClassFunctionalTools

      public ClassFunctionalTools(org.apache.maven.project.MavenProject project)
      Creates a new instance backed by the supplied Maven project's classpath.
      Parameters:
      project - the Maven project used to resolve classpath and output directories
    • ClassFunctionalTools

      public ClassFunctionalTools()
      Creates an empty instance. Projects must be registered later through scanProjectClasses(MavenProject) before tool invocations can resolve class information.
  • Method Details

    • scanProjectClasses

      public void scanProjectClasses(org.apache.maven.project.MavenProject project)
      Registers a project by scanning and caching class metadata for its base directory.
      Parameters:
      project - the Maven project to register
    • findClass

      public String findClass(String className, File projectDir)
      Finds fully qualified class names whose simple names match the supplied regular expression.
    • getClassInfo

      public Map<String,Object> getClassInfo(String className, File projectDir)
      Returns reflective information for the specified class.

      The generated output may include modifiers, superclass, interfaces, non-private fields, constructors, non-private methods, annotations, class path, and dependency artifact coordinates.

      Parameters:
      params - tool invocation arguments; the first argument is expected to be a HashMap containing a className property and the second a File representing the current working directory
      Returns:
      a HashMap describing the requested class or containing an error property when the class or project context cannot be resolved