@@ -143,9 +143,21 @@ public NamedInterfaces getNamedInterfaces() {
143
143
* Returns the logical name of the module.
144
144
*
145
145
* @return will never be {@literal null} or empty.
146
+ * @deprecated since 1.3, use {@link #getIdentifier()} instead.
146
147
*/
148
+ @ Deprecated
147
149
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 ();
149
161
}
150
162
151
163
/**
@@ -306,7 +318,7 @@ public ArchitecturallyEvidentType getArchitecturallyEvidentType(Class<?> type) {
306
318
return getType (type .getName ())
307
319
.map (it -> ArchitecturallyEvidentType .of (it , getSpringBeansInternal ()))
308
320
.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 ())));
310
322
}
311
323
312
324
/**
@@ -404,11 +416,11 @@ public String toString(@Nullable ApplicationModules modules) {
404
416
405
417
if (modules != null ) {
406
418
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 " );
408
420
});
409
421
}
410
422
411
- builder .append ("> Logical name: " ).append (getName ()).append ('\n' );
423
+ builder .append ("> Logical name: " ).append (getIdentifier ()).append ('\n' );
412
424
builder .append ("> Base package: " ).append (basePackage .getName ()).append ('\n' );
413
425
414
426
builder .append ("> Excluded packages: " );
@@ -438,8 +450,12 @@ public String toString(@Nullable ApplicationModules modules) {
438
450
List <ApplicationModule > dependencies = getBootstrapDependencies (modules ).toList ();
439
451
440
452
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 (", " )));
443
459
builder .append ('\n' );
444
460
}
445
461
@@ -739,7 +755,7 @@ Classes getClasses() {
739
755
}
740
756
741
757
private String getQualifiedName (NamedInterface namedInterface ) {
742
- return namedInterface .getQualifiedName (getName ());
758
+ return namedInterface .getQualifiedName (getIdentifier ());
743
759
}
744
760
745
761
private Collection <ApplicationModule > doGetNestedModules (ApplicationModules modules , boolean recursive ) {
@@ -877,7 +893,7 @@ public static DeclaredDependency of(String identifier, ApplicationModule source,
877
893
878
894
var target = modules .getModuleByName (targetModuleName )
879
895
.orElseThrow (() -> new IllegalArgumentException (
880
- INVALID_EXPLICIT_MODULE_DEPENDENCY .formatted (source .getName (), targetModuleName )));
896
+ INVALID_EXPLICIT_MODULE_DEPENDENCY .formatted (source .getIdentifier (), targetModuleName )));
881
897
882
898
if (WILDCARD .equals (namedInterfaceName )) {
883
899
return new DeclaredDependency (target , null );
@@ -888,7 +904,8 @@ public static DeclaredDependency of(String identifier, ApplicationModule source,
888
904
? namedInterfaces .getUnnamedInterface ()
889
905
: namedInterfaces .getByName (namedInterfaceName )
890
906
.orElseThrow (() -> new IllegalArgumentException (
891
- INVALID_NAMED_INTERFACE_DECLARATION .formatted (namedInterfaceName , source .getName (), identifier )));
907
+ INVALID_NAMED_INTERFACE_DECLARATION .formatted (namedInterfaceName , source .getIdentifier (),
908
+ identifier )));
892
909
893
910
return new DeclaredDependency (target , namedInterface );
894
911
}
@@ -943,7 +960,7 @@ boolean contains(Class<?> type) {
943
960
@ Override
944
961
public String toString () {
945
962
946
- var result = target .getName ();
963
+ var result = target .getIdentifier (). toString ();
947
964
948
965
if (namedInterface == null ) {
949
966
return result + " :: " + WILDCARD ;
@@ -1230,14 +1247,14 @@ Violations isValidDependencyWithin(ApplicationModules modules) {
1230
1247
.toList ();
1231
1248
1232
1249
var targetString = targetNamedInterfaces .isEmpty ()
1233
- ? "module '%s'" .formatted (targetModule .getName ())
1250
+ ? "module '%s'" .formatted (targetModule .getIdentifier ())
1234
1251
: "named interface(s) '%s'" .formatted (
1235
1252
targetNamedInterfaces .stream ()
1236
1253
.map (targetModule ::getQualifiedName )
1237
1254
.collect (Collectors .joining (", " )));
1238
1255
1239
1256
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 (),
1241
1258
declaredDependencies .toString ());
1242
1259
1243
1260
return violations .and (new Violation (message ));
@@ -1256,7 +1273,7 @@ Violations isValidDependencyWithin(ApplicationModules modules) {
1256
1273
if (!targetModule .isExposed (target )) {
1257
1274
1258
1275
var violationText = INTERNAL_REFERENCE
1259
- .formatted (originModule .getName (), target .getName (), targetModule .getName ());
1276
+ .formatted (originModule .getIdentifier (), target .getName (), targetModule .getIdentifier ());
1260
1277
1261
1278
return violations .and (new Violation (violationText + lineSeparator () + description ));
1262
1279
}
@@ -1266,7 +1283,7 @@ Violations isValidDependencyWithin(ApplicationModules modules) {
1266
1283
if (!haveSameParentOrDirectParentRelationship (originModule , targetModule , modules )) {
1267
1284
1268
1285
var violationText = INVALID_SUB_MODULE_REFERENCE
1269
- .formatted (originModule .getName (), targetModule .getName (),
1286
+ .formatted (originModule .getIdentifier (), targetModule .getIdentifier (),
1270
1287
FormattableType .of (source ).getAbbreviatedFullName (originModule ),
1271
1288
FormattableType .of (target ).getAbbreviatedFullName (targetModule ));
1272
1289
0 commit comments