// ** This class was generated with DemFGen (vers:10/21/2008)

package gen;

import edu.neu.ccs.demeterf.demfgen.lib.*;
import edu.neu.ccs.demeterf.*;




public class RawMaterial{
    public final List<Constraint> constraints;

    public RawMaterial(List<Constraint> constraints){
        this.constraints = constraints;
    }
    public boolean equals(Object o){
        if(!(o instanceof RawMaterial))return false;
        RawMaterial oo = (RawMaterial)o;
        return (((Object)constraints).equals(oo.constraints));
    }
    public static RawMaterial parse(String inpt) throws ParseException{
        return new TheParser(new java.io.StringBufferInputStream(inpt)).parse_RawMaterial();
    }
    public static RawMaterial parse(java.io.InputStream inpt) throws ParseException{
        return new TheParser(inpt).parse_RawMaterial();
    }
    public static RawMaterial parse(java.io.Reader inpt) throws ParseException{
        return new TheParser(inpt).parse_RawMaterial();
    }

    public static class constraints extends edu.neu.ccs.demeterf.control.Fields.any{}

    static class RelationNrComp implements java.util.Comparator<RelationNr>{
        public int compare(RelationNr a, RelationNr b){
            // return a.v.compareTo(b.v);
	    return new Integer(a.v).compareTo(b.v);
        }
    }
    public Map<RelationNr,Weight> countRelationNrs(){
        Map<RelationNr,Weight> in = TUCombiner.traverse(this,new TUCombiner<Map<RelationNr,Weight>>(){
                Map<RelationNr,Weight> empty = Map.<RelationNr,Weight>create(new RelationNrComp());
                
                public Map<RelationNr,Weight> combine(){ return empty; }
                public Map<RelationNr,Weight> fold(Map<RelationNr,Weight> a, Map<RelationNr,Weight> b){
                    return a.merge(b, new Map.Merge<Weight>(){
                            public Weight merge(Weight i, Weight j)
			      { return i.sum(j); }
                        });
                }
                Map<RelationNr,Weight> combine(Constraint c, Weight w,  RelationNr r){ return empty.put(r,w); }
            }, Control.bypass(Constraint.class));
        return in;
    }

    public String display(){ return gen.Display.DisplayM(this); }
    public String print(){ return gen.Print.PrintM(this); }
    public String toStr(){ return gen.ToStr.ToStrM(this); }

}