- 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 defaultDomain
implementation. Extend to define a domain model.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DefaultDomain(DomainType domainType)
Instantiates a new DefaultDomain identified by the givenDomainType
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <C,T,R>
voidadd(FunctionType<C,T,R> functionType, DatabaseFunction<C,T,R> function)
Adds the given function to this domainprotected <C,T>
voidadd(ProcedureType<C,T> procedureType, DatabaseProcedure<C,T> procedure)
Adds the given procedure to this domainprotected <T,R,P>
voidadd(ReportType<T,R,P> reportType, Report<T,R,P> report)
Adds a report to this domain model.protected void
add(EntityDefinition definition)
Adds a newEntityDefinition
to this domain model.protected void
add(EntityDefinition.Builder definitionBuilder)
Adds a newEntityDefinition
to this domain model, by callingEntityDefinition.Builder.build()
.protected void
addAll(Domain domain)
Adds all entities, procedures, functions and reports from the given domain model.protected void
addEntities(Domain domain)
Adds all the entities from the given domain to this domain.protected void
addFunctions(Domain domain)
Adds all the functions from the given domain to this domain.protected void
addProcedures(Domain domain)
Adds all the procedures from the given domain to this domain.protected void
addReports(Domain domain)
Adds all the reports from the given domain to this domain.Entities
entities()
<C,T,R>
DatabaseFunction<C,T,R>function(FunctionType<C,T,R> functionType)
Retrieves the function of the given type.Map<FunctionType<?,?,?>,DatabaseFunction<?,?,?>>
functions()
<C,T>
DatabaseProcedure<C,T>procedure(ProcedureType<C,T> procedureType)
Retrieves the procedure of the given type.Map<ProcedureType<?,?>,DatabaseProcedure<?,?>>
procedures()
<T,R,P>
Report<T,R,P>report(ReportType<T,R,P> reportType)
Retrieves the report of the given type.Map<ReportType<?,?,?>,Report<?,?,?>>
reports()
protected 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.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
-
-
-
-
Constructor Detail
-
DefaultDomain
protected DefaultDomain(DomainType domainType)
Instantiates a new DefaultDomain identified by the givenDomainType
.- Parameters:
domainType
- the Domain model type to associate with this domain model
-
-
Method Detail
-
type
public final DomainType type()
-
entities
public final Entities entities()
-
reports
public final Map<ReportType<?,?,?>,Report<?,?,?>> reports()
-
procedures
public final Map<ProcedureType<?,?>,DatabaseProcedure<?,?>> procedures()
- Specified by:
procedures
in interfaceDomain
- Returns:
- an unmodifiable view of this domain's procedures
-
functions
public final Map<FunctionType<?,?,?>,DatabaseFunction<?,?,?>> 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.
-
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.
-
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.
-
add
protected final void add(EntityDefinition.Builder definitionBuilder)
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 properties are specified
-
add
protected final void add(EntityDefinition definition)
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 properties 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 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
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 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,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 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
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(Domain)
,addProcedures(Domain)
,addFunctions(Domain)
,addReports(Domain)
-
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:
EntityType.name()
-
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
-
-