@@ -68,7 +68,7 @@ public class Library {
68
68
69
69
private final String linkRootName ;
70
70
71
- private final Map <String , Link > links ;
71
+ private final Map <String , List < Link > > links ;
72
72
73
73
/**
74
74
* Create a new {@code Library} with the given {@code name}, {@code version}, and
@@ -89,7 +89,7 @@ public class Library {
89
89
*/
90
90
public Library (String name , String calendarName , LibraryVersion version , List <Group > groups ,
91
91
List <ProhibitedVersion > prohibitedVersions , boolean considerSnapshots , VersionAlignment versionAlignment ,
92
- String alignsWithBom , String linkRootName , Map <String , Link > links ) {
92
+ String alignsWithBom , String linkRootName , Map <String , List < Link > > links ) {
93
93
this .name = name ;
94
94
this .calendarName = (calendarName != null ) ? calendarName : name ;
95
95
this .version = version ;
@@ -148,16 +148,22 @@ public String getAlignsWithBom() {
148
148
return this .alignsWithBom ;
149
149
}
150
150
151
- public Map <String , Link > getLinks () {
151
+ public Map <String , List < Link > > getLinks () {
152
152
return this .links ;
153
153
}
154
154
155
155
public String getLinkUrl (String name ) {
156
- Link link = getLink (name );
157
- return (link != null ) ? link .url (this ) : null ;
156
+ List <Link > links = getLinks (name );
157
+ if (links == null || links .isEmpty ()) {
158
+ return null ;
159
+ }
160
+ if (links .size () > 1 ) {
161
+ throw new IllegalStateException ("Expected a single '%s' link for %s" .formatted (name , getName ()));
162
+ }
163
+ return links .get (0 ).url (this );
158
164
}
159
165
160
- public Link getLink (String name ) {
166
+ public List < Link > getLinks (String name ) {
161
167
return this .links .get (name );
162
168
}
163
169
@@ -524,7 +530,7 @@ public String toString() {
524
530
525
531
}
526
532
527
- public record Link (Function <LibraryVersion , String > factory , List <String > packages ) {
533
+ public record Link (String rootName , Function <LibraryVersion , String > factory , List <String > packages ) {
528
534
529
535
private static final Pattern PACKAGE_EXPAND = Pattern .compile ("^(.*)\\ [(.*)\\ ]$" );
530
536
0 commit comments