package org.realityforge.replicant.client.transport;

import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/**
 * Summary describing the result of a data load action.
 */
public final class DataLoadStatus
{
  /**
   * A key that uniquely identifies the data source that initiated the data load.
   */
  @Nonnull
  private final String _systemKey;
  private final int _sequence;
  private final boolean _bulkLoad;
  @Nullable
  private final String _requestID;
  @Nonnull
  private final List<ChannelChangeStatus> _channelAdds;
  @Nonnull
  private final List<ChannelChangeStatus> _channelUpdates;
  @Nonnull
  private final List<ChannelChangeStatus> _channelRemoves;

  // The number of entities created or updated as part of change message
  private final int _entityUpdateCount;
  // The number of entities removed as part of change message
  private final int _entityRemoveCount;
  // The number of entities where link() was invoked
  private final int _entityLinkCount;

  public DataLoadStatus( @Nonnull final String systemKey,
                         final int sequence,
                         final boolean bulkLoad,
                         @Nullable final String requestID,
                         @Nonnull final List<ChannelChangeStatus> channelAdds,
                         @Nonnull final List<ChannelChangeStatus> channelUpdates,
                         @Nonnull final List<ChannelChangeStatus> channelRemoves,
                         final int entityUpdateCount,
                         final int entityRemoveCount,
                         final int entityLinkCount )
  {
    _systemKey = systemKey;
    _sequence = sequence;
    _bulkLoad = bulkLoad;
    _requestID = requestID;
    _channelAdds = channelAdds;
    _channelUpdates = channelUpdates;
    _channelRemoves = channelRemoves;
    _entityUpdateCount = entityUpdateCount;
    _entityRemoveCount = entityRemoveCount;
    _entityLinkCount = entityLinkCount;
  }

  @Nonnull
  public String getSystemKey()
  {
    return _systemKey;
  }

  public int getSequence()
  {
    return _sequence;
  }

  public boolean isBulkLoad()
  {
    return _bulkLoad;
  }

  @Nullable
  public String getRequestID()
  {
    return _requestID;
  }

  @Nonnull
  public List<ChannelChangeStatus> getChannelAdds()
  {
    return _channelAdds;
  }

  @Nonnull
  public List<ChannelChangeStatus> getChannelUpdates()
  {
    return _channelUpdates;
  }

  @Nonnull
  public List<ChannelChangeStatus> getChannelRemoves()
  {
    return _channelRemoves;
  }

  public int getEntityUpdateCount()
  {
    return _entityUpdateCount;
  }

  public int getEntityRemoveCount()
  {
    return _entityRemoveCount;
  }

  public int getEntityLinkCount()
  {
    return _entityLinkCount;
  }
}

@@ -2767,11 +2767,502 @@
 unt;%0A  %7D
+%0A%0A  @Override%0A  public String toString()%0A  %7B%0A    return %22%5B%22 +%0A           getSystemKey() + %22: ChangeSet %22 + getSequence() + %22 involved %22 +%0A           getChannelAdds().size() + %22 subscribes, %22 +%0A           getChannelUpdates().size() + %22 subscription updates, %22 +%0A           getChannelRemoves().size() + %22 un-subscribes, %22 +%0A           getEntityUpdateCount() + %22 updates, %22 +%0A           getEntityRemoveCount() + %22 removes and %22 +%0A           getEntityLinkCount() + %22 links%22 +%0A           %22%5D%22;%0A  %7D
 %0A%7D%0A

Add toString to DataLoadStatus to ease debugging