// ** This file was generated with DemFGen (vers:4/15/2011)

package hsr;

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





/** Representation of HSRInstanceSet */
public class HSRInstanceSet implements InstanceSetI{
    protected HSRInstance singleton;

    /** Construct a(n) HSRInstanceSet Instance */
    public HSRInstanceSet(HSRInstance singleton){
        this.singleton = singleton;
    }
    /** Is the given object Equal to this HSRInstanceSet? */
    public boolean equals(Object o){
        if(!(o instanceof HSRInstanceSet))return false;
        if(o == this)return true;
        HSRInstanceSet oo = (HSRInstanceSet)o;
        return (((Object)singleton).equals(oo.singleton));
    }
    /** Parse an instance of HSRInstanceSet from the given String */
    public static HSRInstanceSet parse(String inpt) throws hsr.ParseException{
        return new hsr.TheParser(new java.io.StringReader(inpt)).parse_HSRInstanceSet();
    }
    /** Parse an instance of HSRInstanceSet from the given Stream */
    public static HSRInstanceSet parse(java.io.InputStream inpt) throws hsr.ParseException{
        return new hsr.TheParser(inpt).parse_HSRInstanceSet();
    }
    /** Parse an instance of HSRInstanceSet from the given Reader */
    public static HSRInstanceSet parse(java.io.Reader inpt) throws hsr.ParseException{
        return new hsr.TheParser(inpt).parse_HSRInstanceSet();
    }

    /** Field Class for HSRInstanceSet.singleton */
    public static class singleton extends edu.neu.ccs.demeterf.Fields.any{}

        /** Is this a valid/well-formed Instance of the given instance? */
        public Option<String> belongsTo(InstanceI instance){
        	HSRInstance i = (HSRInstance)instance;
        	if(!i.equals(getSingleton())){
        		return new Some<String>("The instance " + i.print() + " is different from " + getSingleton().print() + ".");
        	}
        	return new None<String>();
        }        
        
        /** Is this a valid/well-formed InstanceSet? */
	    public Option<String> valid(Config config){
	       HSRInstance i = getSingleton();
	       int n = i.getN();
	       int k = i.getK();
	       
	       if(n <= 0){
	    	   return new Some<String>("The Instance set has a n <= 0");
	       }else if(k<=0){
	    	   return new Some<String>("The Instance set has a k <= 0");
	       }
	       return new None<String>();
	    }    

    /** DGP method from Class Display */
    public String display(){ return hsr.Display.DisplayM(this); }
    /** DGP method from Class Print */
    public String print(){ return hsr.Print.PrintM(this); }
    /** DGP method from Class ToStr */
    public String toStr(){ return hsr.ToStr.ToStrM(this); }
    /** DGP method from Class PrintToString */
    public String toString(){ return hsr.PrintToString.PrintToStringM(this); }
    /** DGP method from Class HashCode */
    public int hashCode(){ return hsr.HashCode.HashCodeM(this); }
    /** Setter for field HSRInstanceSet.singleton */
    public void setSingleton(HSRInstance _singleton){ singleton = _singleton; }
    /** Getter for field HSRInstanceSet.singleton */
    public HSRInstance getSingleton(){ return singleton; }

}


