List of usage examples for java.lang Iterable Iterable
Iterable
From source file:org.jiemamy.entity.io.meta.EntityMeta.java
/** * ?????????{@link Iterable}??// www. j a v a 2s . c om * * @return ?????????{@link Iterable} */ public Iterable<PropertyMeta> getAllColumnPropertyMeta() { return new Iterable<PropertyMeta>() { public Iterator<PropertyMeta> iterator() { return new Iterator<PropertyMeta>() { private int i; public boolean hasNext() { return i < columnPropertyMetas.size(); } public PropertyMeta next() { return columnPropertyMetas.get(i++); } public void remove() { throw new UnsupportedOperationException(); } }; } }; }
From source file:name.martingeisse.webide.features.java.compiler.classpath.ClassFolderLibraryFileManager.java
/** * //from ww w .ja va 2 s. c o m */ protected Iterable<JavaFileObject> listClassFilesInternal(final File folder, final boolean recurse) throws IOException { ParameterUtil.ensureNotNull(folder, "folder"); File[] folderFiles = folder.listFiles(); if (folderFiles == null) { return new EmptyIterable<JavaFileObject>(); } final List<JavaFileObject> files = new ArrayList<JavaFileObject>(); final List<Iterable<JavaFileObject>> iterables = new ArrayList<Iterable<JavaFileObject>>(); for (final File file : folderFiles) { if (file.isFile() && file.getName().endsWith(".class")) { files.add(new ReadOnlyRegularJavaFileObject(file)); } else if (file.isDirectory() && recurse) { iterables.add(listClassFilesInternal(file, true)); } } if (iterables.isEmpty()) { return files; } else { iterables.add(files); return new Iterable<JavaFileObject>() { @Override public Iterator<JavaFileObject> iterator() { return GenericTypeUtil.unsafeCast(new IteratorChain(iterables)); } }; } }
From source file:org.nees.rpi.vis.loaders.M3DVLoader.java
/** * Parses the input xml solely to get the names of the datafiles associated * with this model file// w ww . j a va2 s . c o m * * @return * a list of the file names for the model, returns an empty * list if none found * @throws LoaderException * If an error occurs while parsing the input for data files. */ @Override public Iterable<String> getDataFiles() throws LoaderException { try { final List<String> datafiles = new ArrayList<String>(); int i = 0; config = input.isLeft() ? new XMLConfiguration(input.left().get()) : new XMLConfiguration(input.right().get()); do { String filename = config.getString("data-file(" + i + ").file-name"); if (filename == null) break; datafiles.add(filename); i++; } while (true); return new Iterable<String>() { public Iterator<String> iterator() { return datafiles.iterator(); } }; } catch (ConfigurationException e) { throw new LoaderException(e); } }
From source file:org.opencastproject.util.XmlUtil.java
/** Make a {@link org.w3c.dom.NodeList} iterable. */ public static <A extends Node> Iterable<A> iterable(final NodeList nl) { return new Iterable<A>() { @Override/*w w w . ja v a 2s . c o m*/ public Iterator<A> iterator() { return new ImmutableIteratorBase<A>() { private int index = 0; @Override public boolean hasNext() { return index < nl.getLength(); } @Override public A next() { if (hasNext()) { final Node next = nl.item(index); index = index + 1; return (A) next; } else { throw new NoSuchElementException(); } } }; } }; }
From source file:com.github.anba.test262.util.Test262Info.java
private static final <T> Iterable<T> iterable(final Iterator<T> iterator) { return new Iterable<T>() { @Override/*ww w . ja va2 s . co m*/ public Iterator<T> iterator() { return iterator; } }; }
From source file:mondrian.rolap.RolapMeasureGroup.java
/** * Finds out non-joining dimensions for this measure group. * * <p>The result preserves the order in {@code otherDims}.</p> * * @param otherDims Collection of dimensions to be tested for existence in * this measure group/* ww w . j a va 2 s .co m*/ * @return Set of dimensions that do not exist (non joining) in this cube */ public Iterable<RolapCubeDimension> nonJoiningDimensions( final Iterable<? extends RolapCubeDimension> otherDims) { return new Iterable<RolapCubeDimension>() { public Iterator<RolapCubeDimension> iterator() { //noinspection unchecked return (Iterator<RolapCubeDimension>) new FilterIterator(otherDims.iterator(), new Util.Predicate1<RolapCubeDimension>() { public boolean test(RolapCubeDimension dimension) { return !dimensionMap3.containsKey(dimension) && !dimension.isMeasures(); } }); } }; }
From source file:org.libreplan.business.planner.limiting.entities.DateAndHour.java
/** * Creates an {@link Iterable} that returns a lazy iterator. If * <code>end</code> is <code>null</code> it will not stop and will keep on * producing days forever// w w w . ja v a2 s .c o m */ public Iterable<LocalDate> daysUntil(final DateAndHour end) { Validate.isTrue(end == null || end.isAfter(this)); return new Iterable<LocalDate>() { @Override public Iterator<LocalDate> iterator() { return new Iterator<LocalDate>() { private LocalDate current = getDate(); @Override public boolean hasNext() { return end == null || end.isAfter(current); } @Override public LocalDate next() { LocalDate result = current; current = current.plusDays(1); return result; } @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; }
From source file:com.joyveb.dbpimpl.cass.prepare.schema.AbstractQueryOperation.java
protected CassandraFuture<List<ResultSet>> doExecuteAsync(Iterator<Statement> queryIterator) { if (!queryIterator.hasNext()) { ListenableFuture<List<ResultSet>> emptyResultFuture = Futures .immediateFuture(Collections.<ResultSet>emptyList()); CassandraFuture<List<ResultSet>> wrappedFuture = new CassandraFuture<List<ResultSet>>(emptyResultFuture, CassandraUtils.EXCEPTION_TRANSLATOR); return wrappedFuture; }//from w w w . ja va2 s. c o m final Iterator<ListenableFuture<ResultSet>> resultSetFutures = Iterators.transform(queryIterator, new Function<Statement, ListenableFuture<ResultSet>>() { @Override public ListenableFuture<ResultSet> apply(Statement query) { return doExecuteAsync(query); } }); ListenableFuture<List<ResultSet>> allResultSetFuture = Futures .successfulAsList(new Iterable<ListenableFuture<ResultSet>>() { @Override public Iterator<ListenableFuture<ResultSet>> iterator() { return resultSetFutures; } }); CassandraFuture<List<ResultSet>> wrappedFuture = new CassandraFuture<List<ResultSet>>(allResultSetFuture, CassandraUtils.EXCEPTION_TRANSLATOR); return wrappedFuture; }
From source file:com.eaio.util.text.HumanTime.java
/** * Parses a {@link CharSequence} argument and returns a {@link HumanTime} instance. * /* w w w. ja v a2 s.c om*/ * @param s the char sequence, may not be <code>null</code> * @return an instance, never <code>null</code> */ public static HumanTime eval(final CharSequence s) { HumanTime out = new HumanTime(0L); int num = 0; int start = 0; int end = 0; State oldState = State.IGNORED; for (char c : new Iterable<Character>() { /** * @see java.lang.Iterable#iterator() */ public Iterator<Character> iterator() { return new Iterator<Character>() { private int p = 0; /** * @see java.util.Iterator#hasNext() */ public boolean hasNext() { return p < s.length(); } /** * @see java.util.Iterator#next() */ public Character next() { return s.charAt(p++); } /** * @see java.util.Iterator#remove() */ public void remove() { throw new UnsupportedOperationException(); } }; } }) { State newState = getState(c); if (oldState != newState) { if (oldState == State.NUMBER && (newState == State.IGNORED || newState == State.UNIT)) { num = Integer.parseInt(s.subSequence(start, end).toString()); } else if (oldState == State.UNIT && (newState == State.IGNORED || newState == State.NUMBER)) { out.nTimes(s.subSequence(start, end).toString(), num); num = 0; } start = end; } ++end; oldState = newState; } if (oldState == State.UNIT) { out.nTimes(s.subSequence(start, end).toString(), num); } return out; }
From source file:org.apache.hadoop.yarn.server.api.records.impl.pb.NodeStatusPBImpl.java
private synchronized void addContainersToProto() { maybeInitBuilder();// www.ja va 2 s.c o m builder.clearContainersStatuses(); if (containers == null) return; Iterable<ContainerStatusProto> iterable = new Iterable<ContainerStatusProto>() { @Override public Iterator<ContainerStatusProto> iterator() { return new Iterator<ContainerStatusProto>() { Iterator<ContainerStatus> iter = containers.iterator(); @Override public boolean hasNext() { return iter.hasNext(); } @Override public ContainerStatusProto next() { return convertToProtoFormat(iter.next()); } @Override public void remove() { throw new UnsupportedOperationException(); } }; } }; builder.addAllContainersStatuses(iterable); }