

package lrs.visitor;

import lrs.*;

import logic.*;



/**

 * Removes the leading consecutive multiple of an integer from the host.

 */

public class RemLeadMods implements IAlgo {

 

 public static RemLeadMods Singleton = new RemLeadMods();

 private RemLeadMods(){}



 /**

  * @param host 

  * @param param 

  * @return 

  */

 public Object emptyCase(LRStruct host, Object... param) {

  return (null); // Nothing to remove.

 }



 /**

  * Removes leading multiples of param from host.

  * @param host the LRS to filter.

  * @param param the factor to be filtered

  * @return 

  */

 public Object nonEmptyCase(final LRStruct host, final Object... param) {

   BooleanFactory.Singleton.makeBoolean(((Integer) host.getFirst()) > ((Integer) param[0])).

     execute( new IBooleanAlgo() {

     public Object trueCase(IBoolean h, Object... inp) {

       host.removeFront ();

       return host.execute (RemLeadMods.this, param);

     }

     public Object falseCase(IBoolean h, Object... inp) {

       return null;

     }

   });



   

//   if (((Integer) host.getFirst ()).intValue () % ((Integer)param[0]).intValue () == 0)

//  {

//   host.removeFront ();

//   host.execute (this, param[0]);

//  } 

  return (host.getFirst ()); // 

 }

}



