pivot-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Greg Brown (JIRA)" <j...@apache.org>
Subject [jira] Issue Comment Edited: (PIVOT-670) Generic types for listeners
Date Tue, 16 Nov 2010 15:28:14 GMT

    [ https://issues.apache.org/jira/browse/PIVOT-670?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12932496#action_12932496
] 

Greg Brown edited comment on PIVOT-670 at 11/16/10 10:26 AM:
-------------------------------------------------------------

That's a slippery slope. If we did that, we'd probably also want to make every listener interface
a generic for consistency. I personally don't think it is worth it. IMO, there's nothing wrong
with casting when you know what type to expect. Either way (explicit cast or generic type),
you're going to get a ClassCastException if you do the wrong thing.


      was (Author: gbrown):
    That's a slippery slope. If we did that, we'd probably also want to make every listener
interface a generic, for consistency. I personally don't think it is worth it. IMO, there's
nothing wrong with casting when you know what type to expect. Either way (cast or generic
type), you're going to get a ClassCastException if you do the wrong thing.

  
> Generic types for listeners
> ---------------------------
>
>                 Key: PIVOT-670
>                 URL: https://issues.apache.org/jira/browse/PIVOT-670
>             Project: Pivot
>          Issue Type: Improvement
>         Environment: All
>            Reporter: Frédéric VERGEZ
>            Priority: Trivial
>
> Could listener interfaces have generic types ?
> This would allow to be type safe in methods, and avoid objects casting.
> For instance in a ComponentMouseListener:
> public interface ComponentMouseListener<T extends Component> {
>     /**
>      * Component mouse button listener adapter.
>      */
>     public static class Adapter implements ComponentMouseListener {
>         @Override
>         public boolean mouseMove(T component, int x, int y) {
>             return false;
>         }
>         @Override
>         public void mouseOver(T component) {
>         }
>         @Override
>         public void mouseOut(T component) {
>         }
>     }
>     /**
>      * Called when the mouse is moved over a component.
>      *
>      * @param component
>      * @param x
>      * @param y
>      *
>      * @return
>      * <tt>true</tt> to consume the event; <tt>false</tt> to
allow it to
>      * propagate.
>      */
>     public boolean mouseMove(T component, int x, int y);
>     /**
>      * Called when the mouse enters a component.
>      *
>      * @param component
>      */
>     public void mouseOver(T component);
>     /**
>      * Called when the mouse exits a component.
>      *
>      * @param component
>      */
>     public void mouseOut(T component);
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message