@Test public void lastIndexOfPendingAreaOfInterestRequest_passingNonnullFilterForDelete() { final Connection connection = createConnection(); final ChannelAddress address = new ChannelAddress( 1, 0 ); final String filter = "MyFilter"; final IllegalStateException exception = expectThrows( IllegalStateException.class, () -> connection.lastIndexOfPendingAreaOfInterestRequest( AreaOfInterestRequest.Type.REMOVE, address, filter ) ); assertEquals( exception.getMessage(), "Replicant-0024: Connection.lastIndexOfPendingAreaOfInterestRequest passed a REMOVE request for address '1.0' with a non-null filter 'MyFilter'." ); }
int lastIndexOfPendingAreaOfInterestRequest( @Nonnull final AreaOfInterestRequest.Type action, @Nonnull final ChannelAddress address, @Nullable final Object filter ) { if ( Replicant.shouldCheckInvariants() ) { invariant( () -> action != AreaOfInterestRequest.Type.REMOVE || null == filter, () -> "Replicant-0024: Connection.lastIndexOfPendingAreaOfInterestRequest passed a REMOVE " + "request for address '" + address + "' with a non-null filter '" + filter + "'." ); } int index = _pendingAreaOfInterestRequests.size(); final Iterator<AreaOfInterestRequest> iterator = _pendingAreaOfInterestRequests.descendingIterator(); while ( iterator.hasNext() ) { final AreaOfInterestRequest request = iterator.next(); if ( request.match( action, address, filter ) ) { return index; } index -= 1; } if ( _currentAreaOfInterestRequests.stream().anyMatch( a -> a.match( action, address, filter ) ) ) { return 0; } else { return -1; } }
Connection { int lastIndexOfPendingAreaOfInterestRequest( @Nonnull final AreaOfInterestRequest.Type action, @Nonnull final ChannelAddress address, @Nullable final Object filter ) { if ( Replicant.shouldCheckInvariants() ) { invariant( () -> action != AreaOfInterestRequest.Type.REMOVE || null == filter, () -> "Replicant-0024: Connection.lastIndexOfPendingAreaOfInterestRequest passed a REMOVE " + "request for address '" + address + "' with a non-null filter '" + filter + "'." ); } int index = _pendingAreaOfInterestRequests.size(); final Iterator<AreaOfInterestRequest> iterator = _pendingAreaOfInterestRequests.descendingIterator(); while ( iterator.hasNext() ) { final AreaOfInterestRequest request = iterator.next(); if ( request.match( action, address, filter ) ) { return index; } index -= 1; } if ( _currentAreaOfInterestRequests.stream().anyMatch( a -> a.match( action, address, filter ) ) ) { return 0; } else { return -1; } } }
Connection { int lastIndexOfPendingAreaOfInterestRequest( @Nonnull final AreaOfInterestRequest.Type action, @Nonnull final ChannelAddress address, @Nullable final Object filter ) { if ( Replicant.shouldCheckInvariants() ) { invariant( () -> action != AreaOfInterestRequest.Type.REMOVE || null == filter, () -> "Replicant-0024: Connection.lastIndexOfPendingAreaOfInterestRequest passed a REMOVE " + "request for address '" + address + "' with a non-null filter '" + filter + "'." ); } int index = _pendingAreaOfInterestRequests.size(); final Iterator<AreaOfInterestRequest> iterator = _pendingAreaOfInterestRequests.descendingIterator(); while ( iterator.hasNext() ) { final AreaOfInterestRequest request = iterator.next(); if ( request.match( action, address, filter ) ) { return index; } index -= 1; } if ( _currentAreaOfInterestRequests.stream().anyMatch( a -> a.match( action, address, filter ) ) ) { return 0; } else { return -1; } } Connection( @Nonnull final Connector connector ); }
Connection { int lastIndexOfPendingAreaOfInterestRequest( @Nonnull final AreaOfInterestRequest.Type action, @Nonnull final ChannelAddress address, @Nullable final Object filter ) { if ( Replicant.shouldCheckInvariants() ) { invariant( () -> action != AreaOfInterestRequest.Type.REMOVE || null == filter, () -> "Replicant-0024: Connection.lastIndexOfPendingAreaOfInterestRequest passed a REMOVE " + "request for address '" + address + "' with a non-null filter '" + filter + "'." ); } int index = _pendingAreaOfInterestRequests.size(); final Iterator<AreaOfInterestRequest> iterator = _pendingAreaOfInterestRequests.descendingIterator(); while ( iterator.hasNext() ) { final AreaOfInterestRequest request = iterator.next(); if ( request.match( action, address, filter ) ) { return index; } index -= 1; } if ( _currentAreaOfInterestRequests.stream().anyMatch( a -> a.match( action, address, filter ) ) ) { return 0; } else { return -1; } } Connection( @Nonnull final Connector connector );  }
Connection { int lastIndexOfPendingAreaOfInterestRequest( @Nonnull final AreaOfInterestRequest.Type action, @Nonnull final ChannelAddress address, @Nullable final Object filter ) { if ( Replicant.shouldCheckInvariants() ) { invariant( () -> action != AreaOfInterestRequest.Type.REMOVE || null == filter, () -> "Replicant-0024: Connection.lastIndexOfPendingAreaOfInterestRequest passed a REMOVE " + "request for address '" + address + "' with a non-null filter '" + filter + "'." ); } int index = _pendingAreaOfInterestRequests.size(); final Iterator<AreaOfInterestRequest> iterator = _pendingAreaOfInterestRequests.descendingIterator(); while ( iterator.hasNext() ) { final AreaOfInterestRequest request = iterator.next(); if ( request.match( action, address, filter ) ) { return index; } index -= 1; } if ( _currentAreaOfInterestRequests.stream().anyMatch( a -> a.match( action, address, filter ) ) ) { return 0; } else { return -1; } } Connection( @Nonnull final Connector connector );   }