Class ReflectionHelpers

java.lang.Object
no.sikt.graphitron.mappings.ReflectionHelpers

public class ReflectionHelpers extends Object
Helper class that takes care of any reflection operations the code generator might require.
  • Constructor Details

    • ReflectionHelpers

      public ReflectionHelpers()
  • Method Details

    • classHasMethod

      public static boolean classHasMethod(Class<?> reference, String methodName)
      Returns:
      Does this jOOQ table contain this method name?
    • getJooqRecordClassReturnedFromFieldGetter

      public static Optional<Class<? extends org.jooq.impl.UpdatableRecordImpl<?>>> getJooqRecordClassReturnedFromFieldGetter(Class<?> recordClass, String fieldName)
      Gets the jOOQ record class for a field in a Java record class.
      Parameters:
      recordClass - The Java record class to inspect
      fieldName - The field name to get type for
      Returns:
      The jOOQ record class, or null if not a jOOQ record type
    • setterAcceptsOptional

      public static boolean setterAcceptsOptional(Class<?> recordClass, String setterName)
      Checks whether a setter method on the given class accepts an Optional parameter.
      Parameters:
      recordClass - The POJO class to inspect
      setterName - The setter method name (e.g., "setRentalDuration")
      Returns:
      true if the setter's first parameter is Optional
    • getJooqRecordClassForNodeIdInputField

      public static Optional<Class<? extends org.jooq.impl.UpdatableRecordImpl<?>>> getJooqRecordClassForNodeIdInputField(GenerationField field, ProcessedSchema schema)
      Gets the jOOQ record class that a @nodeId field should produce. Uses reflection on the Java record class to get the target field's type.
      Parameters:
      field - The @nodeId field
      Returns:
      The jOOQ record class, or null if the field is not targeting a jOOQ record field
    • methodExpectsTableRecordParamAtIndex

      public static boolean methodExpectsTableRecordParamAtIndex(Method method, int paramIndex)
      Checks whether the parameter at the given index of method is a jOOQ table record type — either an UpdatableRecordImpl subtype or a List<X> where X is one.
      Parameters:
      method - The method to inspect.
      paramIndex - Zero-based index of the parameter to check.
      Returns:
      true if the parameter is a jOOQ table record (singular or listed); false for any other shape (raw types, arrays, Collection, generic wildcards, etc.).