Example usage for java.lang Iterable Iterable

List of usage examples for java.lang Iterable Iterable

Introduction

In this page you can find the example usage for java.lang Iterable Iterable.

Prototype

Iterable

Source Link

Usage

From source file:com.flexive.core.search.cmis.model.SingleTableReference.java

/**
 * {@inheritDoc}/*ww  w  .  j  a  v  a2s . c  o m*/
 */
@Override
public Iterable<TableReference> getLeafTables() {
    return new Iterable<TableReference>() {
        @Override
        public Iterator<TableReference> iterator() {
            return Arrays.asList((TableReference) SingleTableReference.this).iterator();
        }
    };
}

From source file:org.renjin.sexp.ListVector.java

public Iterable<NamedValue> namedValues() {
    return new Iterable<NamedValue>() {
        @Override/*from   ww w .ja  v a2  s  .co  m*/
        public Iterator<NamedValue> iterator() {
            return new UnmodifiableIterator<NamedValue>() {
                private int index = 0;

                @Override
                public boolean hasNext() {
                    return index < length();
                }

                @Override
                public NamedValue next() {
                    NamedValue pair = new NameValuePair(getName(index), getElementAsSEXP(index));
                    index++;
                    return pair;
                }
            };
        }
    };
}

From source file:com.adito.security.DefaultUserDatabase.java

protected static <T> Iterable<T> toIterable(final Iterator<T> itr) {
    return new Iterable<T>() {
        public Iterator<T> iterator() {
            return itr;
        }//from w w  w . java  2  s.co m
    };
}

From source file:org.acmsl.queryj.ConfigurationQueryJCommandImpl.java

/**
 * Retrieves all keys./*from ww w  . ja va2s .c  o m*/
 * @param configuration the {@link Configuration}.
 * @return such keys.
 */
@NotNull
protected Iterable<String> getKeys(@NotNull final Configuration configuration) {
    return new Iterable<String>() {
        /**
         * {@inheritDoc}
         */
        @Override
        public Iterator<String> iterator() {
            return configuration.getKeys();
        }
    };
}

From source file:com.spotify.heroic.metric.astyanax.AstyanaxBackend.java

@Override
public Iterable<BackendEntry> listEntries() {
    final Borrowed<Context> ctx = context.borrow();

    final OperationResult<Rows<MetricsRowKey, Integer>> result;

    try {//from  w  w  w.  j a  v a  2s. c  om
        result = ctx.get().client.prepareQuery(METRICS_CF).getAllRows().execute();
    } catch (final ConnectionException e) {
        throw new RuntimeException("Request failed", e);
    }

    return new Iterable<BackendEntry>() {
        @Override
        public Iterator<BackendEntry> iterator() {
            final Iterator<Row<MetricsRowKey, Integer>> iterator = result.getResult().iterator();

            return new Iterator<BackendEntry>() {
                @Override
                public boolean hasNext() {
                    final boolean next = iterator.hasNext();

                    if (!next) {
                        ctx.release();
                    }

                    return next;
                }

                @Override
                public BackendEntry next() {
                    final Row<MetricsRowKey, Integer> entry = iterator.next();
                    final MetricsRowKey rowKey = entry.getKey();
                    final Series series = rowKey.getSeries();

                    final List<Point> points = rowKey.buildPoints(entry.getColumns());
                    return new BackendEntry(series, MetricCollection.points(points));
                }

                @Override
                public void remove() {
                    throw new UnsupportedOperationException();
                }
            };
        }
    };
}

From source file:de.tuberlin.uebb.jdae.llmsl.Block.java

@Override
public Iterable<GlobalVariable> variables() {
    return new Iterable<GlobalVariable>() {
        public Iterator<GlobalVariable> iterator() {
            return Iterators.forArray(variables);
        }/*from   w  ww  .  java2  s . c  o  m*/
    };
}

From source file:com.quinsoft.zeidon.standardoe.ViewImpl.java

