package org.realityforge.replicant.client;

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

public class ChannelDescriptor
{
  @Nonnull
  private final Enum _graph;
  @Nullable
  private final Object _id;

  public ChannelDescriptor( @Nonnull final Enum graph, @Nullable final Object id )
  {
    _graph = Objects.requireNonNull( graph );
    _id = id;
  }

  @Nonnull
  public Class getSystem()
  {
    return _graph.getDeclaringClass();
  }

  @Nonnull
  public Enum getGraph()
  {
    return _graph;
  }

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

  @Override
  public String toString()
  {
    return _graph.toString() + ( null != _id ? ":" + _id : "" );
  }

  @Override
  public boolean equals( final Object o )
  {
    if ( this == o )
    {
      return true;
    }
    if ( o == null || getClass() != o.getClass() )
    {
      return false;
    }

    final ChannelDescriptor that = (ChannelDescriptor) o;
    return _graph.equals( that._graph ) && !( _id != null ? !_id.equals( that._id ) : that._id != null );
  }

  @Override
  public int hashCode()
  {
    int result = _graph.hashCode();
    result = 31 * result + ( _id != null ? _id.hashCode() : 0 );
    return result;
  }
}

@@ -988,22 +988,23 @@
 urn 
-_graph
+Objects
 .equals(
  tha
@@ -995,24 +995,32 @@
 ects.equals(
+ _graph,
  that._graph
@@ -1029,50 +1029,28 @@
  && 
-!( _id != null ? !_id.equals( that._id ) :
+Objects.equals( _id,
  tha
@@ -1055,24 +1055,16 @@
 hat._id 
-!= null 
 );%0A  %7D%0A%0A

Use Objects.equals to simplify equals code