/*
 * Copyright 2007 Yusuke Yamamoto
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package twitter4j.examples.lambda;

import twitter4j.*;

/**
 * example code to explain lambda expression for handling rate limits
 */
public class TwitterStreamLambda {
    public static void main(String... args) {
        TwitterStreamFactory.getSingleton()
            .onStatus(e -> System.out.println(e.getText()))
            .sample();
    }
}

@@ -651,85 +651,249 @@
 r4j.
-*;%0A%0A/**%0A * example code to explain lambda expression for handling rate limits
+FilterQuery;%0Aimport twitter4j.Status;%0Aimport twitter4j.StatusAdapter;%0Aimport twitter4j.TwitterStream;%0Aimport twitter4j.TwitterStreamFactory;%0A%0A/**%0A * example code to explain lambda expression. Prints tweets containing twitter4j or #twitter4j.
 %0A */
@@ -974,16 +974,44 @@
 args) %7B%0A
+        // Twitter4j 4.0.4+%0A
         
@@ -1058,16 +1058,20 @@
         
+    
 .onStatu
@@ -1096,16 +1096,69 @@
 println(
+String.format(%22@%25s %25s%22, e.getUser().getScreenName(), 
 e.getTex
@@ -1162,17 +1162,22 @@
 Text()))
-%0A
+)%0A    
         
@@ -1185,15 +1185,737 @@
    .
-sample(
+onException(e -%3E e.printStackTrace())%0A                .filter(%22twitter4j%22, %22#twitter4j%22);%0A%0A    %7D%0A%0A    public static void oldTraditionalDullBoringImplementation(String... dummy)%7B%0A        // Twitter4J 4.0.3 or earlier%0A        TwitterStream stream = TwitterStreamFactory.getSingleton();%0A        stream.addListener(new StatusAdapter() %7B%0A            @Override%0A            public void onStatus(Status status) %7B%0A                String.format(%22@%25s %25s%22, status.getUser().getScreenName(), status.getText());%0A            %7D%0A%0A            @Override%0A            public void onException(Exception ex) %7B%0A                ex.printStackTrace();%0A            %7D%0A        %7D);%0A        stream.filter(new FilterQuery(new String%5B%5D%7B%22twitter4j%22, %22#twitter4j%22%7D)
 );%0A 

update lambda exaple