ThreadLocalStack { public T push(T item) { Preconditions.checkNotNull(item); Deque<T> stack = stackLocal.get(); T current; if (stack == null) { stack = new ArrayDeque<>(); current = null; stackLocal.set(stack); } else { current = stack.peekFirst(); } stack.addFirst(item); return current; }  T push(T item); T peek(); T pop(); T popOrError(); T get(); T getOrError(); void set(T item); void remove(); void with(T item, WithProcedure procedure);  }
@Test public void push() { assertThat(stack.push("push"), equalTo(INITIAL_VALUE)); }
@Test(expected = NullPointerException.class) public void pushNull() { stack.push(null); }