abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1221819 - in /abdera/abdera2: activities/src/main/java/org/apache/abdera2/activities/extra/Extra.java test/src/main/java/org/apache/abdera2/test/common/misc/MiscTest.java
Date Wed, 21 Dec 2011 17:33:57 GMT
Author: jmsnell
Date: Wed Dec 21 17:33:57 2011
New Revision: 1221819

URL: http://svn.apache.org/viewvc?rev=1221819&view=rev
Log:
the pair indexer in the mapred example is generically useful... 

Modified:
    abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/Extra.java
    abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/misc/MiscTest.java

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/Extra.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/Extra.java?rev=1221819&r1=1221818&r2=1221819&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/Extra.java
(original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/extra/Extra.java
Wed Dec 21 17:33:57 2011
@@ -47,6 +47,7 @@ import org.apache.abdera2.common.anno.Na
 import org.apache.abdera2.common.date.DateTimes;
 import org.apache.abdera2.common.misc.ExceptionHelper;
 import org.apache.abdera2.common.misc.MoreFunctions;
+import org.apache.abdera2.common.misc.Pair;
 import org.apache.abdera2.common.selector.AbstractSelector;
 import org.apache.abdera2.common.selector.PropertySelector;
 import org.apache.abdera2.common.selector.Selector;
@@ -1543,4 +1544,15 @@ public final class Extra {
     }
     return mt;
   }
+  
+  public static <X extends ASObject>Function<Collection<X>,Iterable<Pair<Void,
X>>> pairIndexer() { 
+    return new Function<Collection<X>,Iterable<Pair<Void, X>>>()
{
+      public Iterable<Pair<Void, X>> apply(Collection<X> input) {
+        return 
+          Pair.<Void,X>make()
+            .index(MoreFunctions.<X>alwaysVoid(), input.getItems());
+      }
+    };
+  }
+  
 }

Modified: abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/misc/MiscTest.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/misc/MiscTest.java?rev=1221819&r1=1221818&r2=1221819&view=diff
==============================================================================
--- abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/misc/MiscTest.java (original)
+++ abdera/abdera2/test/src/main/java/org/apache/abdera2/test/common/misc/MiscTest.java Wed
Dec 21 17:33:57 2011
@@ -20,6 +20,7 @@ import java.util.concurrent.ExecutorServ
 import java.util.concurrent.Future;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import org.apache.abdera2.activities.extra.Extra;
 import org.apache.abdera2.activities.model.ASObject;
 import org.apache.abdera2.activities.model.Activity;
 import org.apache.abdera2.activities.model.Collection;
@@ -275,15 +276,6 @@ public class MiscTest {
   private final static ExecutorService exec = 
     MoreExecutors2.getExitingExecutor();
   
-  private static final Function<Collection<Activity>,Iterable<Pair<Void, Activity>>>
transform = 
-    new Function<Collection<Activity>,Iterable<Pair<Void, Activity>>>()
{
-      public Iterable<Pair<Void, Activity>> apply(Collection<Activity>
input) {
-        return 
-          Pair.<Void,Activity>make()
-            .index(MoreFunctions.<Activity>alwaysVoid(), input.getItems());
-      }
-  };
-  
   private final static Function<
     Collection<Activity>, 
     Future<Iterable<Pair<Integer,Iterable<String>>>>> ff = 
@@ -291,7 +283,7 @@ public class MiscTest {
     MoreFunctions.<
       Iterable<Pair<Void, Activity>>, 
       Iterable<Pair<Integer,Iterable<String>>>>futureFunction(f3,exec),
-    transform);
+    Extra.<Activity>pairIndexer());
 
   private Activity getActivity(String name,int n) {
     return Activity.makeActivity()



Mime
View raw message