package org.teiid.core.types.basic;

import java.math.BigInteger;

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

public class BigintToBinaryTransform extends Transform {
	public Object transformDirect(Object value) throws TransformationException {
		BigInteger contents = (BigInteger) value;
		return new BinaryType(contents.toByteArray());
	}

	public Class<?> getSourceType() {
		return DataTypeManager.DefaultDataClasses.BIG_INTEGER;
	}

	public Class<?> getTargetType() {
		return DataTypeManager.DefaultDataClasses.VARBINARY;
	}

	@Override
	public boolean isExplicit() {
		return true;
	}
}
