public static <E> void assertContains( Iterator<E> actual, E... expected ) { assertContains( Iterators.asIterable( actual ), expected ); }
@GET @Path("/friendsCypher/{name}") public Response getFriendsCypher(@PathParam("name") String name, @Context GraphDatabaseService db) throws IOException { Result result = db.execute("MATCH (p:Person)-[:KNOWS]-(friend) WHERE p.name = {n} RETURN friend.name", Collections.<String, Object>singletonMap("n", name)); List<String> friendNames = new ArrayList<>(); for (Map<String, Object> item : Iterators.asIterable(result)) { friendNames.add((String) item.get("friend.name")); } return Response.ok().entity(objectMapper.writeValueAsString(friendNames)).build(); }
public ConfigurationParser( String... format ) { this( Iterators.asIterable( new ArrayIterator<String>( format ) ) ); }
@SuppressWarnings( "unchecked" ) public ConfigurationParser( File configFile, String... format ) { this( Iterators.asIterable( new CombiningIterator<String>( Arrays.asList( new LineIterator( configFile ), new ArrayIterator<String>( format ) ) ) ) ); }
@Test public void exampleQuery() throws Exception { // START SNIPPET: JavaQuery Result result = db.execute( "MATCH (n) WHERE id(n) = 0 AND 1=1 RETURN n" ); assertThat( result.columns(), hasItem( "n" ) ); Iterator<Node> n_column = result.columnAs( "n" ); assertThat( asIterable( n_column ), hasItem( db.getNodeById( 0 ) ) ); // END SNIPPET: JavaQuery }
for ( Node node : Iterators.asIterable( n_column ) )