All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.hutool.json.JSONObjectIter Maven / Gradle / Ivy

Go to download

Hutool是一个小而全的Java工具类库,通过静态方法封装,降低相关API的学习成本,提高工作效率,使Java拥有函数式语言般的优雅,让Java语言也可以“甜甜的”。

There is a newer version: 5.8.34
Show newest version
package cn.hutool.json;

import java.util.Iterator;

/**
 * 此类用于在JSONAray中便于遍历JSONObject而封装的Iterable,可以借助foreach语法遍历
 * 
 * @author looly
 * @since 4.0.12
 */
public class JSONObjectIter implements Iterable {

	Iterator iterator;
	
	public JSONObjectIter(Iterator iterator) {
		this.iterator = iterator;
	}

	@Override
	public Iterator iterator() {
		return new Iterator() {

			@Override
			public boolean hasNext() {
				return iterator.hasNext();
			}

			@Override
			public JSONObject next() {
				return (JSONObject) iterator.next();
			}

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

}