Chapter 4 inconsistency

I’m at chapter 4 and just implemented the mapToDomain():

override fun mapToDomain(apiEntity: ApiAnimal): AnimalWithDetails {
        return AnimalWithDetails(
            id = ?: throw MappingException("animal id cannot be null"),
            name =,
            type = apiEntity.type.orEmpty(),
            details = parseAnimalDetails(apiEntity),
            media = mapMedia(apiEntity),
            tags = apiEntity.tags.orEmpty().map { it.orEmpty() },
            adoptionStatus = parseAdoptionStatus(apiEntity.status),
            publishedAt = DateTimeUtils.parse(apiEntity.publishedAt.orEmpty())

There are a few things I don’t understand, consistency wise:

  • why are some methods called mappers and some parsers?
  • why does parseAdoptionStatus() use apiEntity.status instead of just apiEntity like all other mappers/parsers?
  • which brings me to the final question - why not use the concrete property for all mappers/parsers? Then the mapper/parser receives only the data it needs.
1 Like