Closed maggu2810 closed 9 years ago
True .. it is not ordered! Is it possible, sure :smile:
The same is true for the package exports and bundle requirements. All are classes inside BundleInformation
. All of them implement èqualsand
hashCode` in order to be stored in a set. And that is what generates the random order.
The easiest thing would be to implement Comparable
and sort them by name followed by version. However VersionRange
is not comparable either. Another way would be to sort them right before viewing then. Which would be OK from my point of view.
That would be in the bundle de.dentrassi.pm.osgi.web
, the class is OsgiController
.
Will have a look at, next week. Thanks
we may first use a LinkedHashMap to keep original order. Second we may implement an optional alphabetical order.
That sounds like a good idea! So we would keep the order of the MANIFEST.MF
. I would then suggest add a ' Comparator` implementation which takes care of sorting objects by name and version range. This could be a static instance which gets applied before the sets (which are converted to lists or arrays first) are passed on the to view model.
So I would suggest that the first step would be the LinkedHashMap which @cornzy suggested. Because then the extracted information in the meta data will also match the data from the manifest. And it should be an easy change.
Is there any reason to use a map? There is no real key value pair if we want to hold a collection of package imports (package exports, bundle requirements). Why not using a list? We could use Collections.sort(...) if we want to sort the list later.
@ctron Is a LinkedList ok? @cornzy Why you would like to use a LinkedHashMap?
@maggu2810 using a LinkedHashMap instead of normal HashSet preserves the natural order from manifest.
@cornzy Have you read my comment before the one you replied to? ;-) Sure a LinkedHashMap will keep the order, but a LinkedList will also keep the order. What is the reason for using a map, that is normally used to store key value pairs, instead of a list?
Oh sorr! I alway thought about a LinkedHashSet! For any reason I always wrote map...
Oh sorry! I previously considered that you want to write Set instead of Map, but it is a miracle I did not found LinkedHashSet. Sure, a Set is good for this, because multiple identicial entries should not exist. Will do it...
Hi,
A LinkedHashSet is fine. These entries should be unique, and the order is important and shod be stable.
A LinkedList would allow for duplicates, which would be OK from a point of view where the data is as it is.
However I would prefer to limit it to a set, in order to have unique exports/imports.
Hello, would like to know what is the order of the "Package Imports" using "Home / Channel / Artifact / Bundle Information". It seems that this is not ordered. It differs from the order in the manifest and it is not ordered alpha-numerical. Would it be possible to allow to switch between different order (e.g. ascending / descending by name, the one of the manifest, ...)?