From 8214c8dd97a38b06959aae00ca678b521c4abef5 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Wed, 2 Aug 2017 00:05:37 +0200 Subject: [PATCH] Refactor --- .../main/java/com/baelding/rxjava/operator/toLength.java | 8 +------- .../baeldung/rxjava/RxJavaCustomOperatorUnitTest.java | 9 +-------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/rxjava/src/main/java/com/baelding/rxjava/operator/toLength.java b/rxjava/src/main/java/com/baelding/rxjava/operator/toLength.java index 47398ddcb8..fa997b563d 100644 --- a/rxjava/src/main/java/com/baelding/rxjava/operator/toLength.java +++ b/rxjava/src/main/java/com/baelding/rxjava/operator/toLength.java @@ -11,12 +11,6 @@ public class toLength implements Transformer { @Override public Observable call(Observable source) { - - return source.map(new Func1() { - @Override - public Integer call(String str) { - return str.length(); - } - }); + return source.map(String::length); } } \ No newline at end of file diff --git a/rxjava/src/test/java/com/baeldung/rxjava/RxJavaCustomOperatorUnitTest.java b/rxjava/src/test/java/com/baeldung/rxjava/RxJavaCustomOperatorUnitTest.java index 0cc458c414..99ac0351be 100644 --- a/rxjava/src/test/java/com/baeldung/rxjava/RxJavaCustomOperatorUnitTest.java +++ b/rxjava/src/test/java/com/baeldung/rxjava/RxJavaCustomOperatorUnitTest.java @@ -96,14 +96,7 @@ public class RxJavaCustomOperatorUnitTest { @Test public void whenUseFunctionTransformer_thenSuccess() { - final Transformer toLengthFn = source -> { - return source.map(new Func1() { - @Override - public Integer call(String str) { - return str.length(); - } - }); - }; + final Transformer toLengthFn = source -> source.map(String::length); final List results = new ArrayList(); Observable.from(Arrays.asList("apple", "orange"))