Class PrimitiveVariableContextVariableTypeConverter<T>
- java.lang.Object
-
- com.microsoft.semantickernel.contextvariables.ContextVariableTypeConverter<T>
-
- com.microsoft.semantickernel.contextvariables.converters.PrimitiveVariableContextVariableTypeConverter<T>
-
- Type Parameters:
T- the type of the variable
- Direct Known Subclasses:
NumberVariableContextVariableTypeConverter,PrimitiveBooleanVariableContextVariableTypeConverter
public class PrimitiveVariableContextVariableTypeConverter<T> extends ContextVariableTypeConverter<T>
AContextVariableTypeConverterfor primitive variables.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.microsoft.semantickernel.contextvariables.ContextVariableTypeConverter
ContextVariableTypeConverter.Builder<T>, ContextVariableTypeConverter.Converter<T,U>, ContextVariableTypeConverter.DefaultConverter<T,U>, ContextVariableTypeConverter.NoopConverter<T>, ContextVariableTypeConverter.ToPromptStringFunction<T>
-
-
Constructor Summary
Constructors Constructor Description PrimitiveVariableContextVariableTypeConverter(Class<T> clazz, Function<String,T> fromPromptString, Function<Object,T> fromObject, Function<T,String> toPromptString)Creates a new instance of thePrimitiveVariableContextVariableTypeConverterclass.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TfromObject(Object s)Convert the object to the type of the context variable using thefromObjectfunction provided to the constructor.TfromPromptString(String s)Convert the prompt string to the type using thefromPromptStringfunction provided to the constructor.<U> UtoObject(ContextVariableTypes types, Object t, Class<U> clazz)Use this converter to convert the object to the type of the context variable.-
Methods inherited from class com.microsoft.semantickernel.contextvariables.ContextVariableTypeConverter
builder, escapeXmlString, getType, toPromptString
-
-
-
-
Constructor Detail
-
PrimitiveVariableContextVariableTypeConverter
public PrimitiveVariableContextVariableTypeConverter(Class<T> clazz, Function<String,T> fromPromptString, Function<Object,T> fromObject, Function<T,String> toPromptString)
Creates a new instance of thePrimitiveVariableContextVariableTypeConverterclass.- Parameters:
clazz- the classfromPromptString- the function to convert from a prompt stringfromObject- the function to convert from an object to primitive
-
-
Method Detail
-
toObject
@Nullable public <U> U toObject(ContextVariableTypes types, @Nullable Object t, Class<U> clazz)
Description copied from class:ContextVariableTypeConverterUse this converter to convert the object to the type of the context variable.- Overrides:
toObjectin classContextVariableTypeConverter<T>- Type Parameters:
U- the type to convert tot- the object to convertclazz- the class of the type to convert to- Returns:
- the converted object
-
fromObject
@Nullable public T fromObject(@Nullable Object s)
Description copied from class:ContextVariableTypeConverterConvert the object to the type of the context variable using thefromObjectfunction provided to the constructor.- Overrides:
fromObjectin classContextVariableTypeConverter<T>- Parameters:
s- the object to convert- Returns:
- the converted object
-
fromPromptString
@Nullable public T fromPromptString(@Nullable String s)
Description copied from class:ContextVariableTypeConverterConvert the prompt string to the type using thefromPromptStringfunction provided to the constructor.- Overrides:
fromPromptStringin classContextVariableTypeConverter<T>- Parameters:
s- the prompt string to convert- Returns:
- the type
-
-