예제 #1
0
 @Override
 public int getBitsCount() {
   int additionalBits = 0;
   for (ResourceObject currentResource : resources) {
     additionalBits += currentResource.getBitsCount();
   }
   return super.getBitsCount() + leavingPeerInfo.getBitsCount() + additionalBits;
 }
예제 #2
0
  @Override
  protected byte[] asBytes(int bitsCount) {
    byte[] bytes = super.asBytes(bitsCount);

    int currentBitIndex = super.getBitsCount();

    ByteUtils.addByteArrayToArrayAtByteIndex(leavingPeerInfo.asBytes(), bytes, currentBitIndex / 8);
    currentBitIndex += leavingPeerInfo.getBitsCount();

    for (ResourceObject currentResource : resources) {
      ByteUtils.addByteArrayToArrayAtByteIndex(
          currentResource.asBytes(), bytes, currentBitIndex / 8);
      currentBitIndex += currentResource.getBitsCount();
    }

    return bytes;
  }