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.transform;
10 import static java.util.Objects.requireNonNull;
13 import java.util.function.Function;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.common.QNameModule;
17 class QNameModuleReplacementFunction implements Function<QName, QName> {
18 private final Map<QNameModule, QNameModule> mapping;
20 QNameModuleReplacementFunction(final Map<QNameModule, QNameModule> mapping) {
21 this.mapping = requireNonNull(mapping);
25 public QName apply(final QName input) {
26 QNameModule potential = mapping.get(input.getModule());
27 if (potential != null) {
28 return QName.create(potential, input.getLocalName()).intern();