Defining entities and specifications
Once we have created all the value objects, we can start to think about how to represent the elements in entities that have an identity. Also, we need to develop specifications to define business rules that govern constraints that the entities should obey.
Remember that what characterizes an entity is its identity and the presence of business rules and data. In the topology and inventory system, we have as entities Equipment
, Router
, and Switch
.
Inside the domain
Java module we created previously, we’ll add the entity classes within a package called entity
.
The Equipment and Router abstract entities
Routers and switches are different types of network equipment, so we’ll start by creating an Equipment
abstract class, as follows:
package dev.davivieira.topologyinventory.domain.entity; import dev.davivieira.topologyinventory.domain.vo.IP; import dev.davivieira.topologyinventory.domain.vo.Id; import dev.davivieira.topologyinventory...