Is there a way to express that classes of a more general package must not access classes of more specialized (or sub) packages?
Rationale: based on an hexagonal architecture style I have my domain classes for example in
com.enterprise.business.domain
The corresponding repository interface is
com.enterprise.business.domain.repo
The specific mongodb implementation could be in
com.enterprise.business.domain.repo.mongodb
etc
So classes in an outer (e.g. com.enterprise.business.domain.repo.mongodb) package can access classes in the base com.enterprise.business.domain package, but never the other way around.
I would like to express this restriction in a general manner.
Something like: a class in some package X must not access a class in some package Y where X is a package prefix of Y.
Is there a way to express that classes of a more general package must not access classes of more specialized (or sub) packages?
Rationale: based on an hexagonal architecture style I have my domain classes for example in
com.enterprise.business.domainThe corresponding repository interface is
com.enterprise.business.domain.repoThe specific mongodb implementation could be in
com.enterprise.business.domain.repo.mongodbetc
So classes in an outer (e.g.
com.enterprise.business.domain.repo.mongodb) package can access classes in the basecom.enterprise.business.domainpackage, but never the other way around.I would like to express this restriction in a general manner.
Something like: a class in some package
Xmust not access a class in some packageYwhereXis a package prefix ofY.