/*
 * Copyright 2015 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.bus;

import org.springframework.boot.context.properties.ConfigurationProperties;

import lombok.Data;

/**
 * @author Dave Syer
 *
 */
@Data
@ConfigurationProperties("spring.cloud.bus")
public class BusProperties {

	private Env env = new Env();
	private Refresh refresh = new Refresh();
	private Ack ack = new Ack();
	private Trace trace = new Trace();
	/**
	 * Name of Spring Cloud Stream destination for messages.
	 */
	private String destination = "topic:springCloudBus";

	private boolean enabled = true;

	public String getDestination() {
		if (this.destination.startsWith("topic:")) {
			return this.destination;
		}
		return "topic:" + this.destination;
	}

	@Data
	public static class Env {
		/**
		 * Flag to switch off environment change events (default on).
		 */
		private boolean enabled = true;
	}

	@Data
	public static class Refresh {
		/**
		 * Flag to switch off refresh events (default on).
		 */
		private boolean enabled = true;
	}

	@Data
	public static class Ack {
		/**
		 * Flag to switch off acks (default on).
		 */
		private boolean enabled = true;
		/**
		 * Service that wants to listen to acks. By default null (meaning all services).
		 */
		private String destinationService;
	}

	@Data
	public static class Trace {
		/**
		 * Flag to switch on tracing of acks (default off).
		 */
		private boolean enabled = false;
	}

}

@@ -866,108 +866,310 @@
 %7B%0A%0A%09
-private Env env = new Env();%0A%09private Refresh refresh = new Refresh();%0A%09private Ack ack = new Ack();
+/**%0A%09 * Environment change event related properties.%0A%09 */%0A%09private Env env = new Env();%0A%09/**%0A%09 * Refresh event related properties.%0A%09 */%0A%09private Refresh refresh = new Refresh();%0A%09/**%0A%09 * Properties related to acks.%0A%09 */%0A%09private Ack ack = new Ack();%0A%09/**%0A%09 * Properties related to tracing of acks.%0A%09 */
 %0A%09pr
@@ -1324,16 +1324,72 @@
 dBus%22;%0A%0A
+%09/**%0A%09 * Flag to indicate that the bus is enabled.%0A%09 */%0A
 %09private

Add some docs for config properties