package tcra.exercises.resolve_one_way_list_private;

import java.util.*;
import tcra.math.*;

public class ResolveOneWayList_PostLengthOfPrecAssertion implements
      Assertion
{
   public ResolveOneWayList_PostLengthOfPrecAssertion() {}
   
   @SuppressWarnings("unchecked")
   public boolean check(List<MathType> t)
   {
      MathString<MathType> lb_prec = (MathString<MathType>)t.get(0);
      MathString<MathType> lb_rem  = (MathString<MathType>)t.get(1);
      MathString<MathType> prec    = (MathString<MathType>)t.get(2);
      MathString<MathType> rem     = (MathString<MathType>)t.get(3);
      MathInteger          len     = (MathInteger)t.get(4);

      if(len.getValue() != prec.length()) return false;
      if(!prec.equals(lb_prec))           return false;
      if(!rem.equals(lb_rem))             return false;
      
      return(true);
   } // end check(List<MathType>)

   @SuppressWarnings("unchecked")
   public String toInstanceString(List<MathType> t)
   {
      MathString<MathType> prec    = (MathString<MathType>)t.get(2);
      MathInteger          len     = (MathInteger)t.get(4);
      
      return ""+len.toHTMLString()+" = ( |"+prec.toHTMLString()+"| )";
   } // end toInstanceString(List<MathType>)

   public String toString()
   {
      return "Length_of_Prec = ( |P.Prec| )";
   } // end toString()
} // end class
