

package LRSVisitor;

import LRStructure.*;

public class LRSSum implements IAlgo{
	/** @SBGen Singleton Variable   */
	private static LRSSum singleton = null;	/** @SBGen Singleton   */
	public static LRSSum Singleton()
	{
		// SBgen: Ensure single instance
		if (singleton == null) 
			singleton = new LRSSum();
		return(singleton);
		// SBgen: End singleton
	}
	/** @SBGen Constructor   */
	private LRSSum()
	{
	}

  public Object nullCase(LRStruct host, Object param)
  {
      return new Integer(0);
  }

  public Object nonNullCase(LRStruct host, Object param)
  {
      return new Integer(
                         ((Integer) host.getFirst()).intValue()
                         + ((Integer)host.getRest().execute(this,param)).intValue()
                         );
  }

}