Revision: 5777
Author: [email protected]
Date: Thu Jul 23 08:25:36 2009
Log: Edited wiki page through web user interface.
http://code.google.com/p/google-web-toolkit/source/detail?r=5777
Modified:
/wiki/WhyWidgetIsAClass.wiki
=======================================
--- /wiki/WhyWidgetIsAClass.wiki Thu Jul 23 06:46:57 2009
+++ /wiki/WhyWidgetIsAClass.wiki Thu Jul 23 08:25:36 2009
@@ -50,8 +50,8 @@
It is sometimes convenient to be able to write methods that require a
parameter that is both a widget, and also requires some interface to be
implemented by it. For example, say I want to write a method that simply
requires a `Widget` that implements `HasText`. There is no
`WidgetThatHasText` interface (one can imagine the interface explosion that
would stem from going down that path), and there couldn't be one because
`Widget` is a class. One solution to this problem is to use something like
the `View<T>` approach above. But you could also use Java's union types,
like so:
{{{
- setHasTextWidget(new Label());
- setHasTextWidget(new HTML());
+ setWidgetThatHasText(new Label());
+ setWidgetThatHasText(new HTML());
<W extends Widget & HasText> void setWidgetThatHasText(W foo) {
RootPanel.get().add(foo);
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---