You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by "Emond Papegaaij (Commented) (JIRA)" <ji...@apache.org> on 2012/02/09 20:54:57 UTC
[jira] [Commented] (WICKET-3805) Change Component#visitParents to
enable visitors of any type
[ https://issues.apache.org/jira/browse/WICKET-3805?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13204788#comment-13204788 ]
Emond Papegaaij commented on WICKET-3805:
-----------------------------------------
I think the correct signature (if Java would have permitted it) should be:
public final <R,C extends Component & T, T> R visitParents(final Class<T> c, final IVisitor<? super C, R> visitor)
The problem is that java does not allow intersection types with type parameters. So we have to choose between 'C extends T' or 'C extends Component'. I think C extends T is the best option, but this makes it impossible to use a visitor on Component if T is an interface:
public final <R, T> R visitParents(final Class<T> c, final IVisitor<? super T, R> visitor)
Another option is 2 methods, one for interfaces and one for components, so add this one:
public final <R, T> R visitParentContainers(final Class<?> c, final IVisitor<? super MarkupContainer, R> visitor)
In either case, it is important to use '? super X', because it allows you to reuse visitors for which C is bound to a superclass (just as with Comparator).
> Change Component#visitParents to enable visitors of any type
> ------------------------------------------------------------
>
> Key: WICKET-3805
> URL: https://issues.apache.org/jira/browse/WICKET-3805
> Project: Wicket
> Issue Type: Improvement
> Components: wicket
> Affects Versions: 1.5-RC4
> Reporter: Pedro Santos
> Priority: Minor
> Fix For: 6.0.0
>
> Attachments: WICKET-3805.patch
>
>
> The generic type of c accepts any type, but the one in IVisitor restrict it to Components.
> Comonent#visitParents(final Class<?> c, final IVisitor<Component, R> visitor)
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira