package org.realityforge.replicant.client;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import javax.annotation.Nonnull;

/**
 * A simple container for representing listener in the broker.
 */
public final class ListenerEntry
{
  private final EntityChangeListener _listener;
  private boolean _globalListener;
  private final HashSet<Class> _interestedTypes = new HashSet<Class>();
  private final HashSet<Object> _interestedInstances = new HashSet<Object>();

  ListenerEntry( final EntityChangeListener listener )
  {
    _listener = listener;
  }

  boolean isEmpty()
  {
    return !isGlobalListener() && 0 == interestedTypeSet().size() && 0 == interestedInstanceSet().size();
  }

  public boolean isGlobalListener()
  {
    return _globalListener;
  }

  void setGlobalListener( final boolean globalListener )
  {
    _globalListener = globalListener;
  }

  @Nonnull
  public EntityChangeListener getListener()
  {
    return _listener;
  }

  @Nonnull
  public Set<Class> getInterestedTypeSet()
  {
    return Collections.unmodifiableSet( interestedTypeSet() );
  }

  @Nonnull
  HashSet<Class> interestedTypeSet()
  {
    return _interestedTypes;
  }

  @Nonnull
  public Set<Object> getInterestedInstanceSet()
  {
    return Collections.unmodifiableSet( _interestedInstances );
  }

  @Nonnull
  HashSet<Object> interestedInstanceSet()
  {
    return _interestedInstances;
  }
}

@@ -253,16 +253,39 @@
 erEntry%0A
+  implements Cloneable%0A
 %7B%0A  priv
@@ -1437,11 +1437,120 @@
 ces;%0A  %7D
+%0A%0A  @Override%0A  public Object clone()%0A    throws CloneNotSupportedException%0A  %7B%0A    return super.clone();%0A  %7D
 %0A%7D%0A

Make ListenerEntry cloneable