TurnContextStateCollection Class

  • java.lang.Object
    • com.microsoft.bot.builder.TurnContextStateCollection

Implements

java.lang.AutoCloseable

public class TurnContextStateCollection
implements java.lang.AutoCloseable

Represents a set of collection of services associated with the TurnContext.

Constructor Summary

Constructor Description
TurnContextStateCollection()

Method Summary

Modifier and Type Method and Description
void <T>add(T value)

Add a service using its type name (Class#getName() as the key.

void <T>add(String key, T value)

Adds a value to the turn's context.

T <T>get(Class<T> type)

Get a service by type using its full type name as the key.

T <T>get(String key)

Get a value.

void <T>replace(T value)

Replaces a value.

void close()

Close all contained AutoCloseable values.

boolean containsKey(String key)

Returns true if this contains a mapping for the specified key.

void copy(TurnContextStateCollection other)

Copy the values from another TurnContextStateCollection.

void finalize()

Auto call of #close.

java.util.Map<java.lang.String,java.lang.Object> getTurnStateServices()

Returns the Services stored in the TurnContextStateCollection.

void remove(String key)

Removes a value.

void replace(String key, Object value)

Replaces a value.

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Constructor Details

TurnContextStateCollection

public TurnContextStateCollection()

Method Details

<T>add

public void add(T value)

Add a service using its type name (Class#getName() as the key.

Parameters:

value - The service to add.

Throws:

java.lang.IllegalArgumentException - For null value.

<T>add

public void add(String key, T value)

Adds a value to the turn's context.

Parameters:

key - The name of the value.
value - The value to add.

Throws:

java.lang.IllegalArgumentException - For null key or value.

<T>get

public T get(Class type)

Get a service by type using its full type name as the key.

Parameters:

type - The type of service to be retrieved. This will use the value returned by Class.getName as the key.

Returns:

The service stored under the specified key.

<T>get

public T get(String key)

Get a value.

Parameters:

key - The key.

Returns:

The value.

Throws:

java.lang.IllegalArgumentException - Null key.

<T>replace

public void replace(T value)

Replaces a value.

Parameters:

value - The service to add.

close

public void close()

Close all contained AutoCloseable values.

Throws:

java.lang.Exception - Exceptions encountered by children during close.

containsKey

public boolean containsKey(String key)

Returns true if this contains a mapping for the specified key.

Parameters:

key - The name of the value.

Returns:

True if the key exists.

copy

public void copy(TurnContextStateCollection other)

Copy the values from another TurnContextStateCollection.

Parameters:

other - The collection to copy.

finalize

public void finalize()

Auto call of #close.

Overrides:

TurnContextStateCollection.finalize()

getTurnStateServices

public Map getTurnStateServices()

Returns the Services stored in the TurnContextStateCollection.

Returns:

the Map of String, Object pairs that contains the names and services for this collection.

remove

public void remove(String key)

Removes a value.

Parameters:

key - The name of the value to remove.

replace

public void replace(String key, Object value)

Replaces a value.

Parameters:

key - The name of the value to replace.
value - The new value.

Applies to