Repository: incubator-streams-examples
Updated Branches:
  refs/heads/master 2657909f1 -> 0aadbe243


STREAMS-476: Remove guava dependency from streams-example project, this closes 
apache/incubator-streams#27


Project: http://git-wip-us.apache.org/repos/asf/incubator-streams-examples/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-streams-examples/commit/0aadbe24
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-streams-examples/tree/0aadbe24
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-streams-examples/diff/0aadbe24

Branch: refs/heads/master
Commit: 0aadbe24362301c948b102ffa6ff82db9f709ff3
Parents: 2657909
Author: smarthi <smar...@apache.org>
Authored: Mon Dec 26 20:03:43 2016 -0500
Committer: smarthi <smar...@apache.org>
Committed: Mon Dec 26 20:03:43 2016 -0500

----------------------------------------------------------------------
 .../streams/example/TwitterFollowNeo4j.java     | 10 +++++----
 .../example/TwitterUserstreamElasticsearch.java | 23 ++++++++++----------
 2 files changed, 18 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-streams-examples/blob/0aadbe24/local/twitter-follow-neo4j/src/main/java/org/apache/streams/example/TwitterFollowNeo4j.java
----------------------------------------------------------------------
diff --git 
a/local/twitter-follow-neo4j/src/main/java/org/apache/streams/example/TwitterFollowNeo4j.java
 
b/local/twitter-follow-neo4j/src/main/java/org/apache/streams/example/TwitterFollowNeo4j.java
index 5ffb6ed..e00e4a0 100644
--- 
a/local/twitter-follow-neo4j/src/main/java/org/apache/streams/example/TwitterFollowNeo4j.java
+++ 
b/local/twitter-follow-neo4j/src/main/java/org/apache/streams/example/TwitterFollowNeo4j.java
@@ -36,10 +36,12 @@ import 
org.apache.streams.twitter.converter.TwitterDocumentClassifier;
 import org.apache.streams.twitter.converter.TwitterFollowActivityConverter;
 import org.apache.streams.twitter.provider.TwitterFollowingProvider;
 
