Class LicenseSetFactory

java.lang.Object
org.apache.rat.license.LicenseSetFactory

public class LicenseSetFactory extends Object
Class to take a set of ILicenses and collection of approved license categories and extract Subsets.
  • Constructor Details

    • LicenseSetFactory

      public LicenseSetFactory()
      Constructs a factory with the specified set of Licenses and the approved license collection.
    • LicenseSetFactory

      public LicenseSetFactory(SortedSet<ILicense> licenses)
      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

      public static ILicenseFamily familySearch(String 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.
    • 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

      public void add(LicenseSetFactory other)
    • logFamilyCollisions

      public void logFamilyCollisions(Log.Level level)
      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

      public void familyDuplicateOption(ReportingSet.Options state)
      Sets the reporting option for duplicate license families.
      Parameters:
      state - The ReportingSet.Option to use for reporting.
    • logLicenseCollisions

      public void logLicenseCollisions(Log.Level level)
      Sets the log level for reporting license collisions.
      Parameters:
      level - The log level.
    • licenseDuplicateOption

      public void licenseDuplicateOption(ReportingSet.Options state)
      Sets the reporting option for duplicate licenses.
      Parameters:
      state - the ReportingSt.Option to use for reporting.
    • addLicense

      public void addLicense(ILicense license)
      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

      public ILicense addLicense(ILicense.Builder builder)
      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

      public void addLicenses(Collection<ILicense> licenses)
      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

      public void addFamily(ILicenseFamily family)
      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

      public void addFamily(ILicenseFamily.Builder builder)
      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

      public void approveLicenseCategory(String familyCategory)
      Adds a license family category (id) to the list of approved licenses
      Parameters:
      familyCategory - the category to add.
    • removeLicenseCategory

      public void removeLicenseCategory(String familyCategory)
      Adds a license family category (id) to the list of approved licenses
      Parameters:
      familyCategory - the category to add.
    • approveLicenseId

      public void approveLicenseId(String licenseId)
      Adds a license family category (id) to the list of approved licenses
      Parameters:
      licenseId - the license ID to add.
    • removeLicenseId

      public void removeLicenseId(String licenseId)
      Removes a license ID from the list of approved licenses.
      Parameters:
      licenseId - the license ID to remove.
    • getApprovedLicensePredicate

      public Predicate<ILicense> getApprovedLicensePredicate()
      Gets a predicate to filter for approved licenses.
      Returns:
      a predicate that returns true if the license is approved.
    • getLicenses

      public SortedSet<ILicense> getLicenses(LicenseSetFactory.LicenseFilter filter)
      Gets the License objects based on the filter.
      Parameters:
      filter - the types of LicenseFamily objects to return.
      Returns:
      a SortedSet of ILicense objects.
    • getLicenseFamilies

      public SortedSet<ILicenseFamily> getLicenseFamilies(LicenseSetFactory.LicenseFilter filter)
      Gets the LicenseFamily objects based on the filter.
      Parameters:
      filter - the types of LicenseFamily objects to return.
      Returns:
      a SortedSet of ILicenseFamily objects.
    • getLicenseCategories

      public SortedSet<String> getLicenseCategories(LicenseSetFactory.LicenseFilter filter)
      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

      public SortedSet<String> getLicenseIds(LicenseSetFactory.LicenseFilter filter)
      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

      public static Optional<ILicense> search(ILicense target, SortedSet<ILicense> licenses)
      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 be null.
      licenses - the SortedSet of licenses to search.
      Returns:
      the matching license or null if not found.