@Test public void justOnce() { OnceSupplier<Integer> s = new OnceSupplier<>(10); assertEquals(10, (long) s.get()); mThrown.expect(IllegalStateException.class); s.get(); }
@Override public synchronized T get() { if (mInit) { throw new IllegalStateException("OnceSupplier called multiple times"); } mInit = true; return mValue; }
OnceSupplier implements Supplier<T> { @Override public synchronized T get() { if (mInit) { throw new IllegalStateException("OnceSupplier called multiple times"); } mInit = true; return mValue; } }
OnceSupplier implements Supplier<T> { @Override public synchronized T get() { if (mInit) { throw new IllegalStateException("OnceSupplier called multiple times"); } mInit = true; return mValue; } OnceSupplier(T value); }
OnceSupplier implements Supplier<T> { @Override public synchronized T get() { if (mInit) { throw new IllegalStateException("OnceSupplier called multiple times"); } mInit = true; return mValue; } OnceSupplier(T value); @Override synchronized T get(); }
OnceSupplier implements Supplier<T> { @Override public synchronized T get() { if (mInit) { throw new IllegalStateException("OnceSupplier called multiple times"); } mInit = true; return mValue; } OnceSupplier(T value); @Override synchronized T get();  }