Cleanup use of Guava library
[yangtools.git] / common / object-cache-api / src / main / java / org / opendaylight / yangtools / objcache / ObjectCacheFactory.java
index a18f6edc17039b72c7ea0fab6943775a7b546179..fcd9ea6fc9c4a1f3f91be8264eb084addb6cd3d8 100644 (file)
@@ -7,11 +7,10 @@
  */
 package org.opendaylight.yangtools.objcache;
 
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
 
 import javax.annotation.Nonnull;
 import javax.annotation.concurrent.GuardedBy;
-
 import org.opendaylight.yangtools.objcache.impl.StaticObjectCacheBinder;
 import org.opendaylight.yangtools.objcache.spi.IObjectCacheFactory;
 import org.opendaylight.yangtools.objcache.spi.NoopObjectCacheBinder;
@@ -22,22 +21,26 @@ import org.opendaylight.yangtools.objcache.spi.NoopObjectCacheBinder;
 public final class ObjectCacheFactory {
     private static volatile IObjectCacheFactory factory;
 
+    private ObjectCacheFactory() {
+        throw new UnsupportedOperationException("Utility class should not be instantiated");
+    }
+
     @GuardedBy("this")
     private static synchronized IObjectCacheFactory initialize() {
         // Double-check under lock
-        IObjectCacheFactory f = factory;
-        if (f != null) {
-            return f;
+        IObjectCacheFactory fa = factory;
+        if (fa != null) {
+            return fa;
         }
 
         try {
-            f = StaticObjectCacheBinder.getInstance().getProductCacheFactory();
-            factory = f;
+            fa = StaticObjectCacheBinder.getInstance().getProductCacheFactory();
+            factory = fa;
         } catch (NoClassDefFoundError e) {
-            f = NoopObjectCacheBinder.INSTANCE.getProductCacheFactory();
+            fa = NoopObjectCacheBinder.INSTANCE.getProductCacheFactory();
         }
 
-        return f;
+        return fa;
     }
 
     public static synchronized void reset() {
@@ -52,11 +55,11 @@ public final class ObjectCacheFactory {
      * @return Object cache instance.
      */
     public static ObjectCache getObjectCache(@Nonnull final Class<?> objClass) {
-        IObjectCacheFactory f = factory;
-        if (f == null) {
-            f = initialize();
+        IObjectCacheFactory fa = factory;
+        if (fa == null) {
+            fa = initialize();
         }
 
-        return f.getObjectCache(Preconditions.checkNotNull(objClass));
+        return fa.getObjectCache(requireNonNull(objClass));
     }
 }