package org.teiid.core.types.basic;

import org.teiid.core.types.Transform;
import org.teiid.core.types.TransformationException;

import java.math.BigDecimal;

public class DecimalToStringTransform extends Transform {
    private final Class<?> sourceType;

    public DecimalToStringTransform(Class<?> sourceType) {
        this.sourceType = sourceType;
    }

    public Class<?> getSourceType() {
        return sourceType;
    }

    public Class<?> getTargetType() {
        return String.class;
    }

    public Object transformDirect(Object value) throws TransformationException {
        return new BigDecimal(value.toString()).toPlainString();
    }
}
