@Test(expected = IllegalStateException.class) public void mustSetDelegateBeforeUse() { ClientDescriptor clientDescriptor = mock(ClientDescriptor.class); ProxyClientConnectionCloser proxyCloser = new ProxyClientConnectionCloser(); proxyCloser.closeClientConnection(clientDescriptor); }
@Override public void closeClientConnection(ClientDescriptor clientDescriptor) { ClientConnectionCloser currentDelegate = delegate; if (currentDelegate == null) { throw new IllegalStateException("No calls to closeClientConnection() should be made before the delegate ClientConnectionCloser has been set"); } currentDelegate.closeClientConnection(clientDescriptor); }
ProxyClientConnectionCloser implements ClientConnectionCloser { @Override public void closeClientConnection(ClientDescriptor clientDescriptor) { ClientConnectionCloser currentDelegate = delegate; if (currentDelegate == null) { throw new IllegalStateException("No calls to closeClientConnection() should be made before the delegate ClientConnectionCloser has been set"); } currentDelegate.closeClientConnection(clientDescriptor); } }
ProxyClientConnectionCloser implements ClientConnectionCloser { @Override public void closeClientConnection(ClientDescriptor clientDescriptor) { ClientConnectionCloser currentDelegate = delegate; if (currentDelegate == null) { throw new IllegalStateException("No calls to closeClientConnection() should be made before the delegate ClientConnectionCloser has been set"); } currentDelegate.closeClientConnection(clientDescriptor); }  }
ProxyClientConnectionCloser implements ClientConnectionCloser { @Override public void closeClientConnection(ClientDescriptor clientDescriptor) { ClientConnectionCloser currentDelegate = delegate; if (currentDelegate == null) { throw new IllegalStateException("No calls to closeClientConnection() should be made before the delegate ClientConnectionCloser has been set"); } currentDelegate.closeClientConnection(clientDescriptor); }  void setClientConnectionCloser(ClientConnectionCloser delegate); @Override void closeClientConnection(ClientDescriptor clientDescriptor); }
ProxyClientConnectionCloser implements ClientConnectionCloser { @Override public void closeClientConnection(ClientDescriptor clientDescriptor) { ClientConnectionCloser currentDelegate = delegate; if (currentDelegate == null) { throw new IllegalStateException("No calls to closeClientConnection() should be made before the delegate ClientConnectionCloser has been set"); } currentDelegate.closeClientConnection(clientDescriptor); }  void setClientConnectionCloser(ClientConnectionCloser delegate); @Override void closeClientConnection(ClientDescriptor clientDescriptor);  }