Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 41873 invoked from network); 11 Feb 2004 16:01:13 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 11 Feb 2004 16:01:13 -0000 Received: (qmail 35333 invoked by uid 500); 11 Feb 2004 16:00:54 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 35270 invoked by uid 500); 11 Feb 2004 16:00:54 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 35179 invoked from network); 11 Feb 2004 16:00:53 -0000 Received: from unknown (HELO main.gmane.org) (80.91.224.249) by daedalus.apache.org with SMTP; 11 Feb 2004 16:00:53 -0000 Received: from root by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 1AqwnH-0006KP-00 for ; Wed, 11 Feb 2004 17:00:55 +0100 Received: from ktv672-251-110.catv-pool.axelero.hu ([62.201.110.251]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed Feb 11 16:00:55 2004 Received: from szegedia by ktv672-251-110.catv-pool.axelero.hu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed Feb 11 16:00:55 2004 X-Injected-Via-Gmane: http://gmane.org/ To: commons-dev@jakarta.apache.org From: "Attila Szegedi" Subject: Bean property comparator Date: Wed, 11 Feb 2004 14:43:36 +0100 Lines: 27 Message-ID: X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: ktv672-251-110.catv-pool.axelero.hu X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Sender: news X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Hi folks, there's one comparator I've been missing from the commons-collection: a comparator that uses a specified bean property of objects to perform the comparisons. Basically, it works like this: if you construct an instance with: Comparator c = new BeanPropertyComparator(Customer.class, "birthDate"); c will use the natural ordering on the values of Customer.getBirthDate() to compare Customer objects. There's an alternative constructor to specify an embedded comparator for comparing the retrieved property values: Comparator c = new BeanPropertyComparator( Customer.class, "birthDate", new ReverseComparator()); Admittedly, the class is fairly trivial, but I already have it implemented and tested - would the project be interested in the contribution? Attila. --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org