Class NumberVariableContextVariableTypeConverter<T extends Number>
- java.lang.Object
-
- com.microsoft.semantickernel.contextvariables.ContextVariableTypeConverter<T>
-
- com.microsoft.semantickernel.contextvariables.converters.NumberVariableContextVariableTypeConverter<T>
-
- Type Parameters:
T- the type of the number
public class NumberVariableContextVariableTypeConverter<T extends Number> extends ContextVariableTypeConverter<T>
AContextVariableTypeConverterforjava.lang.Numbertype variables. Use, for example,ContextVariableTypes.getGlobalVariableTypeForClass(Integer.class)to get an instance of this class that works with theIntegertype.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.microsoft.semantickernel.contextvariables.ContextVariableTypeConverter
ContextVariableTypeConverter.Converter<T,U>, ContextVariableTypeConverter.DefaultConverter<T,U>, ContextVariableTypeConverter.NoopConverter<T>
-
-
Constructor Summary
Constructors Constructor Description NumberVariableContextVariableTypeConverter(Class<T> clazz, Function<String,T> fromPromptString, Function<Number,T> fromNumber)Creates a new instance of theNumberVariableContextVariableTypeConverterclass.
-
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(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
getType, toPromptString
-
-
-
-
Constructor Detail
-
NumberVariableContextVariableTypeConverter
public NumberVariableContextVariableTypeConverter(Class<T> clazz, Function<String,T> fromPromptString, Function<Number,T> fromNumber)
Creates a new instance of theNumberVariableContextVariableTypeConverterclass.- Parameters:
clazz- the classfromPromptString- the function to convert from a prompt stringfromNumber- the function to convert from a number
-
-
Method Detail
-
toObject
@Nullable public <U> U toObject(@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 extends Number>- Type Parameters:
U- the type to convert to- Parameters:
t- 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 extends Number>- 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 extends Number>- Parameters:
s- the prompt string to convert- Returns:
- the type
-
-