public static Endpoint decodeInline(final RLPInput in, final int fieldCount) {
    checkGuard(
        fieldCount == 2 || fieldCount == 3,
        PeerDiscoveryPacketDecodingException::new,
        "Invalid number of components in RLP representation of an endpoint: expected 2 or 3 elements but got %s",
        fieldCount);

    String hostAddress = null;
    if (!in.nextIsNull()) {
      InetAddress addr = in.readInetAddress();
      hostAddress = addr.getHostAddress();
    } else {
      in.skipNext();
    }
    final int udpPort = in.readIntScalar();

    // Some mainnet packets have been shown to either not have the TCP port field at all,
    // or to have an RLP NULL value for it.
    Optional<Integer> tcpPort = Optional.empty();
    if (fieldCount == 3) {
      if (in.nextIsNull()) {
        in.skipNext();
      } else {
        tcpPort = Optional.of(in.readIntScalar());
      }
    }
    return new Endpoint(hostAddress, udpPort, tcpPort);
  }
Decodes the input stream as an Endpoint instance appearing inline within another object
(generally a Peer).

@param fieldCount The number of fields RLP list.
@param in The RLP input stream from which to read.
@return The decoded endpoint.
ethereum/p2p/src/main/java/org/hyperledger/besu/ethereum/p2p/discovery/Endpoint.java