code: public static void runExample(AdManagerServices adManagerServices, AdManagerSession session)
        throws RemoteException {
      // Get the InventoryService.
      InventoryServiceInterface inventoryService =
          adManagerServices.get(session, InventoryServiceInterface.class);
  
      // Get the NetworkService.
      NetworkServiceInterface networkService =
          adManagerServices.get(session, NetworkServiceInterface.class);
  
      // Set the parent ad unit's ID for all children ad units to be fetched from.
      String parentAdUnitId = networkService.getCurrentNetwork().getEffectiveRootAdUnitId();
  
      // Create a statement to select ad units under the parent ad unit.
      StatementBuilder statementBuilder =
          new StatementBuilder()
              .where("parentId = :parentId")
              .orderBy("id ASC")
              .limit(StatementBuilder.SUGGESTED_PAGE_LIMIT)
              .withBindVariableValue("parentId", parentAdUnitId);
  
      // Default for total result set size.
      int totalResultSetSize = 0;
  
      do {
        // Get ad units by statement.
        AdUnitPage page = inventoryService.getAdUnitsByStatement(statementBuilder.toStatement());
  
        if (page.getResults() != null) {
          totalResultSetSize = page.getTotalResultSetSize();
          int i = page.getStartIndex();
          for (AdUnit adUnit : page.getResults()) {
            System.out.printf(
                "%d) Ad unit with ID '%s' and name '%s' was found.%n",
                i++, adUnit.getId(), adUnit.getName());
          }
        }
  
        statementBuilder.increaseOffsetBy(StatementBuilder.SUGGESTED_PAGE_LIMIT);
      } while (statementBuilder.getOffset() < totalResultSetSize);
  
      System.out.printf("Number of results found: %d%n", totalResultSetSize);
    }
docs: Runs the example.
  
  @param adManagerServices the services factory.
  @param session the session.
  @throws ApiException if the API request failed with one or more service errors.
  @throws RemoteException if the API request failed due to other errors.