All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.api.ads.common.lib.utils.AdsUtilityRegistry Maven / Gradle / Ivy

Go to download

Client library for Java for accessing ads APIs including DFP. If you want to use this library, you must also include another Maven artifact to specify which framework you would like to use it with. For example, to use DFP with Axis, you should include the "dfp-axis" artifact.

There is a newer version: 5.7.0
Show newest version
// Copyright 2016 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.common.lib.utils;

import com.google.common.base.Preconditions;
import com.google.common.collect.Sets;
import com.google.inject.Singleton;

import java.util.Collection;
import java.util.Set;

import javax.annotation.concurrent.ThreadSafe;

/**
 * A thread-safe registry for usage of {@link AdsUtility ads utilities}.
 */
@ThreadSafe
@Singleton
public class AdsUtilityRegistry {

  private final Set adsUtilities = Sets.newConcurrentHashSet();

  /**
   * Adds the specified utility to the registry.
   *
   * 

* Add is performed on a best efforts basis. It is possible that another thread will * subsequently remove the utility immediately after the add. * * @throws NullPointerException if {@code adsUtility == null} */ public void addUtility(AdsUtility adsUtility) { adsUtilities.add(Preconditions.checkNotNull(adsUtility, "Null ads utility")); } /** * Returns all utilities in the registry. */ public Set getRegisteredUtilities() { return Sets.newHashSet(adsUtilities); } /** * Removes the specified utilities from the registry. * *

* Removal is performed on a best efforts basis. It is possible that another thread will * subsequently add one or more of the utilities immediately after the remove. * * @throws NullPointerException if {@code utilities == null} */ public void removeUtilities(Collection utilities) { adsUtilities.removeAll(Preconditions.checkNotNull(utilities, "Null utilities collection")); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy