package lrs; /** * Represents the empty state. Singleton pattern. * @author Dung X. Nguyen Copyright 2000 - All rights reserved. * @since 02/15/00 */ class NullNode extends ANode { /** * Singleton Pattern. */ final static NullNode singleton = new NullNode(); private NullNode() { } /** * Throws java.util.NoSuchElementException. */ LRStruct getRest(LRStruct owner) { throw new java.util.NoSuchElementException("Empty list has no first."); } /** * Throws java.util.NoSuchElementException. */ Object getFirst(LRStruct owner) { throw new java.util.NoSuchElementException("Empty list has no first."); } /** * Throws java.util.NoSuchElementException. */ void setRest(LRStruct tail, LRStruct owner) { throw new java.util.NoSuchElementException("Empty list has no tail."); } /** * Throws java.util.NoSuchElementException. */ void setFirst(Object dat, LRStruct owner) { throw new java.util.NoSuchElementException("Empty list has no first."); } void insertFront(Object dat, LRStruct owner) { owner.setHead(new NonNullNode(dat)); } /** * Throws java.util.NoSuchElementException. */ Object removeFront(LRStruct owner) { throw new java.util.NoSuchElementException("Empty list has no front."); } /** * Calls the visitor's null case. */ Object execute(IAlgo visitor, Object input, LRStruct owner) { return visitor.nullCase(owner, input); } }