Package io.permazen

Class PermazenConfig.Builder

java.lang.Object
io.permazen.PermazenConfig.Builder
All Implemented Interfaces:
Cloneable
Enclosing class:
PermazenConfig

public static final class PermazenConfig.Builder extends Object implements Cloneable
Builder for PermazenConfigs.
  • Method Details

    • database

      public PermazenConfig.Builder database(Database database)
      Configure the underlying Database.

      By default an initially empty, in-memory MemoryKVDatabase is used.

      Parameters:
      database - core API database to use
      Returns:
      this instance
    • validatorFactory

      public PermazenConfig.Builder validatorFactory(jakarta.validation.ValidatorFactory validatorFactory)
      Configure a custom ValidatorFactory used to create Validators for validation within transactions.

      The default is to use the result from Validation.buildDefaultValidatorFactory().

      Parameters:
      validatorFactory - factory for validators, or null for the default
      Returns:
      this instance
    • modelClasses

      public PermazenConfig.Builder modelClasses(Iterable<Class<?>> modelClasses)
      Configure the Java model classes via iteration.

      Note: @PermazenType-annotated super-types of any class in modelClasses will be included, even if the super-type is not explicitly specified in modelClasses.

      Parameters:
      modelClasses - classes annotated with @PermazenType annotations
      Returns:
      this instance
      Throws:
      IllegalArgumentException - if modelClasses is null or contains a null class
    • modelClasses

      public PermazenConfig.Builder modelClasses(Class<?>... modelClasses)
      Configure the Java model classes from an array.

      Note: @PermazenType-annotated super-types of any class in modelClasses will be included, even if the super-type is not explicitly specified in modelClasses.

      Parameters:
      modelClasses - classes annotated with @PermazenType annotations
      Returns:
      this instance
      Throws:
      IllegalArgumentException - if modelClasses is null or contains a null class
    • initializeOnCreation

      public PermazenConfig.Builder initializeOnCreation(boolean initializeOnCreation)
      Configure whether the Permazen instance should initialize() automatically on instantiation.

      The default is false.

      Parameters:
      initializeOnCreation - true to initialize on instantiation, false to defer initialization
    • build

      public PermazenConfig build()
      Create a new PermazenConfig from this instance.
      Returns:
      new PermazenConfig
      Throws:
      IllegalArgumentException - if a model class has invalid annotation(s)
      InvalidSchemaException - if the schema derived from the model classes is invalid
    • clone

      public PermazenConfig.Builder clone()
      Clone this instance.
      Overrides:
      clone in class Object
      Returns:
      clone of this instance