Class DefaultDomain

java.lang.Object
is.codion.framework.domain.DefaultDomain
All Implemented Interfaces:
Domain
Direct Known Subclasses:
TestDomain

public abstract class DefaultDomain extends Object implements Domain
A default Domain implementation. Extend to define a domain model.
See Also:
  • Constructor Details

    • DefaultDomain

      protected DefaultDomain(DomainType domainType)
      Instantiates a new DefaultDomain identified by the given DomainType.
      Parameters:
      domainType - the Domain model type to associate with this domain model
  • Method Details

    • type

      public final DomainType type()
      Specified by:
      type in interface Domain
      Returns:
      the domain type identifying this domain model
    • entities

      public final Entities entities()
      Specified by:
      entities in interface Domain
      Returns:
      the Domain entities
    • reports

      public final Map<ReportType<?,?,?>,Report<?,?,?>> reports()
      Specified by:
      reports in interface Domain
      Returns:
      an unmodifiable view of this domain's reports
    • procedures

      public final Map<ProcedureType<?,?>,DatabaseProcedure<?,?>> procedures()
      Specified by:
      procedures in interface Domain
      Returns:
      an unmodifiable view of this domain's procedures
    • functions

      public final Map<FunctionType<?,?,?>,DatabaseFunction<?,?,?>> functions()
      Specified by:
      functions in interface Domain
      Returns:
      an unmodifiable view of this domain's functions
    • report

      public final <T, R, P> Report<T,R,P> report(ReportType<T,R,P> reportType)
      Description copied from interface: Domain
      Retrieves the report of the given type.
      Specified by:
      report in interface Domain
      Type Parameters:
      T - the report type
      R - the report result type
      P - the report parameters type
      Parameters:
      reportType - the report type
      Returns:
      the report
    • procedure

      public final <C, T> DatabaseProcedure<C,T> procedure(ProcedureType<C,T> procedureType)
      Description copied from interface: Domain
      Retrieves the procedure of the given type.
      Specified by:
      procedure in interface Domain
      Type Parameters:
      C - the type of the database connection this procedure requires
      T - the argument type
      Parameters:
      procedureType - the procedure type
      Returns:
      the procedure
    • function

      public final <C, T, R> DatabaseFunction<C,T,R> function(FunctionType<C,T,R> functionType)
      Description copied from interface: Domain
      Retrieves the function of the given type.
      Specified by:
      function in interface Domain
      Type Parameters:
      C - the type of the database connection this function requires
      T - the argument type
      R - the result type
      Parameters:
      functionType - the function type
      Returns:
      the function
    • add

      protected final void add(EntityDefinition.Builder definitionBuilder)
      Adds a new EntityDefinition to this domain model, by calling EntityDefinition.Builder.build(). Note that any subsequent changes in the builder are not reflected in the entity definition.
      Parameters:
      definitionBuilder - the builder which definition to add
      Throws:
      IllegalArgumentException - in case the entityType has already been used to define an entity
      IllegalArgumentException - in case no attribute definitions are specified
    • add

      protected final void add(EntityDefinition definition)
      Adds a new EntityDefinition to this domain model.
      Parameters:
      definition - the definition to add
      Throws:
      IllegalArgumentException - in case the entityType has already been used to define an entity
      IllegalArgumentException - in case no attribute definitions are specified
    • add

      protected final <T, R, P> void add(ReportType<T,R,P> reportType, Report<T,R,P> report)
      Adds a report to this domain model.
      Type Parameters:
      T - the report type
      R - the report result type
      P - the report parameters type
      Parameters:
      reportType - the report to add
      report - the actual report to associate with the report type
      Throws:
      RuntimeException - in case loading the report failed
      IllegalArgumentException - in case the report has already been added
    • add

      protected final <C, T> void add(ProcedureType<C,T> procedureType, DatabaseProcedure<C,T> procedure)
      Adds the given procedure to this domain
      Type Parameters:
      C - the connection type
      T - the argument type
      Parameters:
      procedureType - the procedure type to identify the procedure
      procedure - the procedure to add
      Throws:
      IllegalArgumentException - in case a procedure has already been associated with the given type
    • add

      protected final <C, T, R> void add(FunctionType<C,T,R> functionType, DatabaseFunction<C,T,R> function)
      Adds the given function to this domain
      Type Parameters:
      C - the connection type
      T - the argument type
      R - the result type
      Parameters:
      functionType - the function type to identify the function
      function - the function to add
      Throws:
      IllegalArgumentException - in case a function has already been associated with the given type
    • setStrictForeignKeys

      protected final void setStrictForeignKeys(boolean strictForeignKeys)
      Specifies whether it should be possible to define foreign keys referencing entities that have not been defined, this can be disabled in cases where entities have circular references.
      Parameters:
      strictForeignKeys - true for strict foreign key validation
    • addAll

      protected final void addAll(Domain domain)
      Adds all entities, procedures, functions and reports from the given domain model.
      Parameters:
      domain - the domain model to copy from
      See Also:
    • addEntities

      protected final void addEntities(Domain domain)
      Adds all the entities from the given domain to this domain. Note that the entity type names must be unique.
      Parameters:
      domain - the domain model which entities to add
      Throws:
      IllegalArgumentException - in case a non-unique entity type name is encountered
      See Also:
    • addProcedures

      protected final void addProcedures(Domain domain)
      Adds all the procedures from the given domain to this domain.
      Parameters:
      domain - the domain model which procedures to add
    • addFunctions

      protected final void addFunctions(Domain domain)
      Adds all the functions from the given domain to this domain.
      Parameters:
      domain - the domain model which functions to add
    • addReports

      protected final void addReports(Domain domain)
      Adds all the reports from the given domain to this domain.
      Parameters:
      domain - the domain model which reports to add