Top Description Fields Constructors Methods
org.testng.internal

public final Class ObjectBag

extends Object
Class Inheritance
Imports
java.util.Map, .Optional, .UUID, java.util.concurrent.ConcurrentHashMap, .ExecutorService, java.util.function.Supplier, org.testng.ISuite, org.testng.log4testng.Logger, org.testng.xml.XmlSuite

A simple bean bag that is intended to help share objects during the lifetime of TestNG without needing it to be a singleton.

Field Summary

Modifier and TypeField and Description
private final Map<Class<?>, Object>
private static final Map<UUID, ObjectBag>
private static final Logger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
cleanup(ISuite suite)

public void
public Object

Returns:

- Either the newly produced instance or the existing instance.
createIfRequired
(Class<?>
- The type of the object to be created
type
,
Supplier<Object>
- A Supplier that should be used to produce a new instance
supplier
)

public static ObjectBag
public static ObjectBag
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bagback to summary
private final Map<Class<?>, Object> bag
instancesback to summary
private static final Map<UUID, ObjectBag> instances
loggerback to summary
private static final Logger logger

Constructor Detail

ObjectBagback to summary
public ObjectBag()

Method Detail

cleanupback to summary
public static void cleanup(ISuite suite)
cleanupback to summary
public void cleanup()
createIfRequiredback to summary
public Object createIfRequired(Class<?> type, Supplier<Object> supplier)
Parameters
type:Class<?>

- The type of the object to be created

supplier:Supplier<Object>

- A Supplier that should be used to produce a new instance

Returns:Object

- Either the newly produced instance or the existing instance.

getInstanceback to summary
public static ObjectBag getInstance(ISuite suite)
getInstanceback to summary
public static ObjectBag getInstance(XmlSuite xmlSuite)