Class GeneratorRegistry.Builder

java.lang.Object
io.bloviate.ext.GeneratorRegistry.Builder
Enclosing class:
GeneratorRegistry

public static final class GeneratorRegistry.Builder extends Object
Builds an immutable GeneratorRegistry. Registration methods may be called in any order and any number of times; register* methods return this for chaining.

Within a single matcher kind, later registrations win for vendor type names and JDBCTypes (last-write replaces), while column-name patterns preserve registration order (first match wins at resolution time).

  • Constructor Details

    • Builder

      public Builder()
      Creates an empty builder with no rules registered.
  • Method Details

    • registerColumnNamePattern

      public GeneratorRegistry.Builder registerColumnNamePattern(String regex, GeneratorFactory factory)
      Registers a generator for columns whose name matches the given regular expression. Matching is full (Matcher.matches()) and case-insensitive — use "email" or ".*_email" rather than relying on substring search. Patterns are evaluated in registration order; the first match wins.
      Parameters:
      regex - the column-name pattern (full-match, case-insensitive)
      factory - the generator factory to use on a match
      Returns:
      this builder
    • registerTypeName

      public GeneratorRegistry.Builder registerTypeName(String typeName, GeneratorFactory factory)
      Registers a generator for columns whose database-specific type name equals the given value, ignoring case (e.g. "uuid", "jsonb").
      Parameters:
      typeName - the vendor type name to match
      factory - the generator factory to use on a match
      Returns:
      this builder
    • registerJdbcType

      public GeneratorRegistry.Builder registerJdbcType(JDBCType jdbcType, GeneratorFactory factory)
      Registers a generator override for a JDBCType. This takes precedence over the built-in DatabaseSupport default for that type.
      Parameters:
      jdbcType - the JDBC type to match
      factory - the generator factory to use on a match
      Returns:
      this builder
    • register

      public GeneratorRegistry.Builder register(GeneratorPlugin plugin)
      Applies a GeneratorPlugin immediately, letting it register rules at this point in the builder chain.
      Parameters:
      plugin - the plugin to apply
      Returns:
      this builder
    • discover

      public GeneratorRegistry.Builder discover()
      Discovers and applies every GeneratorPlugin visible to the current thread's context class loader via ServiceLoader. Discovery order is not specified by ServiceLoader; call this where you want discovered rules to apply relative to your explicit registrations.
      Returns:
      this builder
    • build

      public GeneratorRegistry build()
      Builds the registry from the rules registered so far.
      Returns:
      an immutable registry holding the rules registered so far