package org.realityforge.replicant.client;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nullable;

/**
 * Representation of a subscription to a graph.
 */
public class GraphSubscriptionEntry
{
  private final GraphDescriptor _descriptor;

  @Nullable
  private final Map<Class<?>, Map<Object, EntitySubscriptionEntry>> _entities =
    new HashMap<Class<?>, Map<Object, EntitySubscriptionEntry>>();
  private final Map<Class<?>, Map<Object, EntitySubscriptionEntry>> _roEntities =
    Collections.unmodifiableMap( _entities );

  public GraphSubscriptionEntry( final GraphDescriptor descriptor )
  {
    _descriptor = descriptor;
  }

  public GraphDescriptor getDescriptor()
  {
    return _descriptor;
  }

  public Map<Class<?>, Map<Object, EntitySubscriptionEntry>> getEntities()
  {
    return _roEntities;
  }

  final Map<Class<?>, Map<Object, EntitySubscriptionEntry>> getRwEntities()
  {
    return _entities;
  }
}

package org.realityforge.replicant.client;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/**
 * Representation of a subscription to a graph.
 */
public final class GraphSubscriptionEntry
{
  private final GraphDescriptor _descriptor;
  @Nullable
  private Object _filter;

  private final Map<Class<?>, Map<Object, EntitySubscriptionEntry>> _entities =
    new HashMap<Class<?>, Map<Object, EntitySubscriptionEntry>>();
  private final Map<Class<?>, Map<Object, EntitySubscriptionEntry>> _roEntities =
    Collections.unmodifiableMap( _entities );

  public GraphSubscriptionEntry( @Nonnull final GraphDescriptor descriptor,
                                 @Nullable final Object filter )
  {
    _descriptor = descriptor;
    _filter = filter;
  }

  public GraphSubscriptionEntry( final GraphDescriptor descriptor )
  {
    this( descriptor, null );
  }

  public GraphDescriptor getDescriptor()
  {
    return _descriptor;
  }

  void setFilter( final Object filter )
  {
    _filter = filter;
  }

  public Object getFilter()
  {
    return _filter;
  }

  public Map<Class<?>, Map<Object, EntitySubscriptionEntry>> getEntities()
  {
    return _roEntities;
  }

  final Map<Class<?>, Map<Object, EntitySubscriptionEntry>> getRwEntities()
  {
    return _entities;
  }
}

Make sure subscription entry can hold the filter value
Make sure subscription entry can hold the filter value
