private RepositoryResource getNonProductResourceWithHigherVersion ( RepositoryResource res1 , RepositoryResource res2 ) { if ( res1 . getVersion ( ) == null || res2 . getVersion ( ) == null ) { return res1 ; // don't have two versions so can't compare } // have two String versions .. convert them into Version objects,checking that they are valid versions in the process Version4Digit res1Version = null ; Version4Digit res2Version = null ; try { res1Version = new Version4Digit ( res1 . getVersion ( ) ) ; res2Version = new Version4Digit ( res2 . getVersion ( ) ) ; } catch ( IllegalArgumentException iae ) { // at least one of the one or more of Versions is not a proper osgi // version so we cannot compare the version fields. Just return res1. return res1 ; } if ( res1Version . compareTo ( res2Version ) > 0 ) { return res1 ; } else { return res2 ; } }
Return the resource with the highest version for when the appliesTo versions are equal