Exemplo n.º 1
0
 @Test
 public void flatMap_A$Function1() throws Exception {
   String value = "vvv";
   Some<String> target = new Some<String>(value);
   F1<String, Option<String>> f =
       new F1<String, Option<String>>() {
         @Override
         public Option<String> apply(String v1) {
           return Option.apply(v1);
         }
       };
   Option<String> actual = target.flatMap(f);
   assertThat(actual.isDefined(), is(true));
 }
Exemplo n.º 2
0
 @Test
 public void flatMap_A$F1() throws Exception {
   String value = "vvv";
   Some<String> target = new Some<String>(value);
   F1<String, Option<Integer>> f =
       new F1<String, Option<Integer>>() {
         @Override
         public Option<Integer> apply(String v1) {
           return Option.apply(v1.length());
         }
       };
   Option<Integer> actual = target.flatMap(f);
   assertThat(actual.getOrNull(), is(equalTo(3)));
 }