/*
 * Copyright 2002-2018 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 org.springframework.cloud.servicebroker.model.catalog;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import javax.validation.constraints.NotEmpty;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * The catalog of services offered by the service broker.
 *
 * @author sgreenberg@pivotal.io
 * @author Scott Frederick
 */
public class Catalog {

	/**
	 * A list of service offerings provided by the service broker.
	 */
	@NotEmpty
	@JsonProperty("services")
	private final List<ServiceDefinition> serviceDefinitions;

	Catalog(List<ServiceDefinition> serviceDefinitions) {
		this.serviceDefinitions = serviceDefinitions;
	}

	public List<ServiceDefinition> getServiceDefinitions() {
		return this.serviceDefinitions;
	}

	@Override
	public final boolean equals(Object o) {
		if (this == o) return true;
		if (!(o instanceof Catalog)) return false;
		Catalog catalog = (Catalog) o;
		return Objects.equals(serviceDefinitions, catalog.serviceDefinitions);
	}

	@Override
	public final int hashCode() {
		return Objects.hash(serviceDefinitions);
	}

	@Override
	public String toString() {
		return "Catalog{" +
				"serviceDefinitions=" + serviceDefinitions +
				'}';
	}

	public static CatalogBuilder builder() {
		return new CatalogBuilder();
	}

	public static class CatalogBuilder {
		private final List<ServiceDefinition> serviceDefinitions = new ArrayList<>();

		CatalogBuilder() {
		}

		public CatalogBuilder serviceDefinitions(List<ServiceDefinition> serviceDefinitions) {
			this.serviceDefinitions.addAll(serviceDefinitions);
			return this;
		}

		public CatalogBuilder serviceDefinitions(ServiceDefinition... serviceDefinitions) {
			Collections.addAll(this.serviceDefinitions, serviceDefinitions);
			return this;
		}

		public Catalog build() {
			return new Catalog(serviceDefinitions);
		}
	}
}

@@ -954,16 +954,308 @@
 ker.%0A *%0A
+ * %3Cp%3E%0A * Objects of this type are constructed by the service broker application,%0A * and used to build the response to the platform.%0A *%0A * @see %3Ca href=%22https://github.com/openservicebrokerapi/servicebroker/blob/master/spec.md#catalog-management%22%3EOpen Service Broker API specification%3C/a%3E%0A *%0A
  * @auth
@@ -1336,83 +1336,8 @@
 og %7B
-%0A%0A%09/**%0A%09 * A list of service offerings provided by the service broker.%0A%09 */
 %0A%09@N
@@ -1534,24 +1534,115 @@
 itions;%0A%09%7D%0A%0A
+%09/**%0A%09 * Get the set of service offerings.%0A%09 *%0A%09 * @return a set of service offerings%0A%09 */%0A
 %09public List
@@ -2170,24 +2170,149 @@
 %09%09%09'%7D';%0A%09%7D%0A%0A
+%09/**%0A%09 * Create a builder that provides a fluent API for constructing a %7B@literal Catalog%7D.%0A%09 *%0A%09 * @return the builder%0A%09 */%0A
 %09public stat
@@ -2527,170 +2527,785 @@
 %0A%0A%09%09
-public CatalogBuilder serviceDefinitions(List%3CServiceDefinition%3E serviceDefinitions) %7B%0A%09%09%09this.serviceDefinitions.addAll(serviceDefinitions);%0A%09%09%09return this;%0A%09%09%7D%0A
+/**%0A%09%09 * Add a set of service offerings from the provided %7B@literal List%7D to the%0A%09%09 * service offerings provided by the service broker.%0A%09%09 *%0A%09%09 * %3Cp%3E%0A%09%09 * This value sets the %7B@literal services%7D field in the response to the platform.%0A%09%09 *%0A%09%09 * @param serviceDefinitions a %7B@literal List%7D of service offerings%0A%09%09 */%0A%09%09public CatalogBuilder serviceDefinitions(List%3CServiceDefinition%3E serviceDefinitions) %7B%0A%09%09%09this.serviceDefinitions.addAll(serviceDefinitions);%0A%09%09%09return this;%0A%09%09%7D%0A%0A%09%09/**%0A%09%09 * Add a set of service offerings from the provided array to the%0A%09%09 * service offerings provided by the service broker.%0A%09%09 *%0A%09%09 * %3Cp%3E%0A%09%09 * This value sets the %7B@literal services%7D field in the response to the platform.%0A%09%09 *%0A%09%09 * @param serviceDefinitions an array of service offerings%0A%09%09 */
 %0A%09%09p
@@ -3476,16 +3476,146 @@
 s;%0A%09%09%7D%0A%0A
+%09%09/**%0A%09%09 * Construct a %7B@link Catalog%7D from the provided values.%0A%09%09 *%0A%09%09 * @return the newly constructed %7B@literal Catalog%7D%0A%09%09 */%0A
 %09%09public

Update javadoc for core/model/catalog package.