com.samskivert.mustache.BasicCollector Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jmustache Show documentation
Show all versions of jmustache Show documentation
A Java implementation of the Mustache templating language.
//
// JMustache - A Java implementation of the Mustache templating language
// http://github.com/samskivert/jmustache/blob/master/LICENSE
package com.samskivert.mustache;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
/**
* A collector that does not use reflection and can be used with GWT.
*/
public abstract class BasicCollector implements Mustache.Collector
{
public Iterator> toIterator (final Object value) {
if (value instanceof Iterable>) {
return ((Iterable>)value).iterator();
}
if (value instanceof Iterator>) {
return (Iterator>)value;
}
if (value.getClass().isArray()) {
final ArrayHelper helper = arrayHelper(value);
return new Iterator