@Test public void testExtractMemcachedId() throws InterruptedException { final SessionIdFormat cut = new SessionIdFormat(); assertEquals( "n", cut.extractMemcachedId( "foo-n" ) ); assertEquals( "n", cut.extractMemcachedId( "foo-n.jvm1" ) ); assertEquals( "n", cut.extractMemcachedId( "foo-n.j-v-m1" ) ); assertEquals( null, cut.extractMemcachedId( "foo.j-v-m1" ) ); }
@CheckForNull public String extractMemcachedId( @Nonnull final String sessionId ) { final int idxDash = sessionId.indexOf( '-' ); if ( idxDash < 0 ) { return null; } final int idxDot = sessionId.indexOf( '.' ); if ( idxDot < 0 ) { return sessionId.substring( idxDash + 1 ); } else if ( idxDot < idxDash ) { return null; } else { return sessionId.substring( idxDash + 1, idxDot ); } }
SessionIdFormat { @CheckForNull public String extractMemcachedId( @Nonnull final String sessionId ) { final int idxDash = sessionId.indexOf( '-' ); if ( idxDash < 0 ) { return null; } final int idxDot = sessionId.indexOf( '.' ); if ( idxDot < 0 ) { return sessionId.substring( idxDash + 1 ); } else if ( idxDot < idxDash ) { return null; } else { return sessionId.substring( idxDash + 1, idxDot ); } } }
SessionIdFormat { @CheckForNull public String extractMemcachedId( @Nonnull final String sessionId ) { final int idxDash = sessionId.indexOf( '-' ); if ( idxDash < 0 ) { return null; } final int idxDot = sessionId.indexOf( '.' ); if ( idxDot < 0 ) { return sessionId.substring( idxDash + 1 ); } else if ( idxDot < idxDash ) { return null; } else { return sessionId.substring( idxDash + 1, idxDot ); } } SessionIdFormat();  SessionIdFormat(final StorageKeyFormat storageKeyFormat); }
SessionIdFormat { @CheckForNull public String extractMemcachedId( @Nonnull final String sessionId ) { final int idxDash = sessionId.indexOf( '-' ); if ( idxDash < 0 ) { return null; } final int idxDot = sessionId.indexOf( '.' ); if ( idxDot < 0 ) { return sessionId.substring( idxDash + 1 ); } else if ( idxDot < idxDash ) { return null; } else { return sessionId.substring( idxDash + 1, idxDot ); } } SessionIdFormat();  SessionIdFormat(final StorageKeyFormat storageKeyFormat); @Nonnull String createSessionId(@Nonnull final String sessionId, @Nullable final String memcachedId); @Nonnull String createNewSessionId( @Nonnull final String sessionId, @Nonnull final String newMemcachedId); @Nonnull String changeJvmRoute( @Nonnull final String sessionId, @Nonnull final String newJvmRoute ); boolean isValid( @Nullable final String sessionId ); @CheckForNull String extractMemcachedId( @Nonnull final String sessionId ); @CheckForNull String extractJvmRoute( @Nonnull final String sessionId ); @Nonnull String stripJvmRoute( @Nonnull final String sessionId ); @Nonnull String createLockName( @Nonnull final String sessionId ); @Nonnull String createValidityInfoKeyName( @Nonnull final String origKey ); @Nonnull String createBackupKey( @Nonnull final String origKey ); boolean isBackupKey( @Nonnull final String key ); }
SessionIdFormat { @CheckForNull public String extractMemcachedId( @Nonnull final String sessionId ) { final int idxDash = sessionId.indexOf( '-' ); if ( idxDash < 0 ) { return null; } final int idxDot = sessionId.indexOf( '.' ); if ( idxDot < 0 ) { return sessionId.substring( idxDash + 1 ); } else if ( idxDot < idxDash ) { return null; } else { return sessionId.substring( idxDash + 1, idxDot ); } } SessionIdFormat();  SessionIdFormat(final StorageKeyFormat storageKeyFormat); @Nonnull String createSessionId(@Nonnull final String sessionId, @Nullable final String memcachedId); @Nonnull String createNewSessionId( @Nonnull final String sessionId, @Nonnull final String newMemcachedId); @Nonnull String changeJvmRoute( @Nonnull final String sessionId, @Nonnull final String newJvmRoute ); boolean isValid( @Nullable final String sessionId ); @CheckForNull String extractMemcachedId( @Nonnull final String sessionId ); @CheckForNull String extractJvmRoute( @Nonnull final String sessionId ); @Nonnull String stripJvmRoute( @Nonnull final String sessionId ); @Nonnull String createLockName( @Nonnull final String sessionId ); @Nonnull String createValidityInfoKeyName( @Nonnull final String origKey ); @Nonnull String createBackupKey( @Nonnull final String origKey ); boolean isBackupKey( @Nonnull final String key );  }