2 * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.cluster.datastore.node.utils;
11 import com.google.common.cache.CacheBuilder;
12 import com.google.common.cache.CacheLoader;
13 import com.google.common.cache.LoadingCache;
14 import org.opendaylight.yangtools.yang.common.QName;
16 public class QNameFactory {
18 private static final int MAX_QNAME_CACHE_SIZE = 10000;
20 private static final LoadingCache<String, QName> CACHE = CacheBuilder.newBuilder()
21 .maximumSize(MAX_QNAME_CACHE_SIZE)
24 new CacheLoader<String, QName>() {
26 public QName load(String key) {
27 return QName.create(key);
33 public static QName create(String name) {
34 return CACHE.getUnchecked(name);