package ru.susu.algebra.field.quadratic;
import java.math.BigInteger;
import com.google.common.base.Function;
import ru.susu.algebra.ui.field.ILegendField;
/**
* @author akargapolov
* @since: 16.07.2010
*/
public class QuadraticIntegerExtractor implements Function<Object, QuadraticInteger>
{
private static QuadraticIntegerExtractor _instance = new QuadraticIntegerExtractor();
public static QuadraticIntegerExtractor getInstance()
{
return _instance;
}
@Override
public QuadraticInteger apply(Object from)
{
if (from instanceof ILegendField<?>)
{
ILegendField<?> legend = ( ILegendField<?>)from;
return apply(legend.getValue());
}
else if (from instanceof BigInteger)
{
return new QuadraticInteger((BigInteger)from, BigInteger.ZERO, BigInteger.ZERO);
}
return (QuadraticInteger)from;
}
}
|