public boolean testAndSetRecvSequencenumber(int newValue){
  if (recvSequenceNumber == null) {
    recvSequenceNumber=new AtomicInteger(newValue);
    return true;
  }
  int oldValue=recvSequenceNumber.get();
  boolean wrapAround=(oldValue & 0x00000000ffffffff) >= 4294966271L;
  boolean exactMatch=oldValue + 1 == newValue;
  boolean wrapMatch=wrapAround & (newValue < 1024);
  boolean match=exactMatch | wrapMatch;
  if (match)   recvSequenceNumber.set(newValue);
  return match;
}

public boolean testAndSetRecvSequencenumber ( int newValue ) { if ( recvSequenceNumber == null ) { recvSequenceNumber = new AtomicInteger ( newValue ) ; return true ; } int oldValue = recvSequenceNumber . get ( ) ; boolean wrapAround = ( oldValue & 0x00000000ffffffff ) >= 4294966271L ; boolean exactMatch = oldValue + 1 == newValue ; boolean wrapMatch = wrapAround & ( newValue < 1024 ) ; boolean match = exactMatch | wrapMatch ; if ( match ) recvSequenceNumber . set ( newValue ) ; return match ; }
tests whether value matches expected sequence number and sets a new value . if value has never been set before the test passes and new value is set . test passes if the value is one larger than previous value or if previous value is 4294966271 or larger .
