2 * Copyright (c) 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
8 package org.opendaylight.yangtools.yang.binding.util;
10 import com.google.common.base.Preconditions;
11 import java.lang.reflect.Method;
12 import java.util.HashMap;
14 import java.util.Map.Entry;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.common.QNameModule;
18 final class LocalNameRpcServiceInvoker extends AbstractMappedRpcInvoker<String> {
19 private final QNameModule module;
21 private LocalNameRpcServiceInvoker(final QNameModule module, final Map<String, Method> map) {
23 this.module = Preconditions.checkNotNull(module);
26 static RpcServiceInvoker instanceFor(final QNameModule module, final Map<QName, Method> qnameToMethod) {
27 final Map<String, Method> map = new HashMap<>();
28 for (Entry<QName, Method> e : qnameToMethod.entrySet()) {
29 map.put(e.getKey().getLocalName(), e.getValue());
32 return new LocalNameRpcServiceInvoker(module, map);
36 protected String qnameToKey(final QName qname) {
37 if (module.equals(qname.getModule())) {
38 return qname.getLocalName();