Fix javadoc to comply with JDK14
[yangtools.git] / yang / yang-common / src / main / java / org / opendaylight / yangtools / yang / common / Revision.java
index 32c6f50e5da64ae6308be6fd8b3dd212a736cf0b..a7e0d209054780f7de0e757214b9736c8be90f05 100644 (file)
@@ -18,15 +18,15 @@ import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeParseException;
 import java.util.Optional;
 import java.util.regex.Pattern;
-import javax.annotation.RegEx;
+import org.checkerframework.checker.regex.qual.Regex;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.yangtools.concepts.Immutable;
 
 /**
  * Dedicated object identifying a YANG module revision.
  *
- * <p>
- * <h3>API design note</h3>
+ * <h2>API design note</h2>
  * This class defines the contents of a revision statement, but modules do not require to have a revision (e.g. they
  * have not started to keep track of revisions).
  *
@@ -38,11 +38,13 @@ import org.eclipse.jdt.annotation.Nullable;
  *
  * @author Robert Varga
  */
-public final class Revision implements Comparable<Revision>, Serializable {
+public final class Revision implements Comparable<Revision>, Immutable, Serializable {
     // Note: since we are using writeReplace() this version is not significant.
     private static final long serialVersionUID = 1L;
 
-    @RegEx
+    private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+
+    @Regex
     // FIXME: we should improve this to filter incorrect dates -- see constructor.
     private static final String STRING_FORMAT_PATTERN_STR = "\\d\\d\\d\\d\\-\\d\\d-\\d\\d";
 
@@ -51,7 +53,10 @@ public final class Revision implements Comparable<Revision>, Serializable {
      */
     public static final Pattern STRING_FORMAT_PATTERN = Pattern.compile(STRING_FORMAT_PATTERN_STR);
 
-    private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
+    /**
+     * Revision which compares as greater than any other valid revision.
+     */
+    public static final Revision MAX_VALUE = Revision.of("9999-12-31");
 
     private final @NonNull String str;
 
@@ -89,7 +94,7 @@ public final class Revision implements Comparable<Revision>, Serializable {
      * @return An optional Revision instance.
      * @throws DateTimeParseException if the string format does not conform specification.
      */
-    public static Optional<Revision> ofNullable(final @Nullable String str) {
+    public static @NonNull Optional<Revision> ofNullable(final @Nullable String str) {
         return str == null ? Optional.empty() : Optional.of(new Revision(str));
     }