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
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic intCompare twoOptionals wrapping Revisions.static intCompare two explicitly nullable Revisions.booleaninthashCode()static @NonNull RevisionParse a revision string.ofNullable(@Nullable String str) Parse a (potentially null) revision string.static @NonNull Revisionrevision()Return theRevision, if present.toString()ReturnsRevisionUnion.unionString().Arevision-date-compliant date, or an empty string ("").Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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:RevisionUnionReturn theRevision, if present.- Specified by:
revisionin interfaceRevisionUnion- Returns:
- the revision, or
nullif not present
-
unionString
Description copied from interface:RevisionUnionArevision-date-compliant date, or an empty string ("").- Specified by:
unionStringin interfaceRevisionUnion- Returns:
- A revision-date or empty string
-
readFrom
- Throws:
IOException
-
compare
Compare twoOptionals 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:
hashCodein interfaceRevisionUnion- Overrides:
hashCodein classObject
-
equals
- Specified by:
equalsin interfaceRevisionUnion- Overrides:
equalsin classObject
-
toString
Description copied from interface:RevisionUnionReturnsRevisionUnion.unionString().- Specified by:
toStringin interfaceRevisionUnion- Overrides:
toStringin classObject- Returns:
RevisionUnion.unionString()
-