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

com.softicar.platform.common.core.locale.LocaleScope Maven / Gradle / Ivy

Go to download

The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.

There is a newer version: 50.0.0
Show newest version
package com.softicar.platform.common.core.locale;

/**
 * An {@link AutoCloseable} that controls {@link CurrentLocale}.
 *
 * @author Oliver Richers
 */
public class LocaleScope implements AutoCloseable {

	private final ILocale originalLocale;

	/**
	 * Sets {@link CurrentLocale} to the given {@link ILocale}.
	 *
	 * @param locale
	 *            the {@link ILocale} to set (never null)
	 */
	public LocaleScope(ILocale locale) {

		this.originalLocale = CurrentLocale.get();
		CurrentLocale.set(locale);
	}

	/**
	 * Reverts {@link CurrentLocale} to the original value.
	 */
	@Override
	public void close() {

		CurrentLocale.set(originalLocale);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy