// ** This file was generated with DemFGen (vers:4/15/2011) package nwf; import edu.neu.ccs.demeterf.lib.*; import edu.neu.ccs.demeterf.lib.*; import scg.*; import edu.neu.ccs.demeterf.lib.*; import edu.neu.ccs.demeterf.*; import java.util.Iterator; /** Representation of NWFInstanceSet */ public class NWFInstanceSet implements InstanceSetI{ protected NWFInstance singleton; /** Construct a(n) NWFInstanceSet Instance */ public NWFInstanceSet(NWFInstance singleton){ this.singleton = singleton; } /** Is the given object Equal to this NWFInstanceSet? */ public boolean equals(Object o){ if(!(o instanceof NWFInstanceSet))return false; if(o == this)return true; NWFInstanceSet oo = (NWFInstanceSet)o; return (((Object)singleton).equals(oo.singleton)); } /** Parse an instance of NWFInstanceSet from the given String */ public static NWFInstanceSet parse(String inpt) throws nwf.ParseException{ return new nwf.TheParser(new java.io.StringReader(inpt)).parse_NWFInstanceSet(); } /** Parse an instance of NWFInstanceSet from the given Stream */ public static NWFInstanceSet parse(java.io.InputStream inpt) throws nwf.ParseException{ return new nwf.TheParser(inpt).parse_NWFInstanceSet(); } /** Parse an instance of NWFInstanceSet from the given Reader */ public static NWFInstanceSet parse(java.io.Reader inpt) throws nwf.ParseException{ return new nwf.TheParser(inpt).parse_NWFInstanceSet(); } /** Field Class for NWFInstanceSet.singleton */ public static class singleton extends edu.neu.ccs.demeterf.Fields.any{} /** * Check if an instance belongs to this nwfInstanceSet. * * @param InstanceI instance * @return Option * @author liangyu 1st April */ public Option belongsTo(InstanceI instance) { NWFInstance i = (NWFInstance)instance; if(!i.equals(getSingleton())){ return new Some("The instance " + i.print() + " is different from " + getSingleton().print() + "."); } return new None(); } public Option valid(Config config) { NWFInstance i = getSingleton(); int n = countNode(i); if (n <=0 ) { return new Some("The Instance set has a n <= 0"); } else { return new None(); } } private int countNode(NWFInstance i) { EdgeLabeledGraph g = i.getG(); List> adjs = g.getAdjs(); return adjs.length(); } /** DGP method from Class Display */ public String display(){ return nwf.Display.DisplayM(this); } /** DGP method from Class Print */ public String print(){ return nwf.Print.PrintM(this); } /** DGP method from Class ToStr */ public String toStr(){ return nwf.ToStr.ToStrM(this); } /** DGP method from Class PrintToString */ public String toString(){ return nwf.PrintToString.PrintToStringM(this); } /** DGP method from Class HashCode */ public int hashCode(){ return nwf.HashCode.HashCodeM(this); } /** Setter for field NWFInstanceSet.singleton */ public void setSingleton(NWFInstance _singleton){ singleton = _singleton; } /** Getter for field NWFInstanceSet.singleton */ public NWFInstance getSingleton(){ return singleton; } }