-import com.google.common.collect.Lists;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
 /**
  * Collects friend and follow connections for a set of twitter users and 
builds a graph
  * database in neo4j.
@@ -48,7 +50,7 @@ public class TwitterFollowNeo4j implements Runnable {
 
   private final static Logger LOGGER = 
LoggerFactory.getLogger(TwitterFollowNeo4j.class);
 
-  TwitterFollowNeo4jConfiguration config;
+  private TwitterFollowNeo4jConfiguration config;
 
   public TwitterFollowNeo4j() {
     this(new 
ComponentConfigurator<>(TwitterFollowNeo4jConfiguration.class).detectConfiguration(StreamsConfigurator.getConfig()));
@@ -66,8 +68,8 @@ public class TwitterFollowNeo4j implements Runnable {
 
     ActivityConverterProcessorConfiguration 
activityConverterProcessorConfiguration =
         new ActivityConverterProcessorConfiguration()
-            .withClassifiers(Lists.newArrayList((DocumentClassifier) new 
TwitterDocumentClassifier()))
-            .withConverters(Lists.newArrayList((ActivityConverter) new 
TwitterFollowActivityConverter()));
+            .withClassifiers(Stream.of((DocumentClassifier) new 
TwitterDocumentClassifier()).collect(Collectors.toList()))
+            .withConverters(Stream.of((ActivityConverter) new 
TwitterFollowActivityConverter()).collect(Collectors.toList()));
     ActivityConverterProcessor activity = new 
ActivityConverterProcessor(activityConverterProcessorConfiguration);
 
     GraphHttpConfiguration graphWriterConfiguration = config.getGraph();

http://git-wip-us.apache.org/repos/asf/incubator-streams-examples/blob/0aadbe24/local/twitter-userstream-elasticsearch/src/main/java/org/apache/streams/example/TwitterUserstreamElasticsearch.java
----------------------------------------------------------------------
diff --git 
a/local/twitter-userstream-elasticsearch/src/main/java/org/apache/streams/example/TwitterUserstreamElasticsearch.java
 
b/local/twitter-userstream-elasticsearch/src/main/java/org/apache/streams/example/TwitterUserstreamElasticsearch.java
index 369ec0b..61cd582 100644
--- 
a/local/twitter-userstream-elasticsearch/src/main/java/org/apache/streams/example/TwitterUserstreamElasticsearch.java
+++ 
b/local/twitter-userstream-elasticsearch/src/main/java/org/apache/streams/example/TwitterUserstreamElasticsearch.java
@@ -38,14 +38,15 @@ import 
org.apache.streams.twitter.provider.TwitterStreamProvider;
 import org.apache.streams.verbs.ObjectCombination;
 import org.apache.streams.verbs.VerbDefinition;
 
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import org.elasticsearch.common.Strings;
+import org.apache.commons.lang3.StringUtils;
+import org.hamcrest.MatcherAssert;
+import org.hamcrest.core.IsInstanceOf;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * Example stream that populates elasticsearch with activities from twitter 
userstream in real-time
@@ -60,9 +61,9 @@ public class TwitterUserstreamElasticsearch implements 
Runnable {
   private static VerbDefinition deleteVerbDefinition =
       new VerbDefinition()
           .withValue("delete")
-          .withObjects(Lists.newArrayList(new ObjectCombination()));
+          .withObjects(Stream.of(new 
ObjectCombination()).collect(Collectors.toList()));
 
-  TwitterUserstreamElasticsearchConfiguration config;
+  private TwitterUserstreamElasticsearchConfiguration config;
 
   public TwitterUserstreamElasticsearch() {
     this(new 
ComponentConfigurator<>(TwitterUserstreamElasticsearchConfiguration.class).detectConfiguration(StreamsConfigurator.getConfig()));
@@ -90,9 +91,9 @@ public class TwitterUserstreamElasticsearch implements 
Runnable {
 
     TwitterStreamProvider stream = new 
TwitterStreamProvider(twitterStreamConfiguration);
     ActivityConverterProcessor converter = new ActivityConverterProcessor();
-    VerbDefinitionDropFilter noDeletesProcessor = new 
VerbDefinitionDropFilter(Sets.newHashSet(deleteVerbDefinition));
+    VerbDefinitionDropFilter noDeletesProcessor = new 
VerbDefinitionDropFilter(Stream.of(deleteVerbDefinition).collect(Collectors.toSet()));
     ElasticsearchPersistWriter writer = new 
ElasticsearchPersistWriter(elasticsearchWriterConfiguration);
-    VerbDefinitionKeepFilter deleteOnlyProcessor = new 
VerbDefinitionKeepFilter(Sets.newHashSet(deleteVerbDefinition));
+    VerbDefinitionKeepFilter deleteOnlyProcessor = new 
VerbDefinitionKeepFilter(Stream.of(deleteVerbDefinition).collect(Collectors.toSet()));
     SetDeleteIdProcessor setDeleteIdProcessor = new SetDeleteIdProcessor();
     ElasticsearchPersistDeleter deleter = new 
ElasticsearchPersistDeleter(elasticsearchWriterConfiguration);
 
@@ -121,14 +122,14 @@ public class TwitterUserstreamElasticsearch implements 
Runnable {
     @Override
     public List<StreamsDatum> process(StreamsDatum entry) {
 
-      Preconditions.checkArgument(entry.getDocument() instanceof Activity);
+      MatcherAssert.assertThat(entry.getDocument(), 
IsInstanceOf.instanceOf(Activity.class));
       String id = entry.getId();
       // replace delete with post in id
       // ensure ElasticsearchPersistDeleter will remove original post if 
present
-      id = Strings.replace(id, "delete", "post");
+      id = StringUtils.replace(id, "delete", "post");
       entry.setId(id);
 
-      return Lists.newArrayList(entry);
+      return Stream.of(entry).collect(Collectors.toList());
     }
 
     @Override

Reply via email to