class IldcpResponsePacketHandler {

  public final void handle(final InterledgerResponsePacket responsePacket) {
    Objects.requireNonNull(responsePacket);

    if (IldcpResponsePacket.class.isAssignableFrom(responsePacket.getClass())) {
      handleIldcpResponsePacket((IldcpResponsePacket) responsePacket);
    } else if (InterledgerRejectPacket.class.isAssignableFrom(responsePacket.getClass())) {
      handleIldcpErrorPacket((InterledgerRejectPacket) responsePacket);
    } else {
      throw new RuntimeException(
          String.format("Unsupported IldcpResponsePacket Type: %s", responsePacket.getClass()));
    }
  }

}