code: protected Interest replaceFinalComponent(Interest interest, long segmentNumber, byte marker) {
      Interest copied = new Interest(interest);
      Component lastComponent = Component.fromNumberWithMarker(segmentNumber, marker);
      Name newName = (SegmentationHelper.isSegmented(copied.getName(), marker))
          ? copied.getName().getPrefix(-1)
          : new Name(copied.getName());
      copied.setName(newName.append(lastComponent));
      return copied;
    }
docs: Replace the final component of an interest name with a segmented component;
  if the interest name does not have a segmented component, this will add
  one.
  
  @param interest the request
  @param segmentNumber a segment number
  @param marker a marker to use for segmenting the packet
  @return a segmented interest (a copy of the passed interest)