@Override public ObjectStream<Entity> streamEntities(EntityType type) { Iterable<Entity> data = storage.get(type); if (data != null) { return ObjectStreams.wrap(data.iterator()); } else { return ObjectStreams.empty(); } }
EntityCollection data = storage.get(query.getEntityType()); if (data == null) { return ObjectStreams.empty();
@Test public void testEmptyStreamIterable() { ObjectStream<String> cur = ObjectStreams.empty(); try { assertThat(Iterables.isEmpty(cur), equalTo(true)); } finally { cur.close(); } } //endregion
@Test public void testMakeListEmpty() { List<?> lst = ObjectStreams.makeList(ObjectStreams.empty()); assertThat(lst, hasSize(0)); }
EntityCollection data = storage.get(query.getEntityType()); if (data == null) { return ObjectStreams.empty();
@SuppressWarnings("unchecked") @Test public void testConcatEmpty() { ObjectStream<String> objectStream = ObjectStreams.concat(ObjectStreams.<String>empty()); assertThat(objectStream.readObject(), nullValue()); }
@Test public void testEmptyStream() { ObjectStream<String> cur = ObjectStreams.empty(); try { assertThat(cur.readObject(), nullValue()); try { cur.iterator().next(); fail("next() on empty stream should fail"); } catch (NoSuchElementException e) { /* expected */ } } finally { cur.close(); } }
@Test public void testConcatWithEmpty() { @SuppressWarnings("unchecked") ObjectStream<String> objectStream = ObjectStreams.concat(ObjectStreams.of("foo"), ObjectStreams.<String>empty(), ObjectStreams.of("bar")); assertThat(objectStream, contains("foo", "bar")); assertThat(objectStream.readObject(), nullValue()); } //endregion
@Override public ObjectStream<Entity> streamEntities(EntityType type) { Iterable<Entity> data = storage.get(type); if (data != null) { return ObjectStreams.wrap(data.iterator()); } else { return ObjectStreams.empty(); } }
EntityCollection data = storage.get(query.getEntityType()); if (data == null) { return ObjectStreams.empty();
EntityCollection data = storage.get(query.getEntityType()); if (data == null) { return ObjectStreams.empty();