View on GitHub

qc-atlas

Platform for Sharing Quantum Software

Use model assemblers for HATEOAS responses

Context and Problem Statement

Spring HATEOAS includes several classes that encapsulate domain objects, adding support for links. Constructing such objects, as well as adding the desired links to them is a common operation that requires entity-specific boilerplate code. How can duplicate code in nearly all controller methods be avoided?

Decision Drivers

Considered Options

Decision Outcome

Separate model assemblers were chosen, as the former option would require us to have a deep coupling between HATEOAS types and our DTO classes.

Due to the assembler classes being initially only used for links they all reside in the linkassembler package.

Pros and Cons of the Options

Separate model assembler classes