Record Class SourceIdentifier

java.lang.Object
java.lang.Record
org.opendaylight.yangtools.yang.model.api.source.SourceIdentifier
All Implemented Interfaces:
Serializable, Identifier, Immutable

public record SourceIdentifier(@NonNull UnresolvedQName.Unqualified name, @Nullable Revision revision) extends Record implements Identifier
Base class of YANG Schema source identifiers. Source identifiers are designated to be carry only necessary information to look up YANG module (or submodule) source and to be used by various SchemaSourceProviders.

For further reference see: RFC6020 and RFC6022.

See Also:
  • Constructor Details

    • SourceIdentifier

      public SourceIdentifier(@NonNull UnresolvedQName.Unqualified name, @Nullable Revision revision)
      Creates new YANG Schema source identifier for sources with or without a revision.
      Parameters:
      name - Name of schema
      revision - Revision of schema
      Throws:
      NullPointerException - if name is null
    • SourceIdentifier

      public SourceIdentifier(@NonNull UnresolvedQName.Unqualified name)
      Creates new YANG Schema source identifier for sources without a revision.
      Parameters:
      name - Name of schema
      Throws:
      NullPointerException - if name is null
    • SourceIdentifier

      public SourceIdentifier(@NonNull String name)
      Creates new YANG Schema source identifier for sources without a revision.
      Parameters:
      name - Name of schema
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is not a valid YANG identifier
    • SourceIdentifier

      public SourceIdentifier(@NonNull String name, @Nullable Revision revision)
      Creates new YANG Schema source identifier for sources with or without a revision.
      Parameters:
      name - Name of schema
      revision - Optional schema revision
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is not a valid YANG identifier
    • SourceIdentifier

      public SourceIdentifier(@NonNull String name, @Nullable String revision)
      Creates new YANG Schema source identifier for sources with or without a revision.
      Parameters:
      name - Name of schema
      revision - Optional schema revision
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is not a valid YANG identifier
      DateTimeParseException - if revision format does not conform specification.
  • Method Details

    • toYangFilename

      public @NonNull String toYangFilename()
      Returns filename for this YANG module as specified in RFC 6020.

      Returns filename in format name ['@' revision] '.yang', where revision is date in format YYYY-mm-dd.

      Returns:
      Filename for this source identifier.
      See Also:
    • toString

      public String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in interface Identifier
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • toYangFileName

      public static @NonNull String toYangFileName(@NonNull String moduleName, @Nullable Revision revision)
      Returns filename for this YANG module as specified in RFC 6020.

      Returns filename in format moduleName ['@' revision] '.yang', where Where revision-date is in format YYYY-mm-dd.

      See http://www.rfc-editor.org/rfc/rfc6020#section-5.2

      Parameters:
      moduleName - module name
      revision - optional revision
      Returns:
      Filename for this source identifier.
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in interface Identifier
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in interface Identifier
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • name

      public @NonNull UnresolvedQName.Unqualified name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • revision

      public @Nullable Revision revision()
      Returns the value of the revision record component.
      Returns:
      the value of the revision record component