DtoConverter

interface DtoConverter<TEntity : Any, TDto : Any>

A converter supposed to convert Business Objects to Data Transfer Objects and vice versa.

Implementers have to implement at least either convertToDto or convertToEntity.

There are extension functions available for this interface:

Functions

Link copied to clipboard
open suspend fun convertToDto(entity: TEntity): TDto

Converts given entity to DTO.

Link copied to clipboard
suspend fun <TEntity : Any, TDto : Any> DtoConverter<TEntity, TDto>.convertToDtoIf(entity: TEntity, predicate: () -> Boolean): TDto?

Converts given entity to DTO if the given predicate matches. Returns null otherwise.

Link copied to clipboard

Converts given entities to DTO list.

Link copied to clipboard
suspend fun <TEntity : Any, TDto : Any> DtoConverter<TEntity, TDto>.convertToDtoListIf(entities: List<TEntity>, predicate: () -> Boolean): List<TDto>?

Converts given entities to DTO list if the given predicate matches. Returns null otherwise.

Link copied to clipboard

Converts given DTO list to entities.

Link copied to clipboard
open suspend fun convertToEntity(dto: TDto): TEntity

Converts given DTO to entity.