Adjust to yangtools-2.0.0/odlparent-3.0.0 changes
[netconf.git] / netconf / yanglib / src / main / java / org / opendaylight / yanglib / impl / YangLibProvider.java
index df88860c1f7e757ce548c2f0bb171b84a4c661e2..ba7e22a025bc26bcb5ef251821293bd85f9fdecd 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.yanglib.impl;
 
 import com.google.common.base.Preconditions;
@@ -33,6 +32,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.librar
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.YangIdentifier;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.yanglib.impl.rev141210.YanglibConfig;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
@@ -47,7 +47,6 @@ import org.osgi.framework.ServiceReference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-
 /**
  * Listens on new schema sources registered event. For each new source
  * registered generates URL representing its schema source and write this URL
@@ -186,14 +185,12 @@ public class YangLibProvider implements AutoCloseable, SchemaSourceListener {
     }
 
     private static String revString(final SourceIdentifier id) {
-        final String rev = id.getRevision();
-        return rev == null || SourceIdentifier.NOT_PRESENT_FORMATTED_REVISION.equals(rev) ? "" : rev;
+        return id.getRevision().map(Revision::toString).orElse("");
     }
 
     private static OptionalRevision getRevisionForModule(final SourceIdentifier sourceIdentifier) {
-        final String rev = sourceIdentifier.getRevision();
-        return rev == null || SourceIdentifier.NOT_PRESENT_FORMATTED_REVISION.equals(rev) ? NO_REVISION
-                : new OptionalRevision(new RevisionIdentifier(rev));
+        return sourceIdentifier.getRevision().map(rev -> new OptionalRevision(new RevisionIdentifier(rev.toString())))
+                .orElse(NO_REVISION);
     }
 
     private <T> T getObjectFromBundleContext(final Class<T> type, final String serviceRefName) {