BUG-4688: update Revision design a bit more
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / repo / util / FilesystemSchemaSourceCache.java
index e774c1fa9c0be1ecb30e10956f71530e137c7936..92128618fb7e59ca636a89c6c2965d1582ce02bd 100644 (file)
@@ -24,6 +24,7 @@ import java.nio.file.Path;
 import java.nio.file.SimpleFileVisitor;
 import java.nio.file.StandardCopyOption;
 import java.nio.file.attribute.BasicFileAttributes;
+import java.time.format.DateTimeParseException;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
@@ -182,8 +183,8 @@ public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentat
                 String revStr = match.group();
                 Revision rev;
                 try {
-                    rev = Revision.valueOf(revStr);
-                } catch (final IllegalArgumentException e) {
+                    rev = Revision.of(revStr);
+                } catch (final DateTimeParseException e) {
                     LOG.info("Unable to parse date from yang file name {}, falling back to not-present", fileName, e);
                     rev = null;
                 }
@@ -289,8 +290,7 @@ public final class FilesystemSchemaSourceCache<T extends SchemaSourceRepresentat
             if (matcher.matches()) {
                 final String moduleName = matcher.group("moduleName");
                 final String revision = matcher.group("revision");
-                return Optional.of(RevisionSourceIdentifier.create(moduleName, revision == null ? Optional.empty()
-                        : Optional.of(Revision.valueOf(revision))));
+                return Optional.of(RevisionSourceIdentifier.create(moduleName, Revision.ofNullable(revision)));
             }
             return Optional.empty();
         }