Class RoutineReflection

java.lang.Object
no.sikt.graphitron.mappings.SchemaReflection
no.sikt.graphitron.mappings.RoutineReflection

public class RoutineReflection extends SchemaReflection
Helper class that takes care of any routine reflection operations the code generator might require towards the jOOQ source. Discovers and provides access to stored procedures and functions generated by jOOQ.

Routines are keyed internally by a schema-qualified name (schema.SimpleClassName, lowercased) so that routines with the same name in different database schemas do not collide.

  • Constructor Details

    • RoutineReflection

      public RoutineReflection()
  • Method Details

    • resolveRoutine

      public static List<String> resolveRoutine(String userSuppliedName)
      Resolves a user-supplied routine name against the discovered routines, returning the list of matching qualified keys (schema.SimpleClassName, lowercased). The name may be bare (foo) or schema-qualified (my_schema.foo). Matching is case-insensitive.

      An empty list means no match; a single entry is unambiguous; multiple entries indicate the bare name is ambiguous across schemas and the caller must disambiguate.

    • schemaFromProcedure

      public static String schemaFromProcedure(String qualifiedProcedure)
      Returns the schema portion of a qualified routine key (the part before the dot).
    • isFunction

      public static boolean isFunction(String qualifiedKey)
      Returns:
      Whether the routine is a function (has a return).
    • getInParameters

      public static List<org.jooq.Parameter<?>> getInParameters(String qualifiedKey)
      Returns:
      The IN parameters of the routine (excluding return).
    • getOutParameters

      public static List<org.jooq.Parameter<?>> getOutParameters(String qualifiedKey)
      Returns:
      The OUT parameters of the routine (excluding return).
    • getReturnType

      public static Optional<Class<?>> getReturnType(String qualifiedKey)
      Returns:
      The Java return type of the routine, if it is a function.
    • getRoutinesClassName

      public static Optional<String> getRoutinesClassName(String qualifiedKey)
      Derives the fully qualified name of the generated Routines class that holds the convenience static methods for the given routine. The class lives one package up from the individual routine class (the schema package).

      Assumes the jOOQ convention where each routine class lives at <schema>.routines.XYZ; a routine placed directly in the schema package would cause this to derive an incorrect parent package.

      Returns:
      The fully qualified class name of Routines, or empty if no such routine exists.
    • getRoutineMethodName

      public static Optional<String> getRoutineMethodName(String qualifiedKey)
      Derives the name of the convenience static method on the generated Routines class for a given routine. jOOQ emits the method as a camelCased version of the routine's Java class name (e.g. InventoryHeldByCustomer becomes inventoryHeldByCustomer, and _GroupConcat becomes _GroupConcat).
      Returns:
      The method name on the generated Routines class, or empty if no such routine exists.