java.lang.Object
is.codion.framework.domain.DefaultDomain
- All Implemented Interfaces:
Domain
- Direct Known Subclasses:
TestDomain
A default
Domain
implementation. Extend to define a domain model.-
Constructor Summary
ModifierConstructorDescriptionprotected
DefaultDomain
(DomainType domainType) Instantiates a new DefaultDomain identified by the givenDomainType
. -
Method Summary
Modifier and TypeMethodDescriptionprotected final <C,
T, R> void add
(FunctionType<C, T, R> functionType, DatabaseFunction<C, T, R> function) Adds the given function to this domainprotected final <C,
T> void add
(ProcedureType<C, T> procedureType, DatabaseProcedure<C, T> procedure) Adds the given procedure to this domainprotected final <T,
R, P> void add
(ReportType<T, R, P> reportType, Report<T, R, P> report) Adds a report to this domain model.protected final void
add
(EntityDefinition definition) Adds a newEntityDefinition
to this domain model.protected final void
add
(EntityDefinition.Builder definitionBuilder) Adds a newEntityDefinition
to this domain model, by callingEntityDefinition.Builder.build()
.protected final void
Adds all entities, procedures, functions and reports from the given domain model.protected final void
addEntities
(Domain domain) Adds all the entities from the given domain to this domain.protected final void
addFunctions
(Domain domain) Adds all the functions from the given domain to this domain.protected final void
addProcedures
(Domain domain) Adds all the procedures from the given domain to this domain.protected final void
addReports
(Domain domain) Adds all the reports from the given domain to this domain.final Entities
entities()
final <C,
T, R> DatabaseFunction<C, T, R> function
(FunctionType<C, T, R> functionType) Retrieves the function of the given type.final Map<FunctionType<?,
?, ?>, DatabaseFunction<?, ?, ?>> final <C,
T> DatabaseProcedure<C, T> procedure
(ProcedureType<C, T> procedureType) Retrieves the procedure of the given type.final Map<ProcedureType<?,
?>, DatabaseProcedure<?, ?>> final <T,
R, P> Report<T, R, P> report
(ReportType<T, R, P> reportType) Retrieves the report of the given type.final Map<ReportType<?,
?, ?>, Report<?, ?, ?>> reports()
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.final DomainType
type()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface is.codion.framework.domain.Domain
configureConnection, configureDatabase
-
Constructor Details
-
DefaultDomain
Instantiates a new DefaultDomain identified by the givenDomainType
.- Parameters:
domainType
- the Domain model type to associate with this domain model
-
-
Method Details
-
type
-
entities
-
reports
-
procedures
- Specified by:
procedures
in interfaceDomain
- Returns:
- an unmodifiable view of this domain's procedures
-
functions
-
report
Description copied from interface:Domain
Retrieves the report of the given type. -
procedure
Description copied from interface:Domain
Retrieves the procedure of the given type. -
function
Description copied from interface:Domain
Retrieves the function of the given type. -
add
Adds a newEntityDefinition
to this domain model, by callingEntityDefinition.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 entityIllegalArgumentException
- in case no attribute definitions are specified
-
add
Adds a newEntityDefinition
to this domain model.- Parameters:
definition
- the definition to add- Throws:
IllegalArgumentException
- in case the entityType has already been used to define an entityIllegalArgumentException
- in case no attribute definitions are specified
-
add
Adds a report to this domain model.- Type Parameters:
T
- the report typeR
- the report result typeP
- the report parameters type- Parameters:
reportType
- the report to addreport
- the actual report to associate with the report type- Throws:
RuntimeException
- in case loading the report failedIllegalArgumentException
- in case the report has already been added
-
add
Adds the given procedure to this domain- Type Parameters:
C
- the connection typeT
- the argument type- Parameters:
procedureType
- the procedure type to identify the procedureprocedure
- the procedure to add- Throws:
IllegalArgumentException
- in case a procedure has already been associated with the given type
-
add
protected final <C,T, void addR> (FunctionType<C, T, R> functionType, DatabaseFunction<C, T, R> function) Adds the given function to this domain- Type Parameters:
C
- the connection typeT
- the argument typeR
- the result type- Parameters:
functionType
- the function type to identify the functionfunction
- 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
Adds all entities, procedures, functions and reports from the given domain model.- Parameters:
domain
- the domain model to copy from- See Also:
-
addEntities
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
Adds all the procedures from the given domain to this domain.- Parameters:
domain
- the domain model which procedures to add
-
addFunctions
Adds all the functions from the given domain to this domain.- Parameters:
domain
- the domain model which functions to add
-
addReports
Adds all the reports from the given domain to this domain.- Parameters:
domain
- the domain model which reports to add
-