// Path: src/main/java/com/google/api/ads/dfp/appengine/DfpTags.java
// public final class DfpTags {
// 
//   public static final String AD_UNITS = "ad-units";
//   public static final String COMPANIES = "companies";
//   public static final String CREATIVES = "creatives";
//   public static final String CREATIVE_TEMPLATES = "creativetemplates";
//   public static final String CUSTOM_TARGETING = "custom-targeting";
//   public static final String CUSTOM_TARGETING_KEYS = "custom-targeting-key";
//   public static final String CUSTOM_TARGETING_VALUES = "custom-targeting-values";
//   public static final String LINE_ITEM_CREATIVE_ASSOCIATIONS = "licas";
//   public static final String LINE_ITEMS = "line-items";
//   public static final String NETWORKS = "networks";
//   public static final String ORDERS = "orders";
//   public static final String ORDERS_LINE_ITEMS = "orders-line-items";
//   public static final String PLACEMENTS = "placements";
//   public static final String PUBLISHER_QUERY_LANGUAGE = "pql";
//   public static final String ROLES = "roles";
//   public static final String USERS = "users";
// }
// 
// Path: src/main/java/com/google/api/ads/dfp/appengine/DfpTypeOverrides.java
// public final class DfpTypeOverrides {
// 
//   public static final String KEYS = "key";
//   public static final String LINE_ITEMS = "lineitem";
//   public static final String ORDERS = "order";
//   public static final String VALUES = "value";
// }


import com.google.api.ads.dfp.appengine.DfpTags;
import com.google.api.ads.dfp.appengine.DfpTypeOverrides;
import com.google.common.base.Preconditions;
import com.google.inject.Inject;
import java.util.Map;
// Copyright 2012 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.api.ads.dfp.appengine.fetcher;



/**
 * Factory for creating different types of API object fetchers.
 *
 * @author Jeff Sham
 */
public class FetcherFactory {

  private final Map<String, Fetcher> fetchers;

  @Inject
  public FetcherFactory(Map<String, Fetcher> fetchers) {
    this.fetchers = fetchers;
  }

  /**
   * Returns a fetcher for an API object.
   *
   * @param tag the panel to return results to
   * @param typeOverride determines the type of object to return for panels with multiple types
   * @return an API object fetcher
   * @throws IllegalArgumentException if a fetcher cannot be found
   */
  public Fetcher getInstance(String tag, String typeOverride) {
    Preconditions.checkNotNull(tag);
    Preconditions.checkNotNull(typeOverride);

    if (tag.equals(DfpTags.ORDERS)) {
      if (typeOverride.equals(DfpTypeOverrides.ORDERS)) {
        return fetchers.get(DfpTags.ORDERS);
      } else if (typeOverride.equals(DfpTypeOverrides.LINE_ITEMS)) {
// Path: src/main/java/com/google/api/ads/dfp/appengine/DfpTags.java
// public final class DfpTags {
// 
//   public static final String AD_UNITS = "ad-units";
//   public static final String COMPANIES = "companies";
//   public static final String CREATIVES = "creatives";
//   public static final String CREATIVE_TEMPLATES = "creativetemplates";
//   public static final String CUSTOM_TARGETING = "custom-targeting";
//   public static final String CUSTOM_TARGETING_KEYS = "custom-targeting-key";
//   public static final String CUSTOM_TARGETING_VALUES = "custom-targeting-values";
//   public static final String LINE_ITEM_CREATIVE_ASSOCIATIONS = "licas";
//   public static final String LINE_ITEMS = "line-items";
//   public static final String NETWORKS = "networks";
//   public static final String ORDERS = "orders";
//   public static final String ORDERS_LINE_ITEMS = "orders-line-items";
//   public static final String PLACEMENTS = "placements";
//   public static final String PUBLISHER_QUERY_LANGUAGE = "pql";
//   public static final String ROLES = "roles";
//   public static final String USERS = "users";
// }
// 
// Path: src/main/java/com/google/api/ads/dfp/appengine/DfpTypeOverrides.java
// public final class DfpTypeOverrides {
// 
//   public static final String KEYS = "key";
//   public static final String LINE_ITEMS = "lineitem";
//   public static final String ORDERS = "order";
//   public static final String VALUES = "value";
// }


// Path: src/main/java/com/google/api/ads/dfp/appengine/fetcher/FetcherFactory.java
import com.google.api.ads.dfp.appengine.DfpTags;
import com.google.api.ads.dfp.appengine.DfpTypeOverrides;
import com.google.common.base.Preconditions;
import com.google.inject.Inject;
import java.util.Map;

// Copyright 2012 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.api.ads.dfp.appengine.fetcher;



/**
 * Factory for creating different types of API object fetchers.
 *
 * @author Jeff Sham
 */
public class FetcherFactory {

  private final Map<String, Fetcher> fetchers;

  @Inject
  public FetcherFactory(Map<String, Fetcher> fetchers) {
    this.fetchers = fetchers;
  }

  /**
   * Returns a fetcher for an API object.
   *
   * @param tag the panel to return results to
   * @param typeOverride determines the type of object to return for panels with multiple types
   * @return an API object fetcher
   * @throws IllegalArgumentException if a fetcher cannot be found
   */
  public Fetcher getInstance(String tag, String typeOverride) {
    Preconditions.checkNotNull(tag);
    Preconditions.checkNotNull(typeOverride);

    if (tag.equals(DfpTags.ORDERS)) {
      if (typeOverride.equals(DfpTypeOverrides.ORDERS)) {
        return fetchers.get(DfpTags.ORDERS);
      } else if (typeOverride.equals(DfpTypeOverrides.LINE_ITEMS)) {
        return fetchers.get(DfpTags.LINE_ITEMS);