package org.realityforge.replicant.client.transport;

import javax.annotation.Nullable;

/**
 * An object representing a subscription.
 * The subscription is to a "graph" of objects and any changes to that graph will be replicated
 * to the client from the server via the subscription. The graph is represented by an enum.
 *
 * @param <T> The enum type representing the different graphs.
 */
public class SubscriptionEntry<T extends Enum>
{
  private final T _graph;
  @Nullable
  private final Object _id;
  @Nullable
  private Object _subscriptionData;

  /**
   * True if the initial load of data for entity has been downloaded and is local.
   */
  private boolean _present;
  /**
   * True if the subscription is being updated.
   */
  private boolean _subscriptionUpdateInProgress;
  /**
   * True if the subscription is part way through being cancelled.
   */
  private boolean _deregisterInProgress;
  /**
   * True if a deregister has not been completed.
   */
  private boolean _registered;

  public SubscriptionEntry( final T graph, final Object id )
  {
    _graph = graph;
    _id = id;
    _registered = true;
  }

  public void setSubscriptionData( @Nullable final Object subscriptionData )
  {
    _subscriptionData = subscriptionData;
  }

  @Nullable
  public Object getSubscriptionData()
  {
    return _subscriptionData;
  }

  public T getGraph()
  {
    return _graph;
  }

  @Nullable
  public Object getId()
  {
    return _id;
  }

  public boolean isPresent()
  {
    return _present;
  }

  public void markAsPresent()
  {
    _present = true;
  }

  public boolean isSubscriptionUpdateInProgress()
  {
    return _subscriptionUpdateInProgress;
  }

  public void setSubscriptionUpdateInProgress( final boolean subscriptionUpdateInProgress )
  {
    _subscriptionUpdateInProgress = subscriptionUpdateInProgress;
  }

  public boolean isDeregisterInProgress()
  {
    return _deregisterInProgress;
  }

  public void markDeregisterInProgress()
  {
    _deregisterInProgress = true;
  }

  public boolean isRegistered()
  {
    return _registered;
  }

  public void markAsDeregistered()
  {
    _registered = false;
  }
}

@@ -531,32 +531,31 @@
 Object _
-subscriptionData
+filterParameter
 ;%0A%0A  /**
@@ -1140,32 +1140,31 @@
 void set
-SubscriptionData
+FilterParameter
 ( @Nulla
@@ -1184,71 +1184,68 @@
 ect 
-subscriptionData )%0A  %7B%0A    _subscriptionData = subscriptionData
+filterParameter )%0A  %7B%0A    _filterParameter = filterParameter
 ;%0A  
@@ -1282,24 +1282,23 @@
  get
-SubscriptionData
+FilterParameter
 ()%0A 
@@ -1316,24 +1316,23 @@
 rn _
-subscriptionData
+filterParameter
 ;%0A  

Rename subscriptionData to filterParameter to match domgen conventions