eff7662440ded76304de46d942d53db63069a086
[netconf.git] / restconf / restconf-nb-rfc8040 / src / main / java / org / opendaylight / restconf / nb / rfc8040 / services / simple / impl / FakeModuleImport.java
1 /*
2  * Copyright (c) 2016 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 package org.opendaylight.restconf.nb.rfc8040.services.simple.impl;
9
10 import com.google.common.base.Preconditions;
11 import java.util.Optional;
12 import org.opendaylight.yangtools.concepts.SemVer;
13 import org.opendaylight.yangtools.yang.common.Revision;
14 import org.opendaylight.yangtools.yang.model.api.Module;
15 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
16
17 /**
18  * Fake {@link ModuleImport} implementation used to attach corrent prefix mapping to fake RPCs.
19  *
20  * @author Robert Varga
21  */
22 final class FakeModuleImport implements ModuleImport {
23     private final Module module;
24
25     FakeModuleImport(final Module module) {
26         this.module = Preconditions.checkNotNull(module);
27     }
28
29     @Override
30     public String getModuleName() {
31         return module.getName();
32     }
33
34     @Override
35     public Optional<Revision> getRevision() {
36         return module.getRevision();
37     }
38
39     @Override
40     public String getPrefix() {
41         return module.getName();
42     }
43
44     @Override
45     public Optional<String> getDescription() {
46         return module.getDescription();
47     }
48
49     @Override
50     public Optional<String> getReference() {
51         return module.getReference();
52     }
53
54     @Override
55     public Optional<SemVer> getSemanticVersion() {
56         return module.getSemanticVersion();
57     }
58 }