- Add the Codota plugin to your IDE and get smart completions
private void myMethod () {Charset c =
String charsetName;Charset.forName(charsetName)
Charset.defaultCharset()
ContentType contentType;contentType.getCharset()
- Smart code suggestions by Codota
}
private Iterable<BytesMessageWithOffset> filterAndDecode(Iterable<MessageAndOffset> kafkaMessages, final long offset) { return FunctionalIterable .create(kafkaMessages) .filter( new Predicate<MessageAndOffset>() { @Override public boolean apply(MessageAndOffset msgAndOffset) { return msgAndOffset.offset() >= offset; } } ) .transform( new Function<MessageAndOffset, BytesMessageWithOffset>() { @Override public BytesMessageWithOffset apply(MessageAndOffset msgAndOffset) { ByteBuffer bb = msgAndOffset.message().payload(); byte[] payload = new byte[bb.remaining()]; bb.get(payload); // add nextOffset here, thus next fetch will use nextOffset instead of current offset return new BytesMessageWithOffset(payload, msgAndOffset.nextOffset(), partitionId); } } ); }
@Test public void testFilter() { Assert.assertEquals( Lists.newArrayList( FunctionalIterable.create(Arrays.asList("1", "2", "3")) .filter( new Predicate<String>() { @Override public boolean apply(String input) { return !"2".equals(input); } } ) ), Arrays.asList("1", "3") ); }