Module de.seggebaeing.sqlanalyzer
Class AbstractBusinessDomainMapper<B extends BusinessDomainObject,P extends Persistable>
java.lang.Object
de.seggebaeing.sqlanalyzer.logic.domainmapper.AbstractBusinessDomainMapper<B,P>
- Type Parameters:
B
- business domain object typeP
- persistable DTO type
- All Implemented Interfaces:
BusinessDomainMapper<B,
P>
- Direct Known Subclasses:
GeneratedQueryMapper
,LLMMapper
,PromptMapper
,PromptTypeMapper
,SampleQueryMapper
public abstract class AbstractBusinessDomainMapper<B extends BusinessDomainObject,P extends Persistable>
extends Object
implements BusinessDomainMapper<B,P>
Abstract base for bidirectional mapping between business domain objects (BDOs) and
de.seggebaeing.sqlanalyzer.persistence DTOs.
Maintains identity-preserving caches in both directions to avoid duplicate mappings
(BDO→DTO
and DTO→BDO
). Provides initialize(Supplier)
to inject
an ID supplier required by concrete mappers, and convenience methods
putIntoMaps(B, P)
/ putIntoMaps(P, B)
to register paired objects.
- Since:
- 1.0
- Author:
- Felix Seggebäing
-
Field Summary
FieldsModifier and TypeFieldDescriptionIdentity cache mapping BDO → DTO to reuse mapped instances (not thread-safe).Identity cache mapping DTO → BDO to reuse mapped instances (not thread-safe).Supplier for generating new IDs; set viainitialize(Supplier)
. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
initialize
(Supplier<Integer> idSupplier) Initializes this mapper with a supplier for allocating new IDs.protected void
putIntoMaps
(B bdo, P dto) Registers a mapped pair in both caches (BDO→DTO and DTO→BDO).protected void
putIntoMaps
(P dto, B bdo) Registers a mapped pair in both caches (DTO→BDO and BDO→DTO).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface de.seggebaeing.sqlanalyzer.logic.domainmapper.BusinessDomainMapper
get, get
-
Field Details
-
cacheMapBDOtoDTO
Identity cache mapping BDO → DTO to reuse mapped instances (not thread-safe). -
cacheMapDTOtoBDO
Identity cache mapping DTO → BDO to reuse mapped instances (not thread-safe). -
idSupplier
Supplier for generating new IDs; set viainitialize(Supplier)
. Defaults to a lambda that throws an illegal state exception if used before initialization.
-
-
Constructor Details
-
AbstractBusinessDomainMapper
public AbstractBusinessDomainMapper()
-
-
Method Details
-
putIntoMaps
Registers a mapped pair in both caches (BDO→DTO and DTO→BDO). Requires non-null arguments.- Parameters:
bdo
- the business objectdto
- the corresponding DTO- Throws:
NullPointerException
- if any of the args arenull
-
putIntoMaps
Registers a mapped pair in both caches (DTO→BDO and BDO→DTO). Delegates toputIntoMaps(B, P)
.- Parameters:
dto
- the DTObdo
- the corresponding business object
-
initialize
Initializes this mapper with a supplier for allocating new IDs.- Specified by:
initialize
in interfaceBusinessDomainMapper<B extends BusinessDomainObject,
P extends Persistable> - Parameters:
idSupplier
- non-null supplier of unique IDs- Throws:
NullPointerException
- ifidSupplier
isnull
-