commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From simonetrip...@apache.org
Subject svn commit: r1344792 - in /commons/proper/functor/trunk/src: changes/changes.xml main/java/org/apache/commons/functor/core/Limit.java main/java/org/apache/commons/functor/core/Offset.java
Date Thu, 31 May 2012 16:06:36 GMT
Author: simonetripodi
Date: Thu May 31 16:06:36 2012
New Revision: 1344792

URL: http://svn.apache.org/viewvc?rev=1344792&view=rev
Log:
[FUNCTOR-9] Make Limit and Offset Serializable - patch submitted by Bruno P. Kinoshita

Modified:
    commons/proper/functor/trunk/src/changes/changes.xml
    commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/Limit.java
    commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/Offset.java

Modified: commons/proper/functor/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/changes/changes.xml?rev=1344792&r1=1344791&r2=1344792&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/changes/changes.xml (original)
+++ commons/proper/functor/trunk/src/changes/changes.xml Thu May 31 16:06:36 2012
@@ -26,6 +26,9 @@
       <action dev="simonetripodi" issue="FUNCTOR-16" due-to="Bruno P. Kinoshita">
         Fix checkstyle errors
       </action>
+      <action dev="simonetripodi" issue="FUNCTOR-9" due-to="Bruno P. Kinoshita">
+        Make Limit and Offset Serializable
+      </action>
       <action dev="simonetripodi" issue="FUNCTOR-8" due-to="Bruno P. Kinoshita">
         Possible NPE in TransformedGenerator if getWrappedGenerator() is overridden to return
null
       </action>

Modified: commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/Limit.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/Limit.java?rev=1344792&r1=1344791&r2=1344792&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/Limit.java
(original)
+++ commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/Limit.java
Thu May 31 16:06:36 2012
@@ -17,6 +17,8 @@
  */
 package org.apache.commons.functor.core;
 
+import java.io.Serializable;
+
 import org.apache.commons.functor.BinaryPredicate;
 import org.apache.commons.functor.Predicate;
 import org.apache.commons.functor.UnaryPredicate;
@@ -32,8 +34,14 @@ import org.apache.commons.functor.UnaryP
  * @author Rodney Waldhoff
  */
 
-public final class Limit implements Predicate, UnaryPredicate<Object>, BinaryPredicate<Object,
Object> {
-    // instance variables
+public final class Limit implements Predicate, UnaryPredicate<Object>, BinaryPredicate<Object,
Object>, Serializable {
+	// static attributes
+    // ------------------------------------------------------------------------
+    /**
+	 * serialVersionUID declaration.
+	 */
+	private static final long serialVersionUID = 8974528922587619067L;
+	// instance variables
     //---------------------------------------------------------------
     /**
      * The max number of times the predicate can be invoked.
@@ -85,6 +93,32 @@ public final class Limit implements Pred
      * {@inheritDoc}
      */
     @Override
+    public boolean equals(Object obj) {
+    	if(obj == this) {
+    		return true;
+    	}
+    	if(!(obj instanceof Limit)) {
+    		return false;
+    	}
+    	Limit other = (Limit)obj;
+    	return other.max == max;
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public int hashCode() {
+    	int result = "Limit".hashCode();
+    	result <<= 2;
+    	result ^= max;
+    	return result;
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
+    @Override
     public String toString() {
         return "Limit<" + max + ">";
     }

Modified: commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/Offset.java
URL: http://svn.apache.org/viewvc/commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/Offset.java?rev=1344792&r1=1344791&r2=1344792&view=diff
==============================================================================
--- commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/Offset.java
(original)
+++ commons/proper/functor/trunk/src/main/java/org/apache/commons/functor/core/Offset.java
Thu May 31 16:06:36 2012
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.functor.core;
 
+import java.io.Serializable;
+
 import org.apache.commons.functor.BinaryPredicate;
 import org.apache.commons.functor.Predicate;
 import org.apache.commons.functor.UnaryPredicate;
@@ -31,8 +33,15 @@ import org.apache.commons.functor.UnaryP
  * @author Rodney Waldhoff
  */
 
-public final class Offset implements Predicate, UnaryPredicate<Object>, BinaryPredicate<Object,
Object> {
-    // instance variables
+public final class Offset implements Predicate, UnaryPredicate<Object>, BinaryPredicate<Object,
Object>, Serializable {
+	// static attributes
+    // ------------------------------------------------------------------------
+    /**
+	 * serialVersionUID declaration.
+	 */
+	private static final long serialVersionUID = 5800706757874735854L;
+	
+	// instance variables
     //---------------------------------------------------------------
     /**
      * The number of times the predicate must return {@code false}.
@@ -84,6 +93,32 @@ public final class Offset implements Pre
      * {@inheritDoc}
      */
     @Override
+    public boolean equals(Object obj) {
+    	if(obj == this) {
+    		return true;
+    	}
+    	if(!(obj instanceof Offset)) {
+    		return false;
+    	}
+    	Offset other = (Offset)obj;
+    	return other.min == min;
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public int hashCode() {
+    	int result = "Offset".hashCode();
+    	result <<= 2;
+    	result ^= min;
+    	return result;
+    }
+    
+    /**
+     * {@inheritDoc}
+     */
+    @Override
     public String toString() {
         return "Offset<" + min + ">";
     }



Mime
View raw message