Fix license header violations in sal-clustering-commons
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / datastore / node / utils / QNameFactory.java
1 /*
2  * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.cluster.datastore.node.utils;
10
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;
15
16 public class QNameFactory {
17
18     private static final int MAX_QNAME_CACHE_SIZE = 10000;
19
20     private static final LoadingCache<String, QName> CACHE = CacheBuilder.newBuilder()
21         .maximumSize(MAX_QNAME_CACHE_SIZE)
22         .softValues()
23         .build(
24             new CacheLoader<String, QName>() {
25                 @Override
26                 public QName load(String key) {
27                     return QName.create(key);
28                 }
29             }
30         );
31
32
33     public static QName create(String name){
34         return CACHE.getUnchecked(name);
35     }
36 }