Return-Path: Delivered-To: apmail-incubator-click-dev-archive@minotaur.apache.org Received: (qmail 57565 invoked from network); 16 Jan 2010 18:26:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 16 Jan 2010 18:26:15 -0000 Received: (qmail 69673 invoked by uid 500); 16 Jan 2010 18:26:15 -0000 Delivered-To: apmail-incubator-click-dev-archive@incubator.apache.org Received: (qmail 69601 invoked by uid 500); 16 Jan 2010 18:26:15 -0000 Mailing-List: contact click-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: click-dev@incubator.apache.org Delivered-To: mailing list click-dev@incubator.apache.org Received: (qmail 69590 invoked by uid 99); 16 Jan 2010 18:26:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 16 Jan 2010 18:26:15 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 16 Jan 2010 18:26:14 +0000 Received: from brutus.apache.org (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 7BFD4234C4AA for ; Sat, 16 Jan 2010 10:25:54 -0800 (PST) Message-ID: <1646199535.292731263666354506.JavaMail.jira@brutus.apache.org> Date: Sat, 16 Jan 2010 18:25:54 +0000 (UTC) From: "Andrey Rybin (JIRA)" To: click-dev@incubator.apache.org Subject: [jira] Updated: (CLK-609) Use generics where appropriable In-Reply-To: <959966287.273621263587214451.JavaMail.jira@brutus.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ 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 createPage (Class 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 createPage (Class pageClass) { > return clickServlet.createPage(pageClass, request); > } > @SuppressWarnings("unchecked") > public T createPage (String path) { > return (T) clickServlet.createPage(path, request); > } > ClickServlet: > @SuppressWarnings("unchecked") > protected T createPage (Class 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.