You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@click.apache.org by "Andrey Rybin (JIRA)" <ji...@apache.org> on 2010/01/15 21:26:54 UTC
[jira] Created: (CLK-609) Use generics where appropriable
Use generics where appropriable
-------------------------------
Key: CLK-609
URL: https://issues.apache.org/jira/browse/CLK-609
Project: Click
Issue Type: Improvement
Components: core, extras
Reporter: Andrey Rybin
Priority: Minor
Because Click requires Java 1.5, Click can use its generics support.
For example:
Context:
public <T extends Page> T createPage (Class<T> pageClass) {
return clickServlet.createPage(pageClass, request);
}
ClickServlet:
@SuppressWarnings("unchecked")
protected <T extends Page> T createPage (Class<T> pageClass, HttpServletRequest request) {
String path = getConfigService().getPagePath(pageClass);
if (path == null) {
String msg =
"No path configured for Page class: " + pageClass.getName();
throw new IllegalArgumentException(msg);
}
return (T) initPage(path, pageClass, request);
}
then you can do:
MyPage1 x = getContext() .createPage(MyPage1.class);//no explicit cast
getContext() .createPage(String.class);//compilation error, red code in IDE
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CLK-609) Use generics where appropriable
Posted by "Andrey Rybin (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CLK-609?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12800896#action_12800896 ]
Andrey Rybin commented on CLK-609:
----------------------------------
or this ;-)
@SuppressWarnings("unchecked")
protected <T extends Page> T createPage (Class<T> pageClass, HttpServletRequest request) {
String path = getConfigService().getPagePath(pageClass);
if (path == null) {
throw new IllegalArgumentException("No path configured for Page class: " + pageClass.getName());
}
return (T) initPage(path, pageClass, request);
}
> Use generics where appropriable
> -------------------------------
>
> Key: CLK-609
> URL: https://issues.apache.org/jira/browse/CLK-609
> Project: Click
> Issue Type: Improvement
> Components: core, extras
> Reporter: Andrey Rybin
> Priority: Minor
>
> Because Click requires Java 1.5, Click can use its generics support.
> For example:
> Context:
> public <T extends Page> T createPage (Class<T> pageClass) {
> return clickServlet.createPage(pageClass, request);
> }
> ClickServlet:
> @SuppressWarnings("unchecked")
> protected <T extends Page> T createPage (Class<T> pageClass, HttpServletRequest request) {
> String path = getConfigService().getPagePath(pageClass);
> if (path == null) {
> String msg =
> "No path configured for Page class: " + pageClass.getName();
> throw new IllegalArgumentException(msg);
> }
> return (T) initPage(path, pageClass, request);
> }
> then you can do:
> MyPage1 x = getContext() .createPage(MyPage1.class);//no explicit cast
> getContext() .createPage(String.class);//compilation error, red code in IDE
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (CLK-609) Use generics where appropriable
Posted by "Andrey Rybin (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CLK-609?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrey Rybin updated CLK-609:
-----------------------------
Comment: was deleted
(was: or this ;-)
@SuppressWarnings("unchecked")
protected <T extends Page> T createPage (Class<T> pageClass, HttpServletRequest request) {
String path = getConfigService().getPagePath(pageClass);
if (path == null) {
throw new IllegalArgumentException("No path configured for Page class: " + pageClass.getName());
}
return (T) initPage(path, pageClass, request);
} )
> Use generics where appropriable
> -------------------------------
>
> Key: CLK-609
> URL: https://issues.apache.org/jira/browse/CLK-609
> Project: Click
> Issue Type: Improvement
> Components: core, extras
> Reporter: Andrey Rybin
> Priority: Minor
>
> Because Click requires Java 1.5, Click can use its generics support.
> For example:
> Context:
> public <T extends Page> T createPage (Class<T> pageClass) {
> return clickServlet.createPage(pageClass, request);
> }
> @SuppressWarnings("unchecked")
> public <T extends Page> T createPage (String path) {
> return (T) clickServlet.createPage(path, request);
> }
> ClickServlet:
> @SuppressWarnings("unchecked")
> protected <T extends Page> T createPage (Class<T> pageClass, HttpServletRequest request) {
> String path = getConfigService().getPagePath(pageClass);
> if (path == null) {
> throw new IllegalArgumentException("No path configured for Page class: " + pageClass.getName());
> }
> return (T) initPage(path, pageClass, request);
> }
> then you can do:
> MyPage1 x = getContext() .createPage(MyPage1.class);//no explicit cast
> getContext() .createPage(String.class);//compilation error, red code in IDE
> AdminPage p = getContext() .createPage("/admin/edit.htm");// implicitly cast - Runtime check, but looks nice
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (CLK-609) Use generics where appropriable
Posted by "Malcolm Edgar (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CLK-609?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12801144#action_12801144 ]
Malcolm Edgar commented on CLK-609:
-----------------------------------
I think we are a the point now where the simple uses of generics are reasonably well understood. What do people thing?
I think the Apache Click 2.2 release should include using Java 1.5 features were appropriate to improve the type safety of the API.
regards Malcolm Edgar
> Use generics where appropriable
> -------------------------------
>
> Key: CLK-609
> URL: https://issues.apache.org/jira/browse/CLK-609
> Project: Click
> Issue Type: Improvement
> Components: core, extras
> Reporter: Andrey Rybin
> Priority: Minor
>
> Because Click requires Java 1.5, Click can use its generics support.
> For example:
> Context:
> public <T extends Page> T createPage (Class<T> pageClass) {
> return clickServlet.createPage(pageClass, request);
> }
> ClickServlet:
> @SuppressWarnings("unchecked")
> protected <T extends Page> T createPage (Class<T> pageClass, HttpServletRequest request) {
> String path = getConfigService().getPagePath(pageClass);
> if (path == null) {
> String msg =
> "No path configured for Page class: " + pageClass.getName();
> throw new IllegalArgumentException(msg);
> }
> return (T) initPage(path, pageClass, request);
> }
> then you can do:
> MyPage1 x = getContext() .createPage(MyPage1.class);//no explicit cast
> getContext() .createPage(String.class);//compilation error, red code in IDE
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (CLK-609) Use generics where appropriable
Posted by "Andrey Rybin (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/CLK-609?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrey Rybin updated CLK-609:
-----------------------------
Description:
Because Click requires Java 1.5, Click can use its generics support.
For example:
Context:
public <T extends Page> T createPage (Class<T> pageClass) {
return clickServlet.createPage(pageClass, request);
}
@SuppressWarnings("unchecked")
public <T extends Page> T createPage (String path) {
return (T) clickServlet.createPage(path, request);
}
ClickServlet:
@SuppressWarnings("unchecked")
protected <T extends Page> T createPage (Class<T> pageClass, HttpServletRequest request) {
String path = getConfigService().getPagePath(pageClass);
if (path == null) {
throw new IllegalArgumentException("No path configured for Page class: " + pageClass.getName());
}
return (T) initPage(path, pageClass, request);
}
then you can do:
MyPage1 x = getContext() .createPage(MyPage1.class);//no explicit cast
getContext() .createPage(String.class);//compilation error, red code in IDE
AdminPage p = getContext() .createPage("/admin/edit.htm");// implicitly cast - Runtime check, but looks nice
was:
Because Click requires Java 1.5, Click can use its generics support.
For example:
Context:
public <T extends Page> T createPage (Class<T> pageClass) {
return clickServlet.createPage(pageClass, request);
}
ClickServlet:
@SuppressWarnings("unchecked")
protected <T extends Page> T createPage (Class<T> pageClass, HttpServletRequest request) {
String path = getConfigService().getPagePath(pageClass);
if (path == null) {
String msg =
"No path configured for Page class: " + pageClass.getName();
throw new IllegalArgumentException(msg);
}
return (T) initPage(path, pageClass, request);
}
then you can do:
MyPage1 x = getContext() .createPage(MyPage1.class);//no explicit cast
getContext() .createPage(String.class);//compilation error, red code in IDE
> Use generics where appropriable
> -------------------------------
>
> Key: CLK-609
> URL: https://issues.apache.org/jira/browse/CLK-609
> Project: Click
> Issue Type: Improvement
> Components: core, extras
> Reporter: Andrey Rybin
> Priority: Minor
>
> Because Click requires Java 1.5, Click can use its generics support.
> For example:
> Context:
> public <T extends Page> T createPage (Class<T> pageClass) {
> return clickServlet.createPage(pageClass, request);
> }
> @SuppressWarnings("unchecked")
> public <T extends Page> T createPage (String path) {
> return (T) clickServlet.createPage(path, request);
> }
> ClickServlet:
> @SuppressWarnings("unchecked")
> protected <T extends Page> T createPage (Class<T> pageClass, HttpServletRequest request) {
> String path = getConfigService().getPagePath(pageClass);
> if (path == null) {
> throw new IllegalArgumentException("No path configured for Page class: " + pageClass.getName());
> }
> return (T) initPage(path, pageClass, request);
> }
> then you can do:
> MyPage1 x = getContext() .createPage(MyPage1.class);//no explicit cast
> getContext() .createPage(String.class);//compilation error, red code in IDE
> AdminPage p = getContext() .createPage("/admin/edit.htm");// implicitly cast - Runtime check, but looks nice
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.