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

com.liferay.layout.util.UpdateLayoutStatusThreadLocal Maven / Gradle / Ivy

There is a newer version: 50.2.0
Show newest version
/**
 * SPDX-FileCopyrightText: (c) 2023 Liferay, Inc. https://liferay.com
 * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
 */

package com.liferay.layout.util;

import com.liferay.petra.lang.CentralizedThreadLocal;
import com.liferay.petra.lang.SafeCloseable;

/**
 * @author Lourdes Fernández Besada
 */
public class UpdateLayoutStatusThreadLocal {

	public static Boolean isUpdateLayoutStatus() {
		return _updateLayoutStatus.get();
	}

	public static SafeCloseable setUpdateLayoutStatusWithSafeCloseable(
		Boolean updateLayoutStatus) {

		boolean currentUpdateLayoutStatus = _updateLayoutStatus.get();

		_updateLayoutStatus.set(updateLayoutStatus);

		return () -> _updateLayoutStatus.set(currentUpdateLayoutStatus);
	}

	private static final CentralizedThreadLocal _updateLayoutStatus =
		new CentralizedThreadLocal<>(
			UpdateLayoutStatusThreadLocal.class + "._updateLayoutStatus",
			() -> Boolean.TRUE);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy