package com.github.to2mbn.jmccc.mcdownloader;

import java.util.Map;

public class RemoteVersionList {

	private String latestSnapshot;
	private String latestRelease;
	private Map<String, RemoteVersion> versions;

	/**
	 * Creates a RemoteVersionList.
	 * 
	 * @param latestSnapshot the version of the latest snapshot
	 * @param latestRelease the version of the latestrelease
	 * @param versions the versions
	 */
	public RemoteVersionList(String latestSnapshot, String latestRelease, Map<String, RemoteVersion> versions) {
		this.latestSnapshot = latestSnapshot;
		this.latestRelease = latestRelease;
		this.versions = versions;
	}

	/**
	 * Gets the version of the latest snapshot.
	 * 
	 * @return the version of the latest snapshot
	 */
	public String getLatestSnapshot() {
		return latestSnapshot;
	}

	/**
	 * Gets the version of the latest release.
	 * 
	 * @return the version of the latest release
	 */
	public String getLatestRelease() {
		return latestRelease;
	}

	/**
	 * Gets all the versions.
	 * 
	 * @return all the versions
	 */
	public Map<String, RemoteVersion> getVersions() {
		return versions;
	}

}

@@ -61,46 +61,1040 @@
 til.
+Hash
 Map;%0A
-%0Apublic class RemoteVersionList %7B
+import java.util.Map;%0Aimport org.json.JSONArray;%0Aimport org.json.JSONObject;%0A%0Apublic class RemoteVersionList %7B%0A%0A%09public static RemoteVersionList fromJson(JSONObject json) %7B%0A%09%09String latestSnapshot = null;%0A%09%09String latestRelease = null;%0A%09%09if (json.has(%22latest%22)) %7B%0A%09%09%09JSONObject latest = json.getJSONObject(%22latest%22);%0A%09%09%09latestSnapshot = latest.optString(%22snapshot%22);%0A%09%09%09latestRelease = latest.optString(%22release%22);%0A%09%09%7D%0A%0A%09%09JSONArray jsonVersions = json.getJSONArray(%22versions%22);%0A%09%09Map%3CString, RemoteVersion%3E versions = new HashMap%3C%3E();%0A%09%09for (int i = 0; i %3C jsonVersions.length(); i++) %7B%0A%09%09%09JSONObject jsonVersion = jsonVersions.getJSONObject(i);%0A%09%09%09String version = jsonVersion.getString(%22id%22);%0A%09%09%09String updateTime = jsonVersion.getString(%22time%22);%0A%09%09%09String releaseTime = jsonVersion.getString(%22releaseTime%22);%0A%09%09%09String type = jsonVersion.getString(%22type%22);%0A%09%09%09versions.put(version, new RemoteVersion(version, updateTime, releaseTime, type));%0A%09%09%7D%0A%09%09return new RemoteVersionList(latestSnapshot, latestRelease, versions);%0A%09%7D
 %0A%0A%09p

add RemoteVersionList.fromJson