private void checkConsistentReadAndIncrementPosition ( Class < ? > clazz , FakeEncodedItem item ) { int endPosition = dataPosition + item . sizeBytes ; for ( int i = dataPosition ; i < endPosition ; i ++ ) { FakeEncodedItem foundItemItem = i < dataSize ? data [ i ] : null ; if ( foundItemItem != item ) { throw new UnreliableBehaviorError ( clazz , dataPosition , item , String . format ( Locale . US , "but [%s] interrupts it at position %d" , foundItemItem == null ? "uninitialized data or the end of the buffer" : foundItemItem . value , i ) ) ; } } dataPosition = Math . min ( dataSize , dataPosition + item . sizeBytes ) ; }
Ensures that the next sizeBytes are all the initial value we read .