heiko question on list of maps names

John Mazzitelli mazz at redhat.com
Wed Mar 23 22:05:54 UTC 2011


heiko asked this in the #rhq room:

(04:54:53 PM) pil-dinner: in a list of property maps - does the map name 
need to come from the definition (i.e. is the same for all maps) or can 
I use the name of the list row ?

Related to this question are these problems that we had to fix:

https://bugzilla.redhat.com/show_bug.cgi?id=610859
https://bugzilla.redhat.com/show_bug.cgi?id=622486

My comment in 622486 asks "do they really need to be the same? Why is 
PropertyList.add checking this and throwing an exception when the maps 
don't match?"

I don't see why this restriction needs to be there. I see no correlation 
to the names of the map properties found in the list, however, this code 
is in PropertyList.add:

     public void add(@NotNull Property property) {
...
         if (!property.getName().equals(this.memberPropertyName)) {
             throw new IllegalStateException("All properties in a 
PropertyList (id=[" + getId() + "], name=["
                 + getName() + "]) must have the same name: [" + 
property.getName() + "] != [" + this.memberPropertyName
                 + "]");
         }

In other words, if you have a list, all properties you put in the list 
must have the same name. Therefore, if you have a list-o-maps, all maps 
must have the same name and they must be the same name as the parent list.

I don't know why, and I bet if we take out that if-statement, all will 
still work fine. The names should not matter for list items.


More information about the rhq-devel mailing list