static TypedValue toTypedValue()

in explainability/explainability-service/src/main/java/org/kie/kogito/explainability/ConversionUtils.java [341:357]


    static TypedValue toTypedValue(String name, Type type, Value value) {
        Object underlyingObject = value.getUnderlyingObject();
        if (type.equals(Type.BOOLEAN)) {
            if (underlyingObject instanceof Boolean) {
                return new UnitValue(Boolean.class.getSimpleName(), BooleanNode.valueOf(((Boolean) underlyingObject)));
            }
        } else if (type.equals(Type.NUMBER)) {
            if (underlyingObject instanceof Double) {
                return new UnitValue(Double.class.getSimpleName(), new DoubleNode((Double) underlyingObject));
            }
        } else if (type.equals(Type.TEXT)) {
            if (underlyingObject instanceof String) {
                return new UnitValue(String.class.getSimpleName(), new TextNode((String) underlyingObject));
            }
        }
        throw new IllegalArgumentException(String.format("Unable to convert '%s' with Type '%s' and Value '%s'", name, type, value));
    }