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).
*
*
* @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";
*/
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;
* @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));
}