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

Provide API to get SPDX license identifier for AspectModelFile #688

Merged
merged 2 commits into from
Dec 10, 2024
Merged
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 @@ -46,6 +46,18 @@ default List<String> headerComment() {
return List.of();
}

/**
* Returns the SPDX license identifier for this file, if one exists
*
* @return the SPDX identifier
*/
default Optional<String> spdxLicenseIdentifier() {
return headerComment().stream()
.filter( line -> line.startsWith( "SPDX-License-Identifier:" ) )
.map( line -> line.split( ":" )[1].trim() )
.findFirst();
}

/**
* The URI that denominates the source location, if present. It can be a file:// or https:// URL, but it
* could for example also be an Aspect Model URN, if it refers to a file that is part of the SAMM specification.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ void testLoadDataModelExpectSuccess() throws URISyntaxException {
assertThat( result.files().get( 0 ).headerComment() ).isNotNull();
assertThat( result.files().get( 0 ).headerComment().get( 0 ) ).contains(
"Copyright (c) 2023 Robert Bosch Manufacturing Solutions GmbH" );
assertThat( result.files().get( 0 ).spdxLicenseIdentifier() ).contains( "MPL-2.0" );
} ).doesNotThrowAnyException();
}

Expand Down
Loading