package rac; /** * Shows the String content of the circular list. */ public class ToString implements IRACVisitor { /** * Singleton pattern. */ public static final ToString Singleton = new ToString(); private ToString() { } /** * Returns the empty String. * @param nu not used * @return String */ public Object stopCase(RACStopNode host, Object nu) { return ""; } /** * Prints each element in the circular list one per line. * @param nu not used * @return String */ public Object dataCase(RACDataNode host, Object nu) { return host.getData() + "\n" + host.getNext().execute(this, null); } }