You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Andrea Del Bene <ad...@ciseonweb.it> on 2012/04/20 15:31:01 UTC

'Strange' code inside TagAttributes

Hi,

working on issue 4505 I've noticed that class TagAttributes has the 
following put method:

     @Override
     public final void putAll(Map<? extends String, ?> map)
     {
         for (Object o : map.keySet())
         {
             String key = (String)o;
         }

         super.putAll(map);
     }

why this method iterates over map keys and then invoke the super 
version? I don't understand the purpose of this method.


Re: 'Strange' code inside TagAttributes

Posted by James Carman <ja...@carmanconsulting.com>.
On Fri, Apr 20, 2012 at 9:39 AM, Martin Grigorov <mg...@apache.org> wrote:
> "? extends String" looks strange too

Yes, especially since String is final.  Curiouser and curiouser. :)

Re: 'Strange' code inside TagAttributes

Posted by Martin Grigorov <mg...@apache.org>.
I just committed my version.

On Fri, Apr 20, 2012 at 4:54 PM, Andrea Del Bene <ad...@ciseonweb.it> wrote:
> Oops! i didn't see your corrected version.
>
>> On Fri, Apr 20, 2012 at 4:44 PM, Andrea Del Bene<ad...@ciseonweb.it>
>>  wrote:
>>>
>>> IMHO this version of putAll can be removed...or not :)?
>>
>> No. Why ?
>> #put() does unescape for the value, so #putAll() should do the same.
>>
>>>> Hi Andrea,
>>>>
>>>> Strange indeed!
>>>> I think it should be :
>>>>
>>>>        @Override
>>>>        public final void putAll(Map<? extends String, ?>    map)
>>>>        {
>>>>                for (Map.Entry<? extends String, ?>    entry :
>>>> map.entrySet())
>>>>                {
>>>>                        String key = entry.getKey();
>>>>                        Object value = entry.getValue();
>>>>                        put(key, value);
>>>>                }
>>>>        }
>>>>
>>>>
>>>> "? extends String" looks strange too
>>>>
>>>> On Fri, Apr 20, 2012 at 4:31 PM, Andrea Del Bene<ad...@ciseonweb.it>
>>>>  wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> working on issue 4505 I've noticed that class TagAttributes has the
>>>>> following put method:
>>>>>
>>>>>    @Override
>>>>>    public final void putAll(Map<? extends String, ?>    map)
>>>>>    {
>>>>>        for (Object o : map.keySet())
>>>>>        {
>>>>>            String key = (String)o;
>>>>>        }
>>>>>
>>>>>        super.putAll(map);
>>>>>    }
>>>>>
>>>>> why this method iterates over map keys and then invoke the super
>>>>> version?
>>>>> I
>>>>> don't understand the purpose of this method.
>>>>>
>>>>
>>
>>
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

Re: 'Strange' code inside TagAttributes

Posted by Andrea Del Bene <ad...@ciseonweb.it>.
Oops! i didn't see your corrected version.
> On Fri, Apr 20, 2012 at 4:44 PM, Andrea Del Bene<ad...@ciseonweb.it>  wrote:
>> IMHO this version of putAll can be removed...or not :)?
> No. Why ?
> #put() does unescape for the value, so #putAll() should do the same.
>
>>> Hi Andrea,
>>>
>>> Strange indeed!
>>> I think it should be :
>>>
>>>         @Override
>>>         public final void putAll(Map<? extends String, ?>    map)
>>>         {
>>>                 for (Map.Entry<? extends String, ?>    entry :
>>> map.entrySet())
>>>                 {
>>>                         String key = entry.getKey();
>>>                         Object value = entry.getValue();
>>>                         put(key, value);
>>>                 }
>>>         }
>>>
>>>
>>> "? extends String" looks strange too
>>>
>>> On Fri, Apr 20, 2012 at 4:31 PM, Andrea Del Bene<ad...@ciseonweb.it>
>>>   wrote:
>>>> Hi,
>>>>
>>>> working on issue 4505 I've noticed that class TagAttributes has the
>>>> following put method:
>>>>
>>>>     @Override
>>>>     public final void putAll(Map<? extends String, ?>    map)
>>>>     {
>>>>         for (Object o : map.keySet())
>>>>         {
>>>>             String key = (String)o;
>>>>         }
>>>>
>>>>         super.putAll(map);
>>>>     }
>>>>
>>>> why this method iterates over map keys and then invoke the super version?
>>>> I
>>>> don't understand the purpose of this method.
>>>>
>>>
>
>


Re: 'Strange' code inside TagAttributes

Posted by Martin Grigorov <mg...@apache.org>.
On Fri, Apr 20, 2012 at 4:44 PM, Andrea Del Bene <ad...@ciseonweb.it> wrote:
> IMHO this version of putAll can be removed...or not :)?

No. Why ?
#put() does unescape for the value, so #putAll() should do the same.

>
>> Hi Andrea,
>>
>> Strange indeed!
>> I think it should be :
>>
>>        @Override
>>        public final void putAll(Map<? extends String, ?>  map)
>>        {
>>                for (Map.Entry<? extends String, ?>  entry :
>> map.entrySet())
>>                {
>>                        String key = entry.getKey();
>>                        Object value = entry.getValue();
>>                        put(key, value);
>>                }
>>        }
>>
>>
>> "? extends String" looks strange too
>>
>> On Fri, Apr 20, 2012 at 4:31 PM, Andrea Del Bene<ad...@ciseonweb.it>
>>  wrote:
>>>
>>> Hi,
>>>
>>> working on issue 4505 I've noticed that class TagAttributes has the
>>> following put method:
>>>
>>>    @Override
>>>    public final void putAll(Map<? extends String, ?>  map)
>>>    {
>>>        for (Object o : map.keySet())
>>>        {
>>>            String key = (String)o;
>>>        }
>>>
>>>        super.putAll(map);
>>>    }
>>>
>>> why this method iterates over map keys and then invoke the super version?
>>> I
>>> don't understand the purpose of this method.
>>>
>>
>>
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

Re: 'Strange' code inside TagAttributes

Posted by Andrea Del Bene <ad...@ciseonweb.it>.
IMHO this version of putAll can be removed...or not :)?
> Hi Andrea,
>
> Strange indeed!
> I think it should be :
>
> 	@Override
> 	public final void putAll(Map<? extends String, ?>  map)
> 	{
> 		for (Map.Entry<? extends String, ?>  entry : map.entrySet())
> 		{
> 			String key = entry.getKey();
> 			Object value = entry.getValue();
> 			put(key, value);
> 		}
> 	}
>
>
> "? extends String" looks strange too
>
> On Fri, Apr 20, 2012 at 4:31 PM, Andrea Del Bene<ad...@ciseonweb.it>  wrote:
>> Hi,
>>
>> working on issue 4505 I've noticed that class TagAttributes has the
>> following put method:
>>
>>     @Override
>>     public final void putAll(Map<? extends String, ?>  map)
>>     {
>>         for (Object o : map.keySet())
>>         {
>>             String key = (String)o;
>>         }
>>
>>         super.putAll(map);
>>     }
>>
>> why this method iterates over map keys and then invoke the super version? I
>> don't understand the purpose of this method.
>>
>
>


Re: 'Strange' code inside TagAttributes

Posted by Martin Grigorov <mg...@apache.org>.
Hi Andrea,

Strange indeed!
I think it should be :

	@Override
	public final void putAll(Map<? extends String, ?> map)
	{
		for (Map.Entry<? extends String, ?> entry : map.entrySet())
		{
			String key = entry.getKey();
			Object value = entry.getValue();
			put(key, value);
		}
	}


"? extends String" looks strange too

On Fri, Apr 20, 2012 at 4:31 PM, Andrea Del Bene <ad...@ciseonweb.it> wrote:
> Hi,
>
> working on issue 4505 I've noticed that class TagAttributes has the
> following put method:
>
>    @Override
>    public final void putAll(Map<? extends String, ?> map)
>    {
>        for (Object o : map.keySet())
>        {
>            String key = (String)o;
>        }
>
>        super.putAll(map);
>    }
>
> why this method iterates over map keys and then invoke the super version? I
> don't understand the purpose of this method.
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com