code: public static void runExample(
        AdManagerServices adManagerServices, AdManagerSession session, long lineItemId)
        throws RemoteException {
      // Get the ForecastService.
      ForecastServiceInterface forecastService =
          adManagerServices.get(session, ForecastServiceInterface.class);
  
      // Get forecast for line item.
      AvailabilityForecastOptions options = new AvailabilityForecastOptions();
      options.setIncludeContendingLineItems(true);
      options.setIncludeTargetingCriteriaBreakdown(true);
      AvailabilityForecast forecast =
          forecastService.getAvailabilityForecastById(lineItemId, options);
  
      long matched = forecast.getMatchedUnits();
      double availablePercent = (forecast.getAvailableUnits() / (matched * 1.0)) * 100;
      String unitType = forecast.getUnitType().toString().toLowerCase();
  
      System.out.printf("%d %s matched.%n", matched, unitType);
      System.out.printf("%.2f%% %s available.%n", availablePercent, unitType);
  
      if (forecast.getPossibleUnits() != null) {
        double possiblePercent = (forecast.getPossibleUnits() / (matched * 1.0)) * 100;
        System.out.printf("%.2f%% %s possible.%n", possiblePercent, unitType);
      }
  
      System.out.printf(
          "%d contending line items.%n",
          forecast.getContendingLineItems() == null ? 0 : forecast.getContendingLineItems().length);
    }
docs: Runs the example.
  
  @param adManagerServices the services factory.
  @param session the session.
  @param lineItemId the ID of the line item to get a forecast for.
  @throws ApiException if the API request failed with one or more service errors.
  @throws RemoteException if the API request failed due to other errors.