package org.realityforge.replicant.client.runtime;

import java.util.Date;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.realityforge.replicant.client.ChannelDescriptor;
import org.realityforge.replicant.client.transport.AreaOfInterestAction;
import org.realityforge.replicant.client.transport.ClientSession;
import org.realityforge.replicant.client.transport.DataLoaderListener;
import org.realityforge.replicant.client.transport.DataLoaderListenerSupport;
import org.realityforge.replicant.client.transport.DataLoaderService;

final class TestDataLoaderService
  implements DataLoaderService
{
  private final String _key;
  private final Class _graphType;
  private State _state;
  private boolean _connectCalled;
  private boolean _disconnectCalled;
  private final DataLoaderListenerSupport _listenerSupport = new DataLoaderListenerSupport();

  TestDataLoaderService( final String key, final Class graphType )
  {
    _key = key;
    _graphType = graphType;
    _state = State.DISCONNECTED;
  }

  void setState( @Nonnull final State state )
  {
    _state = state;
  }

  @Nonnull
  @Override
  public State getState()
  {
    return _state;
  }

  void reset()
  {
    _connectCalled = false;
    _disconnectCalled = false;
  }

  @Override
  public void connect()
  {
    _connectCalled = true;
  }

  boolean isConnectCalled()
  {
    return _connectCalled;
  }

  @Override
  public void disconnect()
  {
    _disconnectCalled = true;
  }

  boolean isDisconnectCalled()
  {
    return _disconnectCalled;
  }

  @Override
  public void scheduleDataLoad()
  {
  }

  @Override
  public boolean addDataLoaderListener( @Nonnull final DataLoaderListener listener )
  {
    return _listenerSupport.addListener( listener );
  }

  @Override
  public boolean removeDataLoaderListener( @Nonnull final DataLoaderListener listener )
  {
    return _listenerSupport.removeListener( listener );
  }

  DataLoaderListenerSupport getListener()
  {
    return _listenerSupport;
  }

  @Nonnull
  @Override
  public String getKey()
  {
    return _key;
  }

  @Nonnull
  @Override
  public Class getGraphType()
  {
    return _graphType;
  }

  @Override
  public boolean isSubscribed( @Nonnull final ChannelDescriptor descriptor )
  {
    return false;
  }

  @Override
  public boolean isIdle()
  {
    return true;
  }

  @Nullable
  @Override
  public Date getConnectingAt()
  {
    return null;
  }

  @Nullable
  @Override
  public Date getConnectedAt()
  {
    return null;
  }

  @Nullable
  @Override
  public Date getDisconnectedAt()
  {
    return null;
  }

  @Nullable
  @Override
  public Throwable getLastErrorDuringConnection()
  {
    return null;
  }

  @Nullable
  @Override
  public Throwable getLastError()
  {
    return null;
  }

  @Nullable
  @Override
  public Date getLastErrorAt()
  {
    return null;
  }

  @Nullable
  @Override
  public ClientSession getSession()
  {
    return null;
  }

  @SuppressWarnings( "ConstantConditions" )
  @Nonnull
  @Override
  public ClientSession ensureSession()
  {
    return null;
  }

  @Override
  public boolean isAreaOfInterestActionPending( @Nonnull final AreaOfInterestAction action,
                                                @Nonnull final ChannelDescriptor descriptor,
                                                @Nullable final Object filter )
  {
    return false;
  }

  @Override
  public int indexOfPendingAreaOfInterestAction( @Nonnull final AreaOfInterestAction action,
                                                 @Nonnull final ChannelDescriptor descriptor,
                                                 @Nullable final Object filter )
  {
    return -1;
  }
}

@@ -671,16 +671,32 @@
 al Class
+%3C? extends Enum%3E
  _graphT
@@ -914,16 +914,25 @@
 Service(
+ @Nonnull
  final S
@@ -941,16 +941,25 @@
 ing key,
+ @Nonnull
  final C
@@ -962,16 +962,32 @@
 al Class
+%3C? extends Enum%3E
  graphTy
@@ -2165,16 +2165,32 @@
 ic Class
+%3C? extends Enum%3E
  getGrap

Fix generics warnings