@@ -143,9 +143,21 @@ public NamedInterfaces getNamedInterfaces() {
143143 * Returns the logical name of the module.
144144 *
145145 * @return will never be {@literal null} or empty.
146+ * @deprecated since 1.3, use {@link #getIdentifier()} instead.
146147 */
148+ @ Deprecated
147149 public String getName () {
148- return source .getModuleName ();
150+ return getIdentifier ().toString ();
151+ }
152+
153+ /**
154+ * Returns the logical identifier of the module.
155+ *
156+ * @return will never be {@literal null}.
157+ * @since 1.3
158+ */
159+ public ApplicationModuleIdentifier getIdentifier () {
160+ return source .getIdentifier ();
149161 }
150162
151163 /**
@@ -306,7 +318,7 @@ public ArchitecturallyEvidentType getArchitecturallyEvidentType(Class<?> type) {
306318 return getType (type .getName ())
307319 .map (it -> ArchitecturallyEvidentType .of (it , getSpringBeansInternal ()))
308320 .orElseThrow (() -> new IllegalArgumentException ("Couldn't find type %s in module %s!" .formatted (
309- FormattableType .of (type ).getAbbreviatedFullName (this ), getName ())));
321+ FormattableType .of (type ).getAbbreviatedFullName (this ), getIdentifier ())));
310322 }
311323
312324 /**
@@ -404,11 +416,11 @@ public String toString(@Nullable ApplicationModules modules) {
404416
405417 if (modules != null ) {
406418 modules .getParentOf (this ).ifPresent (it -> {
407- builder .append ("> Parent module: " ).append (it .getName ()).append ("\n " );
419+ builder .append ("> Parent module: " ).append (it .getIdentifier ()).append ("\n " );
408420 });
409421 }
410422
411- builder .append ("> Logical name: " ).append (getName ()).append ('\n' );
423+ builder .append ("> Logical name: " ).append (getIdentifier ()).append ('\n' );
412424 builder .append ("> Base package: " ).append (basePackage .getName ()).append ('\n' );
413425
414426 builder .append ("> Excluded packages: " );
@@ -438,8 +450,12 @@ public String toString(@Nullable ApplicationModules modules) {
438450 List <ApplicationModule > dependencies = getBootstrapDependencies (modules ).toList ();
439451
440452 builder .append ("> Direct module dependencies: " );
441- builder .append (dependencies .isEmpty () ? "none"
442- : dependencies .stream ().map (ApplicationModule ::getName ).collect (Collectors .joining (", " )));
453+ builder .append (dependencies .isEmpty ()
454+ ? "none"
455+ : dependencies .stream ()
456+ .map (ApplicationModule ::getIdentifier )
457+ .map (ApplicationModuleIdentifier ::toString )
458+ .collect (Collectors .joining (", " )));
443459 builder .append ('\n' );
444460 }
445461
@@ -739,7 +755,7 @@ Classes getClasses() {
739755 }
740756
741757 private String getQualifiedName (NamedInterface namedInterface ) {
742- return namedInterface .getQualifiedName (getName ());
758+ return namedInterface .getQualifiedName (getIdentifier ());
743759 }
744760
745761 private Collection <ApplicationModule > doGetNestedModules (ApplicationModules modules , boolean recursive ) {
@@ -877,7 +893,7 @@ public static DeclaredDependency of(String identifier, ApplicationModule source,
877893
878894 var target = modules .getModuleByName (targetModuleName )
879895 .orElseThrow (() -> new IllegalArgumentException (
880- INVALID_EXPLICIT_MODULE_DEPENDENCY .formatted (source .getName (), targetModuleName )));
896+ INVALID_EXPLICIT_MODULE_DEPENDENCY .formatted (source .getIdentifier (), targetModuleName )));
881897
882898 if (WILDCARD .equals (namedInterfaceName )) {
883899 return new DeclaredDependency (target , null );
@@ -888,7 +904,8 @@ public static DeclaredDependency of(String identifier, ApplicationModule source,
888904 ? namedInterfaces .getUnnamedInterface ()
889905 : namedInterfaces .getByName (namedInterfaceName )
890906 .orElseThrow (() -> new IllegalArgumentException (
891- INVALID_NAMED_INTERFACE_DECLARATION .formatted (namedInterfaceName , source .getName (), identifier )));
907+ INVALID_NAMED_INTERFACE_DECLARATION .formatted (namedInterfaceName , source .getIdentifier (),
908+ identifier )));
892909
893910 return new DeclaredDependency (target , namedInterface );
894911 }
@@ -943,7 +960,7 @@ boolean contains(Class<?> type) {
943960 @ Override
944961 public String toString () {
945962
946- var result = target .getName ();
963+ var result = target .getIdentifier (). toString ();
947964
948965 if (namedInterface == null ) {
949966 return result + " :: " + WILDCARD ;
@@ -1230,14 +1247,14 @@ Violations isValidDependencyWithin(ApplicationModules modules) {
12301247 .toList ();
12311248
12321249 var targetString = targetNamedInterfaces .isEmpty ()
1233- ? "module '%s'" .formatted (targetModule .getName ())
1250+ ? "module '%s'" .formatted (targetModule .getIdentifier ())
12341251 : "named interface(s) '%s'" .formatted (
12351252 targetNamedInterfaces .stream ()
12361253 .map (targetModule ::getQualifiedName )
12371254 .collect (Collectors .joining (", " )));
12381255
12391256 var message = "Module '%s' depends on %s via %s -> %s. Allowed targets: %s." //
1240- .formatted (originModule .getName (), targetString , source .getName (), target .getName (),
1257+ .formatted (originModule .getIdentifier (), targetString , source .getName (), target .getName (),
12411258 declaredDependencies .toString ());
12421259
12431260 return violations .and (new Violation (message ));
@@ -1256,7 +1273,7 @@ Violations isValidDependencyWithin(ApplicationModules modules) {
12561273 if (!targetModule .isExposed (target )) {
12571274
12581275 var violationText = INTERNAL_REFERENCE
1259- .formatted (originModule .getName (), target .getName (), targetModule .getName ());
1276+ .formatted (originModule .getIdentifier (), target .getName (), targetModule .getIdentifier ());
12601277
12611278 return violations .and (new Violation (violationText + lineSeparator () + description ));
12621279 }
@@ -1266,7 +1283,7 @@ Violations isValidDependencyWithin(ApplicationModules modules) {
12661283 if (!haveSameParentOrDirectParentRelationship (originModule , targetModule , modules )) {
12671284
12681285 var violationText = INVALID_SUB_MODULE_REFERENCE
1269- .formatted (originModule .getName (), targetModule .getName (),
1286+ .formatted (originModule .getIdentifier (), targetModule .getIdentifier (),
12701287 FormattableType .of (source ).getAbbreviatedFullName (originModule ),
12711288 FormattableType .of (target ).getAbbreviatedFullName (targetModule ));
12721289
0 commit comments