From: <res...@us...> - 2010-09-28 13:57:04
|
Revision: 3659 http://bigdata.svn.sourceforge.net/bigdata/?rev=3659&view=rev Author: resendes Date: 2010-09-28 13:36:17 +0000 (Tue, 28 Sep 2010) Log Message: ----------- Last batch of code for com.bigdata.util package Modified Paths: -------------- branches/bbb_cleanup/bigdata-core/src/main/java/com/bigdata/util/NT.java branches/bbb_cleanup/bigdata-core/src/main/java/com/bigdata/util/NV.java branches/bbb_cleanup/bigdata-core/src/main/java/com/bigdata/util/ReverseLongComparator.java branches/bbb_cleanup/bigdata-core/src/test/java/com/bigdata/util/TestAll.java Added Paths: ----------- branches/bbb_cleanup/bigdata-core/src/test/java/com/bigdata/util/TestReverseLongComparator.java Modified: branches/bbb_cleanup/bigdata-core/src/main/java/com/bigdata/util/NT.java =================================================================== --- branches/bbb_cleanup/bigdata-core/src/main/java/com/bigdata/util/NT.java 2010-09-28 12:43:35 UTC (rev 3658) +++ branches/bbb_cleanup/bigdata-core/src/main/java/com/bigdata/util/NT.java 2010-09-28 13:36:17 UTC (rev 3659) @@ -69,7 +69,8 @@ @Override public boolean equals(Object o) { - + if (this==o) return true; + if (!(o instanceof NT)) { /* Modified: branches/bbb_cleanup/bigdata-core/src/main/java/com/bigdata/util/NV.java =================================================================== --- branches/bbb_cleanup/bigdata-core/src/main/java/com/bigdata/util/NV.java 2010-09-28 12:43:35 UTC (rev 3658) +++ branches/bbb_cleanup/bigdata-core/src/main/java/com/bigdata/util/NV.java 2010-09-28 13:36:17 UTC (rev 3659) @@ -65,6 +65,8 @@ @Override public boolean equals(Object o) { + if (this==o) return true; + if (!(o instanceof NV)) { return false; } Modified: branches/bbb_cleanup/bigdata-core/src/main/java/com/bigdata/util/ReverseLongComparator.java =================================================================== --- branches/bbb_cleanup/bigdata-core/src/main/java/com/bigdata/util/ReverseLongComparator.java 2010-09-28 12:43:35 UTC (rev 3658) +++ branches/bbb_cleanup/bigdata-core/src/main/java/com/bigdata/util/ReverseLongComparator.java 2010-09-28 13:36:17 UTC (rev 3659) @@ -33,17 +33,19 @@ /** * Places {@link Long} values into descending order. - * + * Note: Creates a comparator that compares objects based on the inverse of their + * natural ordering. * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ */ public class ReverseLongComparator implements Comparator<Long>, Serializable { + private static final long serialVersionUID = -234224494051463945L; + /** - * + * Provides an inverse comparison to the <code>Comparator</code> interface. + * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ - private static final long serialVersionUID = -234224494051463945L; - public int compare(final Long o1, final Long o2) { final long l1 = o1.longValue(); Modified: branches/bbb_cleanup/bigdata-core/src/test/java/com/bigdata/util/TestAll.java =================================================================== --- branches/bbb_cleanup/bigdata-core/src/test/java/com/bigdata/util/TestAll.java 2010-09-28 12:43:35 UTC (rev 3658) +++ branches/bbb_cleanup/bigdata-core/src/test/java/com/bigdata/util/TestAll.java 2010-09-28 13:36:17 UTC (rev 3659) @@ -28,7 +28,6 @@ package com.bigdata.util; -import com.bigdata.io.TestChecksumUtility; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; @@ -63,16 +62,16 @@ TestSuite suite = new TestSuite("util"); - // test of the millisecond resolution timestamp factory. - suite.addTestSuite( TestMillisecondTimestampFactory.class ); - + suite.addTestSuite( TestBootStateUtil.class ); suite.addTestSuite( TestCSVReader.class ); - suite.addTestSuite( TestBootStateUtil.class ); suite.addTestSuite( TestEntryUtil.class ); suite.addTestSuite( TestFormat.class ); suite.addTestSuite( TestHTMLUtility.class ); + suite.addTestSuite( TestInnerCause.class ); + suite.addTestSuite( TestMillisecondTimestampFactory.class ); suite.addTestSuite( TestNT.class ); suite.addTestSuite( TestNV.class ); + suite.addTestSuite( TestReverseLongComparator.class ); return suite; } Added: branches/bbb_cleanup/bigdata-core/src/test/java/com/bigdata/util/TestReverseLongComparator.java =================================================================== --- branches/bbb_cleanup/bigdata-core/src/test/java/com/bigdata/util/TestReverseLongComparator.java (rev 0) +++ branches/bbb_cleanup/bigdata-core/src/test/java/com/bigdata/util/TestReverseLongComparator.java 2010-09-28 13:36:17 UTC (rev 3659) @@ -0,0 +1,26 @@ +package com.bigdata.util; + +import junit.framework.TestCase; + +public class TestReverseLongComparator extends TestCase { + + public TestReverseLongComparator(String name) { + super(name); + } + + // Note: reverse comparison --> reverse of compare contract + public void testCompare_non_negative() { + ReverseLongComparator comp = new ReverseLongComparator(); + assertTrue(comp.compare(1L, 2L) > 0); + assertTrue(comp.compare(1L, 1L) == 0); + assertTrue(comp.compare(1L, 0L) < 1); + } + + public void testCompare_negative() { + ReverseLongComparator comp = new ReverseLongComparator(); + assertTrue(comp.compare(-2L, -1L) > 0); + assertTrue(comp.compare(-1L, -1L) == 0); + assertTrue(comp.compare(0L, -1L) < 1); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |