Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Hexagonal architecture #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions src/main/java/org/xmolecules/ide/intellij/Concepts.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,14 @@ class Concepts {
new Concept("Entity", "Entities", it -> JMolecules.isEntity(it) && !JMolecules.isAggregateRoot(it)),
new Concept("Aggregate Root", "Aggregate roots", JMolecules::isAggregateRoot),
new Concept("Event", "Events", JMolecules::isEvent),
new Concept("Event listener", "Event listeners",
any(JMolecules::isEventListener, Spring::isEventListener))
new Concept("Event listener", "Event listeners", any(JMolecules::isEventListener, Spring::isEventListener)),
new Concept("Application", "Applications", JMolecules::isHexagonalApplication),
new Concept("Port", "Ports", it -> JMolecules.isHexagonalPort(it) && !JMolecules.isHexagonalPrimaryPort(it) && !JMolecules.isHexagonalSecondaryPort(it)),
new Concept("Adapter", "Adapters", it -> JMolecules.isHexagonalAdapter(it) && !JMolecules.isHexagonalPrimaryAdapter(it) && !JMolecules.isHexagonalSecondaryAdapter(it)),
new Concept("Primary Port", "Primary Ports", JMolecules::isHexagonalPrimaryPort),
new Concept("Primary Adapter", "Primary Adapters", JMolecules::isHexagonalPrimaryAdapter),
new Concept("Secondary Port", "Secondary Ports", JMolecules::isHexagonalSecondaryPort),
new Concept("Secondary Adapter", "Secondary Adapters", JMolecules::isHexagonalSecondaryAdapter)
);
}

Expand Down Expand Up @@ -92,6 +98,7 @@ private static class JMolecules {
private static final String BASE_PACKAGE = "org.jmolecules";
private static final String DDD_BASE_PACKAGE = BASE_PACKAGE + ".ddd";
private static final String EVENT_BASE_PACKAGE = BASE_PACKAGE + ".event";
private static final String ARCHITECTURE_BASE_PACKAGE = BASE_PACKAGE + ".architecture";

static boolean isFactory(final @NotNull PsiJavaFile file) {
return isTypeAnnotatedWith(DDD_BASE_PACKAGE + ".annotation.Factory", file);
Expand Down Expand Up @@ -129,6 +136,34 @@ static boolean isEventListener(final @NotNull PsiJavaFile file) {
return isTypeAnnotatedWith(EVENT_BASE_PACKAGE + ".types.DomainEventHandler", file);
}

static boolean isHexagonalApplication(final @NotNull PsiJavaFile file) {
return isTypeAnnotatedWith(ARCHITECTURE_BASE_PACKAGE + ".hexagonal.Application", file);
}

static boolean isHexagonalPort(final @NotNull PsiJavaFile file) {
return isTypeAnnotatedWith(ARCHITECTURE_BASE_PACKAGE + ".hexagonal.Port", file);
}

static boolean isHexagonalAdapter(final @NotNull PsiJavaFile file) {
return isTypeAnnotatedWith(ARCHITECTURE_BASE_PACKAGE + ".hexagonal.Adapter", file);
}

static boolean isHexagonalPrimaryPort(final @NotNull PsiJavaFile file) {
return isTypeAnnotatedWith(ARCHITECTURE_BASE_PACKAGE + ".hexagonal.PrimaryPort", file);
}

static boolean isHexagonalPrimaryAdapter(final @NotNull PsiJavaFile file) {
return isTypeAnnotatedWith(ARCHITECTURE_BASE_PACKAGE + ".hexagonal.PrimaryAdapter", file);
}

static boolean isHexagonalSecondaryPort(final @NotNull PsiJavaFile file) {
return isTypeAnnotatedWith(ARCHITECTURE_BASE_PACKAGE + ".hexagonal.SecondaryPort", file);
}

static boolean isHexagonalSecondaryAdapter(final @NotNull PsiJavaFile file) {
return isTypeAnnotatedWith(ARCHITECTURE_BASE_PACKAGE + ".hexagonal.SecondaryAdapter", file);
}

private static boolean implementsOrAnnotated(final @NotNull String basePackage,
final @NotNull String name,
final @NotNull PsiJavaFile file) {
Expand Down