Bug 200605 - Consider IInstallableUnit helper methods
Summary: Consider IInstallableUnit helper methods
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: p2 (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M3   Edit
Assignee: John Arthorne CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks:
 
Reported: 2007-08-20 16:35 EDT by Susan McCourt CLA
Modified: 2008-10-17 17:31 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Susan McCourt CLA 2007-08-20 16:35:25 EDT
I wrote a snippet today to see if an array of required capabilities is satisfied by an IU.  It would be cool if an IU had a method like

iu.satisfies(RequiredCapability [] requirements)

There are probably other helpers like this that would be nice.
I don't mind writing them but I observe lots of similar code throughout the core, and it would be worth a review pass to look for places where helpers would consolidate the code.  For example, just look for references to getProvidedCapabilities() and you'll see lots of similar code.

(As a side note, I see places where ProvidedCapability.isSatisifiedBy could be used.  For example, 
>Picker.findInstallableUnit(id, range, searchedCapability, fragmentsOnly)
could be calling this method instead of doing the same check internally.
Comment 1 Pascal Rapicault CLA 2008-09-08 20:56:07 EDT
Susan, do you think this got addressed?
Comment 2 Susan McCourt CLA 2008-09-11 12:32:10 EDT
I think there are less repetitions of the code pattern now that we have some generalized queries for capabilities.

I would like to see the following happen:
- rename ProvidedCapability.isSatisifiedBy(RequiredCapability cap)
to ProvidedCapability.satisfies(RequiredCapability cap)
See the //TODO comment in the code.  This came up again recently in the mailing list.

- add a method IInstallableUnit.satisfies(RequiredCapability cap) which will iterate the provided capabilities and call the method.

This is a API cleanup item.  The rename is more important than the additional helper.
Comment 3 John Arthorne CLA 2008-10-17 16:15:51 EDT
I got onto doing some miscellaneous API cleanup today, so I'll take this. Since there will be massive API change in M3 we might as well get easy ones like this out of the way now.
Comment 4 John Arthorne CLA 2008-10-17 16:39:30 EDT
I have renamed isSatisfiedBy to satisfies, and added the same helper method to IInstallableUnit. I changed several references to use this new helper, which eliminated (hid) several for loops.
Comment 5 John Arthorne CLA 2008-10-17 17:31:45 EDT
Tests added to InstallableUnitTest