[FUNCTOR-27] add static method to Limit to create new instances
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/functor/trunk@1482663 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/core/src/main/java/org/apache/commons/functor/core/Limit.java b/core/src/main/java/org/apache/commons/functor/core/Limit.java
index 0a2e04f..e5451d6 100644
--- a/core/src/main/java/org/apache/commons/functor/core/Limit.java
+++ b/core/src/main/java/org/apache/commons/functor/core/Limit.java
@@ -121,4 +121,17 @@
}
//default == equals/hashCode due to statefulness
+
+ // static methods
+ // ------------------------------------------------------------------------
+
+ /**
+ * Get a Limit instance for the specified value.
+ * @param count limit
+ * @return Limit
+ */
+ public static Limit of(int count) {
+ return new Limit(count);
+ }
+
}
diff --git a/core/src/test/java/org/apache/commons/functor/core/TestLimit.java b/core/src/test/java/org/apache/commons/functor/core/TestLimit.java
index 29cff99..00e6495 100644
--- a/core/src/test/java/org/apache/commons/functor/core/TestLimit.java
+++ b/core/src/test/java/org/apache/commons/functor/core/TestLimit.java
@@ -16,6 +16,7 @@
*/
package org.apache.commons.functor.core;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -94,4 +95,13 @@
assertObjectsAreNotEqual(new Limit(2), limit);
assertTrue(!limit.equals(null));
}
+
+ @Test
+ public void testLimits() {
+ Limit limit = new Limit(1);
+ assertEquals(Limit.of(1), limit);
+
+ assertObjectsAreEqual(Limit.of(1), limit);
+ assertObjectsAreNotEqual(Limit.of(3), limit);
+ }
}
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 4eece4e..bf041bd 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -23,6 +23,9 @@
</properties>
<body>
<release version="1.0" date="2012-??-??" description="First release.">
+ <action issue="FUNCTOR-27" dev="kinow">
+ Add static Limit#of method to create new Limit's.
+ </action>
<action issue="FUNCTOR-23" dev="simonetripodi" due-to="Liviu Tudor">
aggregator.xml generates broken JavaDoc links
</action>