Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id ED1499311 for ; Tue, 3 Jul 2012 23:04:21 +0000 (UTC) Received: (qmail 10927 invoked by uid 500); 3 Jul 2012 23:04:21 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 10874 invoked by uid 500); 3 Jul 2012 23:04:21 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 10864 invoked by uid 99); 3 Jul 2012 23:04:21 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Jul 2012 23:04:21 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Jul 2012 23:04:19 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 26EBC23889BB for ; Tue, 3 Jul 2012 23:03:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1357004 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math3/util/Pair.java test/java/org/apache/commons/math3/util/PairTest.java Date: Tue, 03 Jul 2012 23:03:57 -0000 To: commits@commons.apache.org From: erans@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120703230358.26EBC23889BB@eris.apache.org> Author: erans Date: Tue Jul 3 23:03:55 2012 New Revision: 1357004 URL: http://svn.apache.org/viewvc?rev=1357004&view=rev Log: MATH-810 Added new accessors. Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Pair.java commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/PairTest.java Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Pair.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Pair.java?rev=1357004&r1=1357003&r2=1357004&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Pair.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/Pair.java Tue Jul 3 23:03:55 2012 @@ -39,8 +39,8 @@ public class Pair { * Create an entry representing a mapping from the specified key to the * specified value. * - * @param k Key. - * @param v Value. + * @param k Key (first element of the pair). + * @param v Value (second element of the pair). */ public Pair(K k, V v) { key = k; @@ -59,7 +59,7 @@ public class Pair { /** * Get the key. * - * @return the key. + * @return the key (first element of the pair). */ public K getKey() { return key; @@ -68,13 +68,31 @@ public class Pair { /** * Get the value. * - * @return the value. + * @return the value (second element of the pair). */ public V getValue() { return value; } /** + * Get the first element of the pair. + * + * @return the first element of the pair. + */ + public K getFirst() { + return key; + } + + /** + * Get the second element of the pair. + * + * @return the second element of the pair. + */ + public V getSecond() { + return value; + } + + /** * Compare the specified object with this entry for equality. * * @param o Object. Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/PairTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/PairTest.java?rev=1357004&r1=1357003&r2=1357004&view=diff ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/PairTest.java (original) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math3/util/PairTest.java Tue Jul 3 23:03:55 2012 @@ -30,6 +30,17 @@ public class PairTest { } @Test + public void testAccessor2() { + final Pair p + = new Pair(new Integer(1), new Double(2)); + + // Check that both APIs refer to the same data. + + Assert.assertTrue(p.getFirst() == p.getKey()); + Assert.assertTrue(p.getSecond() == p.getValue()); + } + + @Test public void testEquals() { Pair p1 = new Pair(null, null); Assert.assertFalse(p1.equals(null));