- Set<Module> modules = globalSchema.getModules();
-
- final Comparator<Module> comparator = new Comparator<Module>() {
- @Override
- public int compare(final Module o1, final Module o2) {
- return o1.getRevision().compareTo(o2.getRevision());
- }
- };
-
- List<Module> sorted = new ArrayList<Module>(modules);
- Collections.<Module> sort(new ArrayList<Module>(modules), comparator);
-
- final Function<Module, QName> transform = new Function<Module, QName>() {
- @Override
- public QName apply(final Module m) {
- return QName.create(m.getNamespace(), m.getRevision(), m.getName());
- }
- };
-
- final Predicate<QName> findFirst = new Predicate<QName>() {
- @Override
- public boolean apply(final QName qn) {
- return Objects.equal(module, qn.getLocalName());
- }
- };
-
- Optional<QName> namespace = FluentIterable.from(sorted).transform(transform).firstMatch(findFirst);
- return namespace.isPresent() ? QName.create(namespace.get(), node) : null;
+ final Module m = globalSchema.findModuleByName(module, null);
+ return m == null ? null : QName.create(m.getQNameModule(), node);