@ SuppressWarnings ( "unchecked" ) // SelfExtractor has no generics public static List < ProductRequirementInformation > createFromAppliesTo ( String appliesTo ) { if ( appliesTo == null || appliesTo . isEmpty ( ) ) { throw new InvalidParameterException ( "Applies to must be set to a valid value but is " + appliesTo ) ; } List < ProductRequirementInformation > products = new ArrayList < ProductRequirementInformation > ( ) ; List < ProductMatch > matchers = SelfExtractor . parseAppliesTo ( appliesTo ) ; for ( ProductMatch match : matchers ) { // All product must have their ID set so this should always produce a valid filter string String productId = match . getProductId ( ) ; String version = match . getVersion ( ) ; final String versionRange ; if ( version != null && version . endsWith ( "+" ) ) { versionRange = version . substring ( 0 , version . length ( ) - 1 ) ; } else { if ( version != null ) { versionRange = Character . toString ( VersionRange . LEFT_CLOSED ) + version + ", " + version + Character . toString ( VersionRange . RIGHT_CLOSED ) ; } else { versionRange = null ; } } String installType = match . getInstallType ( ) ; String licenseType = match . getLicenseType ( ) ; // The editions is a list of strings List < String > editions = match . getEditions ( ) ; products . add ( new ProductRequirementInformation ( versionRange , productId , installType , licenseType , editions ) ) ; } return products ; }
Parse an appliesTo string to produce a list of product requirements