@Test public void sameInstanceIsAlwaysReturned() { SingletonOutputWriterFactory outputWriterFactory = new SingletonOutputWriterFactory(new DummyOutputWriterFactory()); OutputWriter outputWriter1 = outputWriterFactory.create(); OutputWriter outputWriter2 = outputWriterFactory.create(); assertThat(outputWriter1).isSameAs(outputWriter2); }
@Override public T create() { return outputWriter; }
SingletonOutputWriterFactory implements OutputWriterFactory<T> { @Override public T create() { return outputWriter; } }
SingletonOutputWriterFactory implements OutputWriterFactory<T> { @Override public T create() { return outputWriter; } SingletonOutputWriterFactory(@Nonnull OutputWriterFactory<T> outputWriterFactory); }
SingletonOutputWriterFactory implements OutputWriterFactory<T> { @Override public T create() { return outputWriter; } SingletonOutputWriterFactory(@Nonnull OutputWriterFactory<T> outputWriterFactory); @Override T create(); }
SingletonOutputWriterFactory implements OutputWriterFactory<T> { @Override public T create() { return outputWriter; } SingletonOutputWriterFactory(@Nonnull OutputWriterFactory<T> outputWriterFactory); @Override T create();  }