Share via


ContextVariableTypes Class

  • java.lang.Object
    • com.microsoft.semantickernel.contextvariables.ContextVariableTypes

public class ContextVariableTypes

A collection of context variable types, with converters to convert objects to the types.

Constructor Summary

Constructor Description
ContextVariableTypes()

Create a new collection of context variable types.

ContextVariableTypes(ContextVariableTypes contextVariableTypes)

Create a new collection of context variable types.

ContextVariableTypes(List<ContextVariableTypeConverter<?>> converters)

Create a new collection of context variable types.

Method Summary

Modifier and Type Method and Description
ContextVariable<T> contextVariableOf(T value)

Create a context variable of the given value.

static T convert(Object s, Class<T> clazz)

Convert the given object to the given class, if possible.

static ContextVariableType<T> getGlobalVariableTypeForClass(Class<T> aClass)

Get the global context variable type for the given class.

ContextVariableType<T> getVariableTypeForClass(Class<T> aClass)

Get the context variable type for the given class.

ContextVariableType<T> getVariableTypeForSuperClass(Class<T> aClass)

Get the context variable type for the given class or for a type that is assignable from the given class.

void putConverter(ContextVariableTypeConverter<T> contextVariableTypeConverter)

Add a converter to this ContextVariableTypes instance.

static void addGlobalConverter(ContextVariableTypeConverter<?> converter)

Add a converter to the global collection of context variable type converters.

static ContextVariableTypes getGlobalTypes()

Get the globally available collectors, which is the default collection of context variable types and those that have been added with addGlobalConverter(ContextVariableTypeConverter<?> converter).

void putConverters(ContextVariableTypes contextVariableTypes)

Add all the converters from the given collection to this collection.

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

ContextVariableTypes

public ContextVariableTypes()

Create a new collection of context variable types.

ContextVariableTypes

public ContextVariableTypes(ContextVariableTypes contextVariableTypes)

Create a new collection of context variable types.

Parameters:

contextVariableTypes - The collection of context variable types to copy.

ContextVariableTypes

public ContextVariableTypes(List> converters)

Create a new collection of context variable types.

Parameters:

converters - The converters to use to convert objects to the types.

Method Details

contextVariableOf

public ContextVariable contextVariableOf(T value)

Create a context variable of the given value.

Parameters:

value - The value to create a context variable of.

Returns:

The context variable of the given value.

convert

public static T convert(Object s, Class clazz)

Convert the given object to the given class, if possible.

Parameters:

s - the object to convert
clazz - the class of the type to convert to

Returns:

the converted object, or null if the object cannot be converted

getGlobalVariableTypeForClass

public static ContextVariableType getGlobalVariableTypeForClass(Class aClass)

Get the global context variable type for the given class.

Parameters:

aClass - The class to get the context variable type for.

Returns:

The context variable type for the given class.

getVariableTypeForClass

public ContextVariableType getVariableTypeForClass(Class aClass)

Get the context variable type for the given class.

Parameters:

aClass - The class to get the context variable type for.

Returns:

The context variable type for the given class

getVariableTypeForSuperClass

public ContextVariableType getVariableTypeForSuperClass(Class aClass)

Get the context variable type for the given class or for a type that is assignable from the given class. its super class.

Parameters:

aClass - The class to get the context variable type for.

Returns:

The context variable type for the given class.

putConverter

public void putConverter(ContextVariableTypeConverter contextVariableTypeConverter)

Add a converter to this ContextVariableTypes instance.

Parameters:

contextVariableTypeConverter - the converter to add.

addGlobalConverter

public static void addGlobalConverter(ContextVariableTypeConverter converter)

Add a converter to the global collection of context variable type converters.

Parameters:

converter - The converter to add.

getGlobalTypes

public static ContextVariableTypes getGlobalTypes()

Get the globally available collectors, which is the default collection of context variable types and those that have been added with addGlobalConverter(ContextVariableTypeConverter<?> converter).

Returns:

The collection of globally available converters.

putConverters

public void putConverters(ContextVariableTypes contextVariableTypes)

Add all the converters from the given collection to this collection.

Parameters:

contextVariableTypes - The collection of converters to add.

Applies to