/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * The contents of this file are subject to the terms of the Liferay Enterprise
 * Subscription License ("License"). You may not use this file except in
 * compliance with the License. You can obtain a copy of the License by
 * contacting Liferay, Inc. See the License for the specific language governing
 * permissions and limitations under the License, including but not limited to
 * distribution rights of the Software.
 *
 *
 *
 */

package com.liferay.portal.cache.configuration;

import java.util.Collections;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;

/**
 * @author Tina Tian
 */
public class PortalCacheConfiguration {

	/**
	 * @deprecated As of Judson (7.1.x), replaced by {@link
	 *             #PORTAL_CACHE_NAME_DEFAULT}
	 */
	@Deprecated
	public static final String DEFAULT_PORTAL_CACHE_NAME = "default";

	public static final String PORTAL_CACHE_LISTENER_PROPERTIES_KEY_SCOPE =
		"PORTAL_CACHE_LISTENER_PROPERTIES_KEY_SCOPE";

	/**
	 * @deprecated As of Judson (7.1.x), replaced by {@link
	 *             #PORTAL_CACHE_LISTENER_PROPERTIES_KEY_SCOPE}
	 */
	@Deprecated
	public static final String PORTAL_CACHE_LISTENER_SCOPE =
		"PORTAL_CACHE_LISTENER_SCOPE";

	public static final String PORTAL_CACHE_NAME_DEFAULT = "default";

	public PortalCacheConfiguration(
		String portalCacheName,
		Set<Properties> portalCacheListenerPropertiesSet,
		Properties portalCacheBootstrapLoaderProperties) {

		if (portalCacheName == null) {
			throw new NullPointerException("Portal cache name is null");
		}

		_portalCacheName = portalCacheName;

		if (portalCacheListenerPropertiesSet == null) {
			_portalCacheListenerPropertiesSet = Collections.emptySet();
		}
		else {
			_portalCacheListenerPropertiesSet = new HashSet<>(
				portalCacheListenerPropertiesSet);
		}
	}

	/**
	 * @deprecated As of Wilberforce (7.0.x), with no direct replacement
	 */
	@Deprecated
	public Properties getPortalCacheBootstrapLoaderProperties() {
		return null;
	}

	public Set<Properties> getPortalCacheListenerPropertiesSet() {
		return _portalCacheListenerPropertiesSet;
	}

	public String getPortalCacheName() {
		return _portalCacheName;
	}

	public PortalCacheConfiguration newPortalCacheConfiguration(
		String portalCacheName) {

		return new PortalCacheConfiguration(
			portalCacheName, _portalCacheListenerPropertiesSet, null);
	}

	/**
	 * @deprecated As of Wilberforce (7.0.x), with no direct replacement
	 */
	@Deprecated
	public void setPortalCacheBootstrapLoaderProperties(
		Properties portalCacheBootstrapLoaderProperties) {
	}

	private final Set<Properties> _portalCacheListenerPropertiesSet;
	private final String _portalCacheName;

}