@Test public void testParseMessages() { Observable.just("*1*0*21##*#*1##FRAME##") .flatMap(OpenWebNetObservable.parseMessages()) .subscribe(messages -> { assertEquals("invalid frame", "*1*0*21##", messages.get(0).getValue()); assertEquals("invalid frame", "*#*1##", messages.get(1).getValue()); assertEquals("invalid frame", "FRAME##", messages.get(2).getValue()); }); }
static Func1<String, Observable<List<OpenMessage>>> parseMessages() { return messages -> { ImmutableList<OpenMessage> response = FluentIterable .from(Splitter.on(FRAME_END) .trimResults() .omitEmptyStrings() .split(messages)) .transform(value -> value.concat(FRAME_END)) .transform(message -> (OpenMessage) new ResponseOpenMessage(message)) .toList(); return Observable.just(response); }; }
OpenWebNetObservable { static Func1<String, Observable<List<OpenMessage>>> parseMessages() { return messages -> { ImmutableList<OpenMessage> response = FluentIterable .from(Splitter.on(FRAME_END) .trimResults() .omitEmptyStrings() .split(messages)) .transform(value -> value.concat(FRAME_END)) .transform(message -> (OpenMessage) new ResponseOpenMessage(message)) .toList(); return Observable.just(response); }; } }
OpenWebNetObservable { static Func1<String, Observable<List<OpenMessage>>> parseMessages() { return messages -> { ImmutableList<OpenMessage> response = FluentIterable .from(Splitter.on(FRAME_END) .trimResults() .omitEmptyStrings() .split(messages)) .transform(value -> value.concat(FRAME_END)) .transform(message -> (OpenMessage) new ResponseOpenMessage(message)) .toList(); return Observable.just(response); }; } private  OpenWebNetObservable(); }
OpenWebNetObservable { static Func1<String, Observable<List<OpenMessage>>> parseMessages() { return messages -> { ImmutableList<OpenMessage> response = FluentIterable .from(Splitter.on(FRAME_END) .trimResults() .omitEmptyStrings() .split(messages)) .transform(value -> value.concat(FRAME_END)) .transform(message -> (OpenMessage) new ResponseOpenMessage(message)) .toList(); return Observable.just(response); }; } private  OpenWebNetObservable();  }
OpenWebNetObservable { static Func1<String, Observable<List<OpenMessage>>> parseMessages() { return messages -> { ImmutableList<OpenMessage> response = FluentIterable .from(Splitter.on(FRAME_END) .trimResults() .omitEmptyStrings() .split(messages)) .transform(value -> value.concat(FRAME_END)) .transform(message -> (OpenMessage) new ResponseOpenMessage(message)) .toList(); return Observable.just(response); }; } private  OpenWebNetObservable();   }