void (final ByteBuffer target, final int offset, final int capacity, final int length, final int redirectToId, final ByteBuffer payload) { if (capacity < MIN_CAPACITY || capacity > MAX_CAPACITY) { throw new IllegalArgumentException( "PaddingRecord capacity(" + capacity + ") must be in [" + MIN_CAPACITY + ".." + MAX_CAPACITY + "]"); } final int capacityOverFirstBucket = capacity - MIN_CAPACITY; if ((capacityOverFirstBucket % OFFSET_BUCKET) != 0) { throw new IllegalArgumentException("capacity-MIN (=" + capacityOverFirstBucket + ") must be rounded up to " + OFFSET_BUCKET); } final int packedCapacity = capacityOverFirstBucket >> OFFSET_BUCKET_BITS; final byte headerByte0 = (byte)(RECORD_TYPE_PADDING | (((packedCapacity >> CAPACITY_BITS_2) >> CAPACITY_BITS_1) & CAPACITY_MASK_0)); final byte headerByte1 = (byte)((packedCapacity >> CAPACITY_BITS_2) & CAPACITY_MASK_1); final byte headerByte2 = (byte)(packedCapacity & CAPACITY_MASK_2); target.put(offset, headerByte0); target.put(offset + 1, headerByte1); target.put(offset + 2, headerByte2); }