code: public synchronized Packet build()
      {
          checkBuilt();
          isBuilt = true;
  
          try
          {
              dataOutputStream.close();
          }
          catch (final IOException e)
          {
              logger.error("Unable to build packet: {} : {}", e.getClass(), e.getMessage());
          }
  
          return new Packet(
                  packetType,
                  packetID,
                  byteArrayOutputStream.toByteArray()
          );
      }
docs: Builds Packet with given data
  @return Packet
  @throws IllegalStateException see {@link #checkBuilt()}