// Path: src/main/java/com/edorasware/one/initializr/metadata/DefaultMetadataElement.java
// public class DefaultMetadataElement extends MetadataElement {
// 
// 	private boolean defaultValue;
// 
// 	public DefaultMetadataElement() {
// 	}
// 
// 	public DefaultMetadataElement(String id, String name, boolean defaultValue) {
// 		super(id, name);
// 		this.defaultValue = defaultValue;
// 	}
// 
// 	public DefaultMetadataElement(String id, boolean defaultValue) {
// 		this(id, null, defaultValue);
// 	}
// 
// 	public void setDefault(boolean defaultValue) {
// 		this.defaultValue = defaultValue;
// 	}
// 
// 	public boolean isDefault() {
// 		return this.defaultValue;
// 	}
// 
// 	public static DefaultMetadataElement create(String id, boolean defaultValue) {
// 		return new DefaultMetadataElement(id, defaultValue);
// 	}
// 
// 	public static DefaultMetadataElement create(String id, String name, boolean defaultValue) {
// 		return new DefaultMetadataElement(id, name, defaultValue);
// 	}
// 
// }


import com.edorasware.one.initializr.metadata.DefaultMetadataElement;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.web.client.RestTemplate;
import java.util.ArrayList;
import java.util.List;
/*
 * Copyright 2012-2017 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.edorasware.one.initializr.web.support;



/**
 * Reads metadata from the main spring.io website. This is a stateful service: create a
 * new instance whenever you need to refresh the content.
 *
 * @author Stephane Nicoll
 */
public class EdorasoneMetadataReader {

	private final JSONObject content;

	/**
	 * Parse the content of the metadata at the specified url
	 */
	public EdorasoneMetadataReader(RestTemplate restTemplate, String url) {
		this.content = new JSONObject(restTemplate.getForObject(url, String.class));
	}

	/**
	 * Return the edoras one versions parsed by this instance.
	 */
	public List<DefaultMetadataElement> getEdorasoneVersions() {
		JSONArray array = content.getJSONArray("projectReleases");
// Path: src/main/java/com/edorasware/one/initializr/metadata/DefaultMetadataElement.java
// public class DefaultMetadataElement extends MetadataElement {
// 
// 	private boolean defaultValue;
// 
// 	public DefaultMetadataElement() {
// 	}
// 
// 	public DefaultMetadataElement(String id, String name, boolean defaultValue) {
// 		super(id, name);
// 		this.defaultValue = defaultValue;
// 	}
// 
// 	public DefaultMetadataElement(String id, boolean defaultValue) {
// 		this(id, null, defaultValue);
// 	}
// 
// 	public void setDefault(boolean defaultValue) {
// 		this.defaultValue = defaultValue;
// 	}
// 
// 	public boolean isDefault() {
// 		return this.defaultValue;
// 	}
// 
// 	public static DefaultMetadataElement create(String id, boolean defaultValue) {
// 		return new DefaultMetadataElement(id, defaultValue);
// 	}
// 
// 	public static DefaultMetadataElement create(String id, String name, boolean defaultValue) {
// 		return new DefaultMetadataElement(id, name, defaultValue);
// 	}
// 
// }


// Path: src/main/java/com/edorasware/one/initializr/web/support/EdorasoneMetadataReader.java
import com.edorasware.one.initializr.metadata.DefaultMetadataElement;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.web.client.RestTemplate;
import java.util.ArrayList;
import java.util.List;

/*
 * Copyright 2012-2017 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.edorasware.one.initializr.web.support;



/**
 * Reads metadata from the main spring.io website. This is a stateful service: create a
 * new instance whenever you need to refresh the content.
 *
 * @author Stephane Nicoll
 */
public class EdorasoneMetadataReader {

	private final JSONObject content;

	/**
	 * Parse the content of the metadata at the specified url
	 */
	public EdorasoneMetadataReader(RestTemplate restTemplate, String url) {
		this.content = new JSONObject(restTemplate.getForObject(url, String.class));
	}

	/**
	 * Return the edoras one versions parsed by this instance.
	 */
	public List<DefaultMetadataElement> getEdorasoneVersions() {
		JSONArray array = content.getJSONArray("projectReleases");
		List<DefaultMetadataElement> list = new ArrayList<>();