Package org.rascalmpl.interpreter.matching

Source Code of org.rascalmpl.interpreter.matching.SingleIValueIterator

/*******************************************************************************
* Copyright (c) 2009-2013 CWI
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:

*   * Jurgen J. Vinju - Jurgen.Vinju@cwi.nl - CWI
*   * Paul Klint - Paul.Klint@cwi.nl - CWI
*******************************************************************************/
package org.rascalmpl.interpreter.matching;

import java.util.Iterator;

import org.eclipse.imp.pdb.facts.IValue;
import org.rascalmpl.interpreter.asserts.ImplementationError;


/*
* SingleIValueIterator turns a single IValue into an Iterator that
* can be used for implementing generators.
*/

public class SingleIValueIterator implements Iterator<IValue>
  private IValue value;
  private boolean firstCall;

  SingleIValueIterator(IValue value){
    this.value = value;
    this.firstCall = true;
  }

  public boolean hasNext() {
   
    return firstCall;
  }

  public IValue next() {
    if(!firstCall){
      throw new ImplementationError("next called more than once");
    }
    firstCall = false;
    return value;
  }

  public void remove() {
    throw new UnsupportedOperationException("remove for SingleIValueIterator");
 
}
TOP

Related Classes of org.rascalmpl.interpreter.matching.SingleIValueIterator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.