package org.realityforge.replicant.server.transport;

import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import javax.annotation.Nonnull;
import org.realityforge.replicant.server.ChangeSet;
import org.realityforge.replicant.server.ChannelAddress;

final class ChannelCacheEntry
{
  private final ReadWriteLock _lock = new ReentrantReadWriteLock();
  private final ChannelAddress _descriptor;
  private String _cacheKey;
  private ChangeSet _changeSet;

  ChannelCacheEntry( @Nonnull final ChannelAddress address )
  {
    _descriptor = address;
  }

  @Nonnull
  ReadWriteLock getLock()
  {
    return _lock;
  }

  @Nonnull
  ChannelAddress getDescriptor()
  {
    return _descriptor;
  }

  void init( @Nonnull final String cacheKey, @Nonnull final ChangeSet changeSet )
  {
    _cacheKey = cacheKey;
    _changeSet = changeSet;
  }

  boolean isInitialized()
  {
    return null != _cacheKey;
  }

  @Nonnull
  String getCacheKey()
  {
    if ( null == _cacheKey )
    {
      throw new NullPointerException( "cacheKey" );
    }
    return _cacheKey;
  }

  @Nonnull
  ChangeSet getChangeSet()
  {
    if ( null == _changeSet )
    {
      throw new NullPointerException( "changeSet" );
    }
    return _changeSet;
  }
}

@@ -47,16 +47,42 @@
 sport;%0A%0A
+import java.util.Objects;%0A
 import j
@@ -1022,86 +1022,48 @@
     
-if ( null == _cacheKey )%0A    %7B%0A      throw new NullPointerException( %22
+return Objects.requireNonNull( _
 cacheKey
 %22 );
@@ -1062,41 +1062,12 @@
 eKey
-%22
  );%0A
-    %7D%0A    return _cacheKey;%0A
   %7D%0A
@@ -1117,79 +1117,40 @@
     
-if ( null == _changeSet )%0A    %7B%0A      throw new NullPointerException( %22
+return Objects.requireNonNull( _
 chan
@@ -1158,42 +1158,12 @@
 eSet
-%22
  );%0A
-    %7D%0A    return _changeSet;%0A
   %7D%0A

Simplify code