QuadraticIntegerExtractor.java :  » Math » algebra » ru » susu » algebra » field » quadratic » Java Open Source

Java Open Source » Math » algebra 
algebra » ru » susu » algebra » field » quadratic » QuadraticIntegerExtractor.java
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;
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.