Package org.apache.rat.license
Class LicenseSetFactory
java.lang.Object
org.apache.rat.license.LicenseSetFactory
Class to take a set of ILicenses and collection of approved license
categories and extract Subsets.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
An enum that defines the types of Licenses to extract. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a factory with the specified set of Licenses and the approved license collection.LicenseSetFactory
(SortedSet<ILicense> licenses) Constructs a factory with the specified set of Licenses and the approved license collection. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(LicenseSetFactory other) void
addFamily
(ILicenseFamily family) Adds a license family to the list of families.void
addFamily
(ILicenseFamily.Builder builder) Adds a license family to the list of families.void
addLicense
(ILicense license) Adds a license to the list of licenses.addLicense
(ILicense.Builder builder) Adds a license to the list of licenses.void
addLicenses
(Collection<ILicense> licenses) Adds multiple licenses to the list of licenses.void
approveLicenseCategory
(String familyCategory) Adds a license family category (id) to the list of approved licensesvoid
approveLicenseId
(String licenseId) Adds a license family category (id) to the list of approved licensesvoid
Sets the reporting option for duplicate license families.static ILicenseFamily
familySearch
(String target, SortedSet<ILicenseFamily> licenseFamilies) Search a SortedSet of ILicenseFamily instances looking for a matching instance.static ILicenseFamily
familySearch
(ILicenseFamily target, SortedSet<ILicenseFamily> licenseFamilies) Search a SortedSet of ILicenseFamily instances looking for a matching instance.Gets a predicate to filter for approved licenses.Gets the License ids based on the filter.Gets the LicenseFamily objects based on the filter.Gets the License ids based on the filter.Gets the License objects based on the filter.void
Sets the reporting option for duplicate licenses.void
logFamilyCollisions
(Log.Level level) Set the log level for reporting collisions in the set of license families.void
logLicenseCollisions
(Log.Level level) Sets the log level for reporting license collisions.void
removeLicenseCategory
(String familyCategory) Adds a license family category (id) to the list of approved licensesvoid
removeLicenseId
(String licenseId) Removes a license ID from the list of approved licenses.Search a SortedSet of licenses for the matching license id.Search a SortedSet of licenses for the matching license.
-
Constructor Details
-
LicenseSetFactory
public LicenseSetFactory()Constructs a factory with the specified set of Licenses and the approved license collection. -
LicenseSetFactory
Constructs a factory with the specified set of Licenses and the approved license collection.- Parameters:
licenses
- the set of defined licenses. Families will be extracted from the licenses.
-
-
Method Details
-
familySearch
Search a SortedSet of ILicenseFamily instances looking for a matching instance.- Parameters:
target
- The instance to search for.licenseFamilies
- the license families to search.- Returns:
- the matching instance of the target given.
-
familySearch
public static ILicenseFamily familySearch(ILicenseFamily target, SortedSet<ILicenseFamily> licenseFamilies) Search a SortedSet of ILicenseFamily instances looking for a matching instance.- Parameters:
target
- The instance to search for.licenseFamilies
- the license families to search.- Returns:
- the matching instance of the target given.
-
add
-
logFamilyCollisions
Set the log level for reporting collisions in the set of license families.NOTE: should be set before licenses or license families are added.
- Parameters:
level
- The log level to use.
-
familyDuplicateOption
Sets the reporting option for duplicate license families.- Parameters:
state
- The ReportingSet.Option to use for reporting.
-
logLicenseCollisions
Sets the log level for reporting license collisions.- Parameters:
level
- The log level.
-
licenseDuplicateOption
Sets the reporting option for duplicate licenses.- Parameters:
state
- the ReportingSt.Option to use for reporting.
-
addLicense
Adds a license to the list of licenses. Does not add the license to the list of approved licenses.- Parameters:
license
- The license to add to the list of licenses.
-
addLicense
Adds a license to the list of licenses. Does not add the license to the list of approved licenses.- Parameters:
builder
- The license builder to build and add to the list of licenses.- Returns:
- The ILicense implementation that was added.
-
addLicenses
Adds multiple licenses to the list of licenses. Does not add the licenses to the list of approved licenses.- Parameters:
licenses
- The licenses to add.
-
addFamily
Adds a license family to the list of families. Does not add the family to the list of approved licenses.- Parameters:
family
- The license family to add to the list of license families.
-
addFamily
Adds a license family to the list of families. Does not add the family to the list of approved licenses.- Parameters:
builder
- The licenseFamily.Builder to build and add to the list of licenses.
-
approveLicenseCategory
Adds a license family category (id) to the list of approved licenses- Parameters:
familyCategory
- the category to add.
-
removeLicenseCategory
Adds a license family category (id) to the list of approved licenses- Parameters:
familyCategory
- the category to add.
-
approveLicenseId
Adds a license family category (id) to the list of approved licenses- Parameters:
licenseId
- the license ID to add.
-
removeLicenseId
Removes a license ID from the list of approved licenses.- Parameters:
licenseId
- the license ID to remove.
-
getApprovedLicensePredicate
Gets a predicate to filter for approved licenses.- Returns:
- a predicate that returns
true
if the license is approved.
-
getLicenses
Gets the License objects based on the filter.- Parameters:
filter
- the types of LicenseFamily objects to return.- Returns:
- a SortedSet of ILicense objects.
-
getLicenseFamilies
Gets the LicenseFamily objects based on the filter.- Parameters:
filter
- the types of LicenseFamily objects to return.- Returns:
- a SortedSet of ILicenseFamily objects.
-
getLicenseCategories
Gets the License ids based on the filter.- Parameters:
filter
- the types of License Ids to return.- Returns:
- The list of all licenses in the category regardless of whether or not it is used by an ILicense implementation.
-
getLicenseIds
Gets the License ids based on the filter.- Parameters:
filter
- the types of License Ids to return.- Returns:
- The list of all licenses in the category regardless of whether or not it is used by an ILicense implementation.
-
search
public static Optional<ILicense> search(String familyId, String licenseId, SortedSet<ILicense> licenses) Search a SortedSet of licenses for the matching license id.- Parameters:
licenseId
- the id to search for.licenses
- the SortedSet of licenses to search.- Returns:
- the matching license or
null
if not found.
-
search
Search a SortedSet of licenses for the matching license. License must match both family code, and license id.- Parameters:
target
- the license to search for. Must not benull
.licenses
- the SortedSet of licenses to search.- Returns:
- the matching license or
null
if not found.
-