@Override
public Iterable<EntityInstance> getHierEntityList(boolean includeRoot, String entityName) {
    EntityDef entityDef = null;//from  ww w  . j  ava  2s. c  o m
    if (!StringUtils.isBlank(entityName))
        entityDef = getLodDef().getEntityDef(entityName);

    ObjectInstance oi = viewCursor.getObjectInstance();
    final EntityIterator<EntityInstanceImpl> iter = new IteratorBuilder(getObjectInstance()).withOiScoping(oi)
            .forEntityDef(entityDef).setLazyLoad(true).build();

    // Skip the root?
    if (!includeRoot)
        iter.next();

    // We have to create an iterator so that we can set the cursor in next().
    return new Iterable<EntityInstance>() {
        @Override
        public Iterator<EntityInstance> iterator() {
            return new Iterator<EntityInstance>() {
                @Override
                public boolean hasNext() {
                    return iter.hasNext();
                }

                @Override
                public EntityInstance next() {
                    EntityInstanceImpl ei = iter.next();
                    EntityDef entityDef = ei.getEntityDef();
                    EntityCursorImpl entityCursor = viewCursor.getEntityCursor(entityDef);
                    entityCursor.setCursor(ei);
                    return entityCursor.getEntityInstance();
                }

                @Override
                public void remove() {
                    iter.remove();
                }
            };
        }
    };
}

From source file:jetbrains.exodus.entitystore.FileSystemBlobVaultOld.java

@Override
public BackupStrategy getBackupStrategy() {
    return new BackupStrategy() {

        @Override/*from   ww w  .  j  a  va 2  s.co m*/
        public Iterable<FileDescriptor> listFiles() {
            return new Iterable<FileDescriptor>() {
                @Override
                public Iterator<FileDescriptor> iterator() {
                    final Deque<FileDescriptor> queue = new LinkedList<>();
                    queue.add(new FileDescriptor(location, blobsDirectory + File.separator));
                    return new Iterator<FileDescriptor>() {
                        int i = 0;
                        int n = 0;
                        File[] files;
                        FileDescriptor next;
                        String currentPrefix;

                        @Override
                        public boolean hasNext() {
                            if (next != null) {
                                return true;
                            }
                            while (i < n) {
                                final File file = files[i++];
                                final String name = file.getName();
                                if (file.isDirectory()) {
                                    queue.push(new FileDescriptor(file,
                                            currentPrefix + file.getName() + File.separator));
                                } else if (file.isFile()) {
                                    final long fileSize = file.length();
                                    if (fileSize == 0)
                                        continue;
                                    if (name.endsWith(blobExtension) || name.equalsIgnoreCase(VERSION_FILE)) {
                                        next = new FileDescriptor(file, currentPrefix, fileSize);
                                        return true;
                                    }
                                } else {
                                    // something strange with filesystem
                                    throw new EntityStoreException(
                                            "File or directory expected: " + file.toString());
                                }
                            }
                            if (queue.isEmpty()) {
                                return false;
                            }
                            final FileDescriptor fd = queue.pop();
                            files = IOUtil.listFiles(fd.getFile());
                            currentPrefix = fd.getPath();
                            i = 0;
                            n = files.length;
                            next = fd;
                            return true;
                        }

                        @Override
                        public FileDescriptor next() {
                            if (!hasNext()) {
                                throw new NoSuchElementException();
                            }
                            final FileDescriptor result = next;
                            next = null;
                            return result;
                        }

                        @Override
                        public void remove() {
                            throw new UnsupportedOperationException();
                        }
                    };
                }
            };
        }
    };
}

From source file:oculus.aperture.common.JSONProperties.java

@Override
public Iterable<Integer> getIntegers(String key) {
    try {//from  w ww.j  a  v a  2s . c  o  m
        final JSONArray array = obj.getJSONArray(key);

        return new Iterable<Integer>() {
            @Override
            public Iterator<Integer> iterator() {
                return new Iterator<Integer>() {
                    private final int n = array.length();
                    private int i = 0;

                    @Override
                    public boolean hasNext() {
                        return n > i;
                    }

                    @Override
                    public Integer next() {
                        try {
                            return (n > i) ? array.getInt(i++) : null;
                        } catch (JSONException e) {
                            return null;
                        }
                    }

                    @Override
                    public void remove() {
                        throw new UnsupportedOperationException();
                    }
                };
            }
        };
    } catch (JSONException e) {
        return EmptyIterable.instance();
    }
}

From source file:de.uniba.wiai.kinf.pw.projects.lillytab.reasoner.abox.RABox.java

@Override
public Iterable<Pair<R, NodeID>> getSuccessorPairs() {
    return new Iterable<Pair<R, NodeID>>() {
        @Override/*  ww  w. j  a  v a2s  .  com*/
        public Iterator<Pair<R, NodeID>> iterator() {
            return new SubRoleAwarePairIterator(_successors);
        }
    };
}