package com.fernandocejas.java.samples.optional;

import com.fernandocejas.arrow.annotations.See;
import com.fernandocejas.arrow.strings.Strings;

@See(ref = "")
public class UseCaseScenario03 {

  public UseCaseScenario03() {
    //empty
  }

  @Override public String toString() {
    return Strings.EMPTY;
  }
}

@@ -126,186 +126,1785 @@
 row.
-strings.Strings;%0A%0A@See(ref = %22%22)%0Apublic class UseCaseScenario03 %7B%0A%0A  public UseCaseScenario03() %7B%0A    //empty%0A  %7D%0A%0A  @Override public String toString() %7B%0A    return Strings.EMPTY
+optional.Optional;%0Aimport java.util.Arrays;%0Aimport java.util.Collections;%0Aimport java.util.List;%0Aimport rx.Observable;%0Aimport rx.functions.Action1;%0Aimport rx.functions.Func1;%0Aimport rx.schedulers.Schedulers;%0A%0A@See(ref = %22%22)%0Apublic class UseCaseScenario03 %7B%0A%0A  public static final Func1%3COptional%3CList%3CString%3E%3E, Observable%3CList%3CString%3E%3E%3E TO_AD_ITEM =%0A      new Func1%3COptional%3CList%3CString%3E%3E, Observable%3CList%3CString%3E%3E%3E() %7B%0A        @Override public Observable%3CList%3CString%3E%3E call(Optional%3CList%3CString%3E%3E ads) %7B%0A          return ads.isPresent()%0A              ? Observable.just(ads.get())%0A              : Observable.just(Collections.%3CString%3EemptyList());%0A        %7D%0A      %7D;%0A%0A  public static final Func1%3CList%3CString%3E, Boolean%3E EMPTY_ELEMENTS =%0A      new Func1%3CList%3CString%3E, Boolean%3E() %7B%0A        @Override public Boolean call(List%3CString%3E ads) %7B%0A          return !ads.isEmpty();%0A        %7D%0A      %7D;%0A%0A  public UseCaseScenario03() %7B%0A    //empty%0A  %7D%0A%0A  @Override public String toString() %7B%0A    final StringBuilder builder = new StringBuilder();%0A    feed().subscribe(new Action1%3CList%3CString%3E%3E() %7B%0A      @Override public void call(List%3CString%3E feed) %7B%0A        for (String feedElement : feed) %7B%0A          builder.append(%22%5Cn%22).append(feedElement);%0A        %7D%0A      %7D%0A    %7D);%0A    return builder.toString();%0A  %7D%0A%0A  private Observable%3CList%3CString%3E%3E feed() %7B%0A    return ads()%0A        .flatMap(TO_AD_ITEM)%0A        .filter(EMPTY_ELEMENTS)%0A        .concatWith(users())%0A        .observeOn(Schedulers.immediate());%0A  %7D%0A%0A  private Observable%3CList%3CString%3E%3E users() %7B%0A    return Observable.just(Arrays.asList(%22IronMan%22, %22Wolverine%22, %22Batman%22, %22Superman%22));%0A  %7D%0A%0A  private Observable%3COptional%3CList%3CString%3E%3E%3E ads() %7B%0A    return Observable.just(Optional.fromNullable(Collections.singletonList(%22This is and Ad%22)))
 ;%0A  

Add third case scenario for Optional sample.