<commit_before>/**
 * Copyright (C) 2012 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */
package com.opengamma.web.server.push.analytics;

import java.util.HashMap;
import java.util.Map;

import com.opengamma.DataNotFoundException;
import com.opengamma.util.ArgumentChecker;

/**
 * Base class for grids that display analytics data calculated by the engine.
 * @param <V> The type of viewport created and used by this grid.
 */
/* package */ abstract class AnalyticsGrid<V extends AnalyticsViewport> {

  protected final Map<String, V> _viewports = new HashMap<String, V>();

  private final String _gridId;

  /**
   * @param gridId The ID that is passed to listeners when the grid structure changes. This can be any unique value,
   * the grid doesn't use it and makes no assumptions about its form.
   */
  protected AnalyticsGrid(String gridId) {
    ArgumentChecker.notNull(gridId, "gridId");
    _gridId = gridId;
  }

  /**
   * @return The row and column structure of the grid
   */
  public abstract GridStructure getGridStructure();

  /**
   * Returns a viewport that represents part of the grid that a user is viewing.
   * @param viewportId ID of the viewport
   * @return The viewort
   * @throws DataNotFoundException If no viewport exists with the specified ID
   */
  protected V getViewport(String viewportId) {
    V viewport = _viewports.get(viewportId);
    if (viewport == null) {
      throw new DataNotFoundException("No viewport found with ID " + viewportId);
    }
    return viewport;
  }<commit_msg>[PLAT-2271] Javadoc<commit_after>/**
 * Copyright (C) 2012 - present by OpenGamma Inc. and the OpenGamma group of companies
 *
 * Please see distribution for license.
 */
package com.opengamma.web.server.push.analytics;

import java.util.HashMap;
import java.util.Map;

import com.opengamma.DataNotFoundException;
import com.opengamma.util.ArgumentChecker;

/**
 * Base class for grids that display analytics data calculated by the engine.
 * @param <V> The type of viewport created and used by this grid.
 */
/* package */ abstract class AnalyticsGrid<V extends AnalyticsViewport> {

  /** Viewports keyed by ID. */
  protected final Map<String, V> _viewports = new HashMap<String, V>();

  /** ID that's passed to listeners when this grid's row and column structure changes. */
  private final String _gridId;

  /**
   * @param gridId The ID that is passed to listeners when the grid structure changes. This can be any unique value,
   * the grid doesn't use it and makes no assumptions about its form.
   */
  protected AnalyticsGrid(String gridId) {
    ArgumentChecker.notNull(gridId, "gridId");
    _gridId = gridId;
  }

  /**
   * @return The row and column structure of the grid
   */
  public abstract GridStructure getGridStructure();

  /**
   * Returns a viewport that represents part of the grid that a user is viewing.
   * @param viewportId ID of the viewport
   * @return The viewort
   * @throws DataNotFoundException If no viewport exists with the specified ID
   */
  protected V getViewport(String viewportId) {
    V viewport = _viewports.get(viewportId);
    if (viewport == null) {
      throw new DataNotFoundException("No viewport found with ID " + viewportId);
    }
    return viewport;
  }
{'fraction_non_alphanumeric': 0.08670694864048338, 'fraction_numerical': 0.0036253776435045317, 'mean_word_length': 3.598611111111111, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6990392', 'n_tokens_mistral': 952, 'n_tokens_neox': 922, 'n_words': 370}