Class Revision
java.lang.Object
org.opendaylight.yangtools.yang.common.Revision
- All Implemented Interfaces:
Serializable
,Comparable<RevisionUnion>
,Immutable
,WritableObject
,RevisionUnion
Dedicated object identifying a YANG module revision.
API design note
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).
APIs which involve this class should always transfer instances via Optional<Revision>
, which is
the primary bridge data type. Implementations can use nullable fields with explicit conversions to/from
Optional
. Both patterns can take advantage of compare(Optional, Optional)
and
compare(Revision, Revision)
respectively.
- See Also:
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
Compare twoOptional
s wrapping Revisions.static int
Compare two explicitly nullable Revisions.boolean
int
hashCode()
static @NonNull Revision
Parse a revision string.ofNullable
(@Nullable String str) Parse a (potentially null) revision string.static @NonNull Revision
revision()
Return theRevision
, if present.toString()
Return the revision string according to RFC7950, section 7.1.9.Arevision-date
-compliant date, or an empty string (""
).Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.opendaylight.yangtools.yang.common.RevisionUnion
compareTo, findRevision, getRevision, writeTo
-
Field Details
-
STRING_FORMAT_PATTERN
String format pattern, which can be used to match parts of a string into components. -
MAX_VALUE
Revision which compares as greater than any other valid revision.
-
-
Method Details
-
of
Parse a revision string.- Parameters:
str
- String to be parsed- Returns:
- A Revision instance.
- Throws:
DateTimeParseException
- if the string format does not conform specification.NullPointerException
- if the string is null
-
ofNullable
Parse a (potentially null) revision string. Null strings result result inOptional.empty()
.- Parameters:
str
- String to be parsed- Returns:
- An optional Revision instance.
- Throws:
DateTimeParseException
- if the string format does not conform specification.
-
revision
Description copied from interface:RevisionUnion
Return theRevision
, if present.- Specified by:
revision
in interfaceRevisionUnion
- Returns:
- the revision, or
null
if not present
-
unionString
Description copied from interface:RevisionUnion
Arevision-date
-compliant date, or an empty string (""
).- Specified by:
unionString
in interfaceRevisionUnion
- Returns:
- A revision-date or empty string
-
readFrom
- Throws:
IOException
-
compare
Compare twoOptional
s wrapping Revisions. Arguments and return value are consistent withComparator.compare(Object, Object)
interface contract. Missing revisions compare as lower than any other revision.- Parameters:
first
- First optional revisionsecond
- Second optional revision- Returns:
- Positive, zero, or negative integer.
-
compare
Compare two explicitly nullable Revisions. UnlikeRevisionUnion.compareTo(Revision)
, this handles both arguments being null such that total ordering is defined.- Parameters:
first
- First revisionsecond
- Second revision- Returns:
- Positive, zero, or negative integer.
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceRevisionUnion
- Overrides:
hashCode
in classObject
-
equals
- Specified by:
equals
in interfaceRevisionUnion
- Overrides:
equals
in classObject
-
toString
Return the revision string according to RFC7950, section 7.1.9. The string is guaranteed to be composed on 10 ASCII characters inYYYY-MM-DD
format. The items are guaranteed to be decimal numbers. There are no further guarantees as to convertibility to an actual calendar date, as this method can validly return"2019-02-29"
(even if 2019 is not a leap year) or"2022-12-32"
(even if no month has 32 days).- Specified by:
toString
in interfaceRevisionUnion
- Overrides:
toString
in classObject
- Returns:
- A string in
YYYY-MM-DD
format
-