package dynamake.commands;

import java.io.Serializable;
import java.util.ArrayDeque;

public class ExecutionScope implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private ArrayDeque<Object> production = new ArrayDeque<Object>();
	
	public void produce(Object value) {
		production.addLast(value);
	}
	
	public Object consume() {
		return production.pollFirst();
	}

	public void unproduce() {
		production.removeLast();
	}

	public void unconsume(Object value) {
		production.addFirst(value);
	}
}

package dynamake.commands;

import java.io.Serializable;
import java.util.ArrayDeque;

public class ExecutionScope implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private static class NullWrapper {
		
	}

	private ArrayDeque<Object> production = new ArrayDeque<Object>();
	
	public void produce(Object value) {
		if(value == null)
			value = new NullWrapper();
		
		production.addLast(value);
	}
	
	public Object consume() {
		Object value =  production.pollFirst();
		return value instanceof NullWrapper ? null : value;
	}

	public void unproduce() {
		production.removeLast();
	}

	public void unconsume(Object value) {
		production.addFirst(value);
	}
}

Add support for producing/consuming Java nulls in a scope.
Add support for producing/consuming Java nulls in a scope.

Signed-off-by: Jakob Brandsborg Ehmsen <387ed33cc9ebf98b733caa2520baacd616b28aa5@gmail.com>