-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt the code to use new classes, statements, utilities and features of yangtools 6.0.7. Signed-off-by: Ivan Hrasko <[email protected]>
- Loading branch information
Showing
22 changed files
with
115 additions
and
288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,14 +11,12 @@ | |
|
||
package com.mrv.yangtools.codegen.impl; | ||
|
||
import org.opendaylight.yangtools.yang.common.QName; | ||
import java.util.Optional; | ||
import org.opendaylight.yangtools.yang.common.QNameModule; | ||
import org.opendaylight.yangtools.yang.model.api.Module; | ||
import org.opendaylight.yangtools.yang.model.api.SchemaContext; | ||
import org.opendaylight.yangtools.yang.model.api.SchemaNode; | ||
|
||
import java.net.URI; | ||
import java.util.Set; | ||
|
||
/** | ||
* | ||
* @author [email protected] | ||
|
@@ -29,19 +27,13 @@ public class ModuleUtils { | |
public ModuleUtils(SchemaContext ctx) { | ||
this.ctx = ctx; | ||
} | ||
public String toModuleName(QName qname) { | ||
Set<Module> modules = ctx.findModuleByNamespace(qname.getModule().getNamespace()); | ||
if(modules.size() != 1) throw new IllegalStateException("no support for " + modules.size() + " modules with name " + qname); | ||
return modules.iterator().next().getName(); | ||
} | ||
|
||
public String toModuleName(URI uri) { | ||
Set<Module> modules = ctx.findModuleByNamespace(uri); | ||
if(modules.size() != 1) throw new IllegalStateException("no support for " + modules.size() + " modules with uri " + uri); | ||
return modules.iterator().next().getName(); | ||
public String toModuleName(QNameModule qname) { | ||
Optional<Module> modules = ctx.findModule(qname); | ||
if(modules.isEmpty()) throw new IllegalStateException("no support for " + qname + " modules with name " + qname); | ||
return modules.get().getName(); | ||
} | ||
|
||
public String toModuleName(SchemaNode node) { | ||
return toModuleName(node.getQName()); | ||
return toModuleName(node.getPath().getLastComponent().getModule()); | ||
} | ||
} |
Oops, something went wrong.