com.softicar.platform.common.core.singleton.CurrentSingletonSet Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of platform-common Show documentation
Show all versions of platform-common Show documentation
The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.
package com.softicar.platform.common.core.singleton;
import java.util.Objects;
/**
* Holds the currently active {@link SingletonSet} of the current
* {@link Thread}.
*
* @author Oliver Richers
*/
public class CurrentSingletonSet {
private static final SingletonSetThreadLocal INSTANCE = new SingletonSetThreadLocal();
/**
* Returns the currently active {@link SingletonSet}.
*
* @return the current {@link SingletonSet} (never null)
*/
public static SingletonSet get() {
return INSTANCE.get();
}
/**
* Defines the currently active {@link SingletonSet}.
*
* This method should not be called directly. Instead,
* {@link SingletonSetScope} should be used.
*
* @param singletonSet
* the {@link SingletonSet} to use (never null)
*/
public static void set(SingletonSet singletonSet) {
Objects.requireNonNull(singletonSet);
INSTANCE.set(singletonSet);
}
/**
* Removes the current {@link SingletonSet}.
*/
public static void remove() {
INSTANCE.remove();
}
}