package tcra.exercises.resolve_prefix_reversal_private;

import java.util.List;
import tcra.math.Assertion;
import tcra.math.MathString;
import tcra.math.MathType;

public class ResolvePrefixReversalCapability_PostPrefix_ReversalAssertion
       implements Assertion
{
   public ResolvePrefixReversalCapability_PostPrefix_ReversalAssertion()
   {}

   @SuppressWarnings("unchecked")
   public boolean check(List<MathType> t)
   {
      MathString<MathType> lb_self = (MathString<MathType>)t.get(0);
      MathString<MathType> lb_pre  = (MathString<MathType>)t.get(1);
      MathString<MathType> self    = (MathString<MathType>)t.get(2);

      return(self.equals(lb_self.prepend(lb_pre.reverse())));
   } // end check(List)
   
   public String toString()
   {
      return("S = #Pre<sup>Rev</sup> * #S;");
   } // end toString()

   @SuppressWarnings("unchecked")
   public String toInstanceString(List<MathType> t)
   {
      MathString<MathType> lb_self = (MathString<MathType>)t.get(0);
      MathString<MathType> lb_pre  = (MathString<MathType>)t.get(1);
      MathString<MathType> self    = (MathString<MathType>)t.get(2);
      
      return(self.toHTMLString() +  " = "+
             lb_pre.reverse().toHTMLString() + " * " +
             lb_self.toHTMLString() + ";");
   } // end toInstanceString(List)
} // end class
