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

org.wildfly.swarm.config.webservices.ClientConfig Maven / Gradle / Ivy

package org.wildfly.swarm.config.webservices;

import org.wildfly.swarm.config.runtime.AttributeDocumentation;
import org.wildfly.swarm.config.runtime.ResourceDocumentation;
import org.wildfly.swarm.config.runtime.SingletonResource;
import org.wildfly.swarm.config.runtime.Address;
import org.wildfly.swarm.config.runtime.ResourceType;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyChangeListener;
import java.util.List;
import org.wildfly.swarm.config.runtime.Subresource;
import org.wildfly.swarm.config.webservices.PostHandlerChainConsumer;
import org.wildfly.swarm.config.webservices.PostHandlerChainSupplier;
import org.wildfly.swarm.config.webservices.PostHandlerChain;
import org.wildfly.swarm.config.runtime.SubresourceInfo;
import org.wildfly.swarm.config.webservices.PreHandlerChainConsumer;
import org.wildfly.swarm.config.webservices.PreHandlerChainSupplier;
import org.wildfly.swarm.config.webservices.PreHandlerChain;
import org.wildfly.swarm.config.webservices.PropertyConsumer;
import org.wildfly.swarm.config.webservices.PropertySupplier;
import org.wildfly.swarm.config.webservices.Property;
import org.wildfly.swarm.config.runtime.ModelNodeBinding;

/**
 * Webservice client configuration
 */
@Address("/subsystem=webservices/client-config=*")
@ResourceType("client-config")
public class ClientConfig>
		implements
			org.wildfly.swarm.config.runtime.Keyed {

	private String key;
	private PropertyChangeSupport pcs;
	private ClientConfigResources subresources = new ClientConfigResources();

	public ClientConfig(java.lang.String key) {
		super();
		this.key = key;
	}

	public String getKey() {
		return this.key;
	}

	/**
	 * Adds a property change listener
	 */
	public void addPropertyChangeListener(PropertyChangeListener listener) {
		if (null == this.pcs)
			this.pcs = new PropertyChangeSupport(this);
		this.pcs.addPropertyChangeListener(listener);
	}

	/**
	 * Removes a property change listener
	 */
	public void removePropertyChangeListener(
			java.beans.PropertyChangeListener listener) {
		if (this.pcs != null)
			this.pcs.removePropertyChangeListener(listener);
	}

	public ClientConfigResources subresources() {
		return this.subresources;
	}

	/**
	 * Add all PostHandlerChain objects to this subresource
	 * 
	 * @return this
	 * @param value
	 *            List of PostHandlerChain objects.
	 */
	@SuppressWarnings("unchecked")
	public T postHandlerChains(java.util.List value) {
		this.subresources.postHandlerChains = value;
		return (T) this;
	}

	/**
	 * Add the PostHandlerChain object to the list of subresources
	 * 
	 * @param value
	 *            The PostHandlerChain to add
	 * @return this
	 */
	@SuppressWarnings("unchecked")
	public T postHandlerChain(PostHandlerChain value) {
		this.subresources.postHandlerChains.add(value);
		return (T) this;
	}

	/**
	 * Create and configure a PostHandlerChain object to the list of
	 * subresources
	 * 
	 * @param key
	 *            The key for the PostHandlerChain resource
	 * @param config
	 *            The PostHandlerChainConsumer to use
	 * @return this
	 */
	@SuppressWarnings("unchecked")
	public T postHandlerChain(java.lang.String childKey,
			PostHandlerChainConsumer consumer) {
		PostHandlerChain child = new PostHandlerChain<>(
				childKey);
		if (consumer != null) {
			consumer.accept(child);
		}
		postHandlerChain(child);
		return (T) this;
	}

	/**
	 * Create and configure a PostHandlerChain object to the list of
	 * subresources
	 * 
	 * @param key
	 *            The key for the PostHandlerChain resource
	 * @return this
	 */
	@SuppressWarnings("unchecked")
	public T postHandlerChain(java.lang.String childKey) {
		postHandlerChain(childKey, null);
		return (T) this;
	}

	/**
	 * Install a supplied PostHandlerChain object to the list of subresources
	 */
	@SuppressWarnings("unchecked")
	public T postHandlerChain(PostHandlerChainSupplier supplier) {
		postHandlerChain(supplier.get());
		return (T) this;
	}

	/**
	 * Add all PreHandlerChain objects to this subresource
	 * 
	 * @return this
	 * @param value
	 *            List of PreHandlerChain objects.
	 */
	@SuppressWarnings("unchecked")
	public T preHandlerChains(java.util.List value) {
		this.subresources.preHandlerChains = value;
		return (T) this;
	}

	/**
	 * Add the PreHandlerChain object to the list of subresources
	 * 
	 * @param value
	 *            The PreHandlerChain to add
	 * @return this
	 */
	@SuppressWarnings("unchecked")
	public T preHandlerChain(PreHandlerChain value) {
		this.subresources.preHandlerChains.add(value);
		return (T) this;
	}

	/**
	 * Create and configure a PreHandlerChain object to the list of subresources
	 * 
	 * @param key
	 *            The key for the PreHandlerChain resource
	 * @param config
	 *            The PreHandlerChainConsumer to use
	 * @return this
	 */
	@SuppressWarnings("unchecked")
	public T preHandlerChain(java.lang.String childKey,
			PreHandlerChainConsumer consumer) {
		PreHandlerChain child = new PreHandlerChain<>(
				childKey);
		if (consumer != null) {
			consumer.accept(child);
		}
		preHandlerChain(child);
		return (T) this;
	}

	/**
	 * Create and configure a PreHandlerChain object to the list of subresources
	 * 
	 * @param key
	 *            The key for the PreHandlerChain resource
	 * @return this
	 */
	@SuppressWarnings("unchecked")
	public T preHandlerChain(java.lang.String childKey) {
		preHandlerChain(childKey, null);
		return (T) this;
	}

	/**
	 * Install a supplied PreHandlerChain object to the list of subresources
	 */
	@SuppressWarnings("unchecked")
	public T preHandlerChain(PreHandlerChainSupplier supplier) {
		preHandlerChain(supplier.get());
		return (T) this;
	}

	/**
	 * Add all Property objects to this subresource
	 * 
	 * @return this
	 * @param value
	 *            List of Property objects.
	 */
	@SuppressWarnings("unchecked")
	public T properties(java.util.List value) {
		this.subresources.properties = value;
		return (T) this;
	}

	/**
	 * Add the Property object to the list of subresources
	 * 
	 * @param value
	 *            The Property to add
	 * @return this
	 */
	@SuppressWarnings("unchecked")
	public T property(Property value) {
		this.subresources.properties.add(value);
		return (T) this;
	}

	/**
	 * Create and configure a Property object to the list of subresources
	 * 
	 * @param key
	 *            The key for the Property resource
	 * @param config
	 *            The PropertyConsumer to use
	 * @return this
	 */
	@SuppressWarnings("unchecked")
	public T property(java.lang.String childKey, PropertyConsumer consumer) {
		Property child = new Property<>(childKey);
		if (consumer != null) {
			consumer.accept(child);
		}
		property(child);
		return (T) this;
	}

	/**
	 * Create and configure a Property object to the list of subresources
	 * 
	 * @param key
	 *            The key for the Property resource
	 * @return this
	 */
	@SuppressWarnings("unchecked")
	public T property(java.lang.String childKey) {
		property(childKey, null);
		return (T) this;
	}

	/**
	 * Install a supplied Property object to the list of subresources
	 */
	@SuppressWarnings("unchecked")
	public T property(PropertySupplier supplier) {
		property(supplier.get());
		return (T) this;
	}

	/**
	 * Child mutators for ClientConfig
	 */
	public static class ClientConfigResources {
		/**
		 * Endpoint configuration POST handler chain
		 */
		@ResourceDocumentation("Endpoint configuration POST handler chain")
		@SubresourceInfo("postHandlerChain")
		private List postHandlerChains = new java.util.ArrayList<>();
		/**
		 * Endpoint configuration PRE handler chain
		 */
		@ResourceDocumentation("Endpoint configuration PRE handler chain")
		@SubresourceInfo("preHandlerChain")
		private List preHandlerChains = new java.util.ArrayList<>();
		/**
		 * Endpoint configuration property
		 */
		@ResourceDocumentation("Endpoint configuration property")
		@SubresourceInfo("property")
		private List properties = new java.util.ArrayList<>();

		/**
		 * Get the list of PostHandlerChain resources
		 * 
		 * @return the list of resources
		 */
		@Subresource
		public List postHandlerChains() {
			return this.postHandlerChains;
		}

		public PostHandlerChain postHandlerChain(java.lang.String key) {
			return this.postHandlerChains.stream()
					.filter(e -> e.getKey().equals(key)).findFirst()
					.orElse(null);
		}
		/**
		 * Get the list of PreHandlerChain resources
		 * 
		 * @return the list of resources
		 */
		@Subresource
		public List preHandlerChains() {
			return this.preHandlerChains;
		}

		public PreHandlerChain preHandlerChain(java.lang.String key) {
			return this.preHandlerChains.stream()
					.filter(e -> e.getKey().equals(key)).findFirst()
					.orElse(null);
		}
		/**
		 * Get the list of Property resources
		 * 
		 * @return the list of resources
		 */
		@Subresource
		public List properties() {
			return this.properties;
		}

		public Property property(java.lang.String key) {
			return this.properties.stream().filter(e -> e.getKey().equals(key))
					.findFirst().orElse(null);
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy