Share via


PrimitiveVariableContextVariableTypeConverter<T> Class

Type Parameters

T

the type of the variable

public class PrimitiveVariableContextVariableTypeConverter<T>
extends ContextVariableTypeConverter<T>

A ContextVariableTypeConverter<T> for primitive variables.

Constructor Summary

Constructor Description
PrimitiveVariableContextVariableTypeConverter(Class<T> clazz, Function<String,T> fromPromptString, Function<Object,T> fromObject, Function<T,String> toPromptString)

Creates a new instance of the PrimitiveVariableContextVariableTypeConverter<T> class.

Method Summary

Modifier and Type Method and Description
U toObject(ContextVariableTypes types, Object t, Class<U> clazz)

Use this converter to convert the object to the type of the context variable.

T fromObject(Object s)

Convert the object to the type of the context variable using the fromObject function provided to the constructor.

T fromPromptString(String s)

Convert the prompt string to the type using the fromPromptString function provided to the constructor.

Methods inherited from ContextVariableTypeConverter

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

PrimitiveVariableContextVariableTypeConverter

public PrimitiveVariableContextVariableTypeConverter(Class clazz, Function fromPromptString, Function fromObject, Function toPromptString)

Creates a new instance of the PrimitiveVariableContextVariableTypeConverter<T> class.

Parameters:

clazz - the class
fromPromptString - the function to convert from a prompt string
fromObject - the function to convert from an object to primitive
toPromptString - the function to convert to a prompt string

Method Details

toObject

public U toObject(ContextVariableTypes types, Object t, Class clazz)

Use this converter to convert the object to the type of the context variable.

Overrides:

PrimitiveVariableContextVariableTypeConverter<T>.toObject(ContextVariableTypes types, Object t, Class<U> clazz)

Parameters:

types
t
clazz

fromObject

public T fromObject(Object s)

Convert the object to the type of the context variable using the fromObject function provided to the constructor.

Overrides:

PrimitiveVariableContextVariableTypeConverter<T>.fromObject(Object s)

Parameters:

s

fromPromptString

public T fromPromptString(String s)

Convert the prompt string to the type using the fromPromptString function provided to the constructor.

Overrides:

PrimitiveVariableContextVariableTypeConverter<T>.fromPromptString(String s)

Parameters:

s

Applies to