Return-Path: X-Original-To: apmail-commons-dev-archive@www.apache.org Delivered-To: apmail-commons-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9BCAB101A1 for ; Wed, 16 Oct 2013 19:50:15 +0000 (UTC) Received: (qmail 63184 invoked by uid 500); 16 Oct 2013 19:50:12 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 63095 invoked by uid 500); 16 Oct 2013 19:50:12 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 63087 invoked by uid 99); 16 Oct 2013 19:50:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Oct 2013 19:50:12 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy includes SPF record at spf.trusted-forwarder.org) Received: from [212.227.126.171] (HELO moutng.kundenserver.de) (212.227.126.171) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Oct 2013 19:50:04 +0000 Received: from [192.168.178.21] (dslb-088-069-255-173.pools.arcor-ip.net [88.69.255.173]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0MhPmw-1V9w0Q1xII-00MuQv; Wed, 16 Oct 2013 21:49:44 +0200 Message-ID: <525EEDD6.1000502@oliver-heger.de> Date: Wed, 16 Oct 2013 21:49:42 +0200 From: Oliver Heger User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 MIME-Version: 1.0 To: Commons Developers List Subject: [BeanUtils] Generics for BeanComparator X-Enigmail-Version: 1.5.2 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:bInJ0Sx72V2jNsP/yQpCRkYx6DBKT5D898U1mQIHmdR x8Udo/SDadn8BtNTZEtN/IU3VQsX7Pl/qmcnVhK5OlXV6ZbM0h aWNejvs6YRhQxPxZNexcgNaiBgQvQg+avTZOKv/Ul+WLUXXG+3 BFQ/k0YQnrRPX9Gnws+pK2pD8WWH/GgbXJJvksSA129kSWdR8e SYVhSOyaYKfRgAUwPTOkUn/Nfw+sAG+HVxgXs41lyi1/lwTWKo NX3BVSWf4RqY1SgGDfVHgHryBNBgoEs/T5E2qg+lVZNXCsNUjk voUlTpGWmm7+UbskBzOqLJwh3ENnkwWEI732t5my7GDeKU3sol 7hTggcrUKVClWiTMm5sY= X-Virus-Checked: Checked by ClamAV on apache.org There is another complicated one: BeanComparator implements Comparator in a way that it compares a given property of a specific bean class. The actual comparison is handled by another Comparator stored in a member field. So I am tempted to transform it to BeanComparator where T is the bean class and P is the type of the property. The internal Comparator would then be of type

. However, this does not really work out for the following reasons: - The internal comparator can be passed to the constructor, but this is optional. If it is not defined, a helper class from [collections] is used providing a generic Comparator on Comparable objects. How can this be aligned to the type parameter? - The value of the property to be compared is obtained using PropertyUtils which returns an Object. So there is no chance for the compiler to do type checks. Perhaps we can check manually whether the value of the property is of the expected type, but this implies that we have to determine the class of the type parameter at runtime. AFAIK this is not always possible, e.g. if a subclass is created which does not have type parameters. Any ideas? Thanks Oliver --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org