Class Revision
java.lang.Object
org.opendaylight.yangtools.yang.common.Revision
- All Implemented Interfaces:
Serializable
,Comparable<Revision>
,Immutable
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.
- Author:
- Robert Varga
- See Also:
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
Compare twoOptional
s wrapping Revisions.static int
Compare two explicitly nullable Revisions.int
boolean
int
hashCode()
static @NonNull Revision
Parse a revision string.ofNullable
(@Nullable String str) Parse a (potentially null) revision string.toString()
-
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.
-
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. UnlikecompareTo(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.
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Revision>
-
hashCode
public int hashCode() -
equals
-
toString
-