Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,20 @@ public String toString() {
* Thrown if typeName is {@code null} or empty
*/
public static PackagingType of(String typeName) throws IllegalArgumentException {
return of(typeName, typeName, "");
}

public static PackagingType of(String typeName, String extension) throws IllegalArgumentException {
return of(typeName, extension, "");
}

public static PackagingType of(String typeName, String extension, String classifier) throws IllegalArgumentException {
PackagingType packagingType = fromCache(typeName);
if (packagingType != null){
return packagingType;
}
// this will cause packaging object to register into cache
return new PackagingType(typeName);
return new PackagingType(typeName, extension == null ? typeName : extension, classifier == null ? "" : classifier);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,17 @@ public void random() {
Assert.assertEquals("random", PackagingType.of("random").toString());
}

@Test
public void bundle() {
final PackagingType packagingType = PackagingType.of("bundle", "jar");
Assert.assertEquals("bundle", packagingType.toString());
Assert.assertEquals("jar", packagingType.getExtension());
Assert.assertEquals("", packagingType.getClassifier());

final PackagingType packagingType2 = PackagingType.of("bundle2", null, null);
Assert.assertEquals("bundle2", packagingType2.toString());
Assert.assertEquals("bundle2", packagingType2.getExtension());
Assert.assertEquals("", packagingType2.getClassifier());
}

}