On Wed, 27 Aug 2008 17:12:40 +0200
"Christian Migowski" <[EMAIL PROTECTED]> wrote:

> Hello,
> 
> see comment below.
> 
> 2008/8/27, Emmanuel Lecharny [EMAIL PROTECTED]:
> >
> >
> >   public void setFilters(Map<String, ? extends IoFilter> filters) {
> >       if (filters == null) {
> >           throw new NullPointerException("filters");
> >       }
> >             if (!isOrderedMap(filters)) {
> >           ...
> >
> >   @SuppressWarnings("unchecked")
> >   private boolean isOrderedMap(Map map) {
> >       Class<?> mapType = map.getClass();
> >       ...
> >       Random rand = new Random();
> >       List<String> expectedNames = new ArrayList<String>();
> >       IoFilter dummyFilter = new IoFilterAdapter();
> > <------------------------------this is here.
> >             for (int i = 0; i < 65536; i ++) {
> > // WTF is this loop ???
> >           String filterName;
> >                     do {
> >               filterName = String.valueOf(rand.nextInt());
> >           } while (newMap.containsKey(filterName));
> 
> 
> it generates a "unique" new key to be inserted in the new Map.
> Cleverly you omitted the comment that exists in the code:
> 
> // Last resort: try to create a new instance and test if it maintains
> // the insertion order.
> 
> you'll see why it is important to maintain the filter order that the
> user intended to have - even if HE/SHE made a mistake by choosing the
> wrong collection.
> 
> Here is my opinion: It's this small bits and pieces and checks that
> try to cover _everything_ that make a framework worth using. If a
> framework just provides some sloppy checking and will fail
> mysteriously (depending on the filters, it could be quite difficult
> to fiddle out the mistake if the order in the map wasn't maintained),
> you are maybe better of doing it all by yourself. Just because
> something isn't understood doesn't mean it is a bad thing.
> 
> christian
> 

Hi,
I'll avoid the lyric part about what a framework is supposed to be :)

My preoccupation is to know if we need such a mechanism for changing the
map. Who use this setFilter method, and why ?

Julien

Attachment: signature.asc
Description: PGP signature

Reply via email to