/** * Exposes {@code iterator} as an {@link Iterable}. It breaks the contract * of {@link Iterable} in that it returns the supplied iterator instance for * each call to {@code iterator()} on the returned {@link Iterable} * instance. This method mostly exists to make it easy to use an * {@link Iterator} in a for-loop. * * @param <T> the type of items in the iterator. * @param iterator the iterator to expose as an {@link Iterable}. * @return the supplied iterator posing as an {@link Iterable}. */ //@Deprecated * @deprecated use {@link #loop(Iterator) the loop method} instead. public static <T> Iterable<T> asIterable( final Iterator<T> iterator ) { return loop( iterator ); }
public static <T> boolean contains( Iterator<T> iterator, T item ) { try { for ( T element : loop( iterator ) ) { if ( item == null ? element == null : item.equals( element ) ) { return true; } } return false; } finally { if ( iterator instanceof ResourceIterator<?> ) { ((ResourceIterator<?>) iterator).close(); } } }
private Iterable<CommonAbstractStore> instantiatedRecordStores() { Iterator<StoreType> storeTypes = new FilteringIterator<>( iterator( STORE_TYPES ), INSTANTIATED_RECORD_STORES ); return loop( new IteratorWrapper<CommonAbstractStore,StoreType>( storeTypes ) { @Override protected CommonAbstractStore underlyingObjectToObject( StoreType type ) { return (CommonAbstractStore) stores[type.ordinal()]; } } ); }
@Override protected Iterable<Node> manifest() { return loop( db.findNodes( label, propertyName, propertyValue ) ); } };
private Function<GraphDatabaseService, List<Long>> listNodeIdsFromIndexLookup( final Label label, final String propertyKey, final Object value ) { return graphDb -> { ArrayList<Long> ids = new ArrayList<>(); for ( Node node : loop( graphDb.findNodes( label, propertyKey, value ) ) ) { ids.add( node.getId() ); } return ids; }; }
private ListRepresentation createResultRepresentation( Result executionResult ) { final List<String> columns = executionResult.columns(); Iterable<Map<String, Object>> inner = new RepresentationExceptionHandlingIterable<>( loop( executionResult ) ); return new ListRepresentation( "data", new IterableWrapper<Representation,Map<String,Object>>( inner ) { @Override protected Representation underlyingObjectToObject( final Map<String,Object> row ) { return new ListRepresentation( "row", new IterableWrapper<Representation,String>( columns ) { @Override protected Representation underlyingObjectToObject( String column ) { return getRepresentation( row.get( column ) ); } } ); } } ); }
private void showIndices( DbStructureVisitor visitor, KernelTransaction ktx, TokenNameLookup nameLookup ) throws IndexNotFoundKernelException { SchemaRead schemaRead = ktx.schemaRead(); for ( IndexReference reference : loop( sortByType( schemaRead.indexesGetAll() ) ) ) { String userDescription = reference.schema().userDescription( nameLookup ); double uniqueValuesPercentage = schemaRead.indexUniqueValuesSelectivity( reference ); long size = schemaRead.indexSize( reference ); visitor.visitIndex( (IndexDescriptor) reference, userDescription, uniqueValuesPercentage, size ); } }
private static void doStuff( GraphDatabaseService db, Label label, String propertyKey ) { try ( Transaction tx = db.beginTx() ) { for ( Node node : loop( db.findNodes( label, propertyKey, 3323 ) ) ) { count( node.getLabels() ); } } }
for ( Map<String, Object> row : loop( result ) )
storeView, nameLookup, loop( iterator( rules ) ), internalLogProvider, userLogProvider,
/** * Exposes {@code iterator} as an {@link Iterable}. It breaks the contract * of {@link Iterable} in that it returns the supplied iterator instance for * each call to {@code iterator()} on the returned {@link Iterable} * instance. This method mostly exists to make it easy to use an * {@link Iterator} in a for-loop. * * @param <T> the type of items in the iterator. * @param iterator the iterator to expose as an {@link Iterable}. * @return the supplied iterator posing as an {@link Iterable}. */ //@Deprecated * @deprecated use {@link #loop(Iterator) the loop method} instead. public static <T> Iterable<T> asIterable( final Iterator<T> iterator ) { return loop( iterator ); }
public static <T> boolean contains( Iterator<T> iterator, T item ) { try { for ( T element : loop( iterator ) ) { if ( item == null ? element == null : item.equals( element ) ) { return true; } } return false; } finally { if ( iterator instanceof ResourceIterator<?> ) { ((ResourceIterator<?>) iterator).close(); } } }
private Iterable<CommonAbstractStore> instantiatedRecordStores() { Iterator<StoreType> storeTypes = new FilteringIterator<>( iterator( STORE_TYPES ), INSTANTIATED_RECORD_STORES ); return loop( new IteratorWrapper<CommonAbstractStore,StoreType>( storeTypes ) { @Override protected CommonAbstractStore underlyingObjectToObject( StoreType type ) { return (CommonAbstractStore) stores[type.ordinal()]; } } ); }
private ListRepresentation createResultRepresentation( Result executionResult ) { final List<String> columns = executionResult.columns(); Iterable<Map<String, Object>> inner = new RepresentationExceptionHandlingIterable<>( loop( executionResult ) ); return new ListRepresentation( "data", new IterableWrapper<Representation,Map<String,Object>>( inner ) { @Override protected Representation underlyingObjectToObject( final Map<String,Object> row ) { return new ListRepresentation( "row", new IterableWrapper<Representation,String>( columns ) { @Override protected Representation underlyingObjectToObject( String column ) { return getRepresentation( row.get( column ) ); } } ); } } ); }
private void showIndices( DbStructureVisitor visitor, KernelTransaction ktx, TokenNameLookup nameLookup ) throws IndexNotFoundKernelException { SchemaRead schemaRead = ktx.schemaRead(); for ( IndexReference reference : loop( sortByType( schemaRead.indexesGetAll() ) ) ) { String userDescription = reference.schema().userDescription( nameLookup ); double uniqueValuesPercentage = schemaRead.indexUniqueValuesSelectivity( reference ); long size = schemaRead.indexSize( reference ); visitor.visitIndex( (IndexDescriptor) reference, userDescription, uniqueValuesPercentage, size ); } }
for ( Map<String, Object> row : loop( result ) )