package org.opendaylight.yangtools.yang.model.repo.api;
import com.google.common.annotations.Beta;
-import com.google.common.base.Optional;
import java.util.Objects;
+import java.util.Optional;
import org.opendaylight.yangtools.concepts.SemVer;
-import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.common.Revision;
/**
- * YANG Schema source identifier with specified semantic version
+ * YANG Schema source identifier with specified semantic version.
*
+ * <p>
* Simple transfer object represents identifier of source for YANG schema
* (module or submodule), which consists of
* <ul>
* <li>(Optional) Module revision ({link {@link #getRevision()}
* </ul>
*
+ * <p>
* Source identifier is designated to be carry only necessary information to
* look-up YANG model source and to be used by various SchemaSourceProviders.
*
+ * <p>
* <b>Note:</b>On source retrieval layer it is impossible to distinguish between
* YANG module and/or submodule unless source is present.
*
*
* @param name
* Name of schema
- * @param formattedRevision
- * Optional of source revision in format YYYY-mm-dd. If not
- * present, default value will be used.
+ * @param revision
+ * Revision of source, possibly not present
* @param semVer
* semantic version of source
*/
- SemVerSourceIdentifier(final String name, final Optional<String> formattedRevision, final SemVer semVer) {
- this(name, formattedRevision.or(NOT_PRESENT_FORMATTED_REVISION), semVer);
+ SemVerSourceIdentifier(final String name, final Optional<Revision> revision, final SemVer semVer) {
+ super(name, revision);
+ this.semVer = semVer;
}
/**
* semantic version of source
*/
SemVerSourceIdentifier(final String name, final SemVer semVer) {
- this(name, Optional.absent(), semVer);
+ this(name, Optional.empty(), semVer);
}
/**
- * Creates new YANG Schema semVer source identifier.
+ * Returns semantic version of source if it was specified.
*
- * @param name
- * Name of schema
- * @param formattedRevision
- * Revision of source in format YYYY-mm-dd
- * @param semVer
- * semantic version of source
+ * @return revision of source.
*/
- SemVerSourceIdentifier(final String name, final String formattedRevision, final SemVer semVer) {
- super(name, formattedRevision);
- this.semVer = semVer == null ? Module.DEFAULT_SEMANTIC_VERSION : semVer;
- }
-
- /**
- * Returns semantic version of source or
- * {@link Module#DEFAULT_SEMANTIC_VERSION} if semantic version was not
- * supplied.
- *
- * @return revision of source or {@link Module#DEFAULT_SEMANTIC_VERSION} if
- * revision was not supplied.
- */
- public SemVer getSemanticVersion() {
- return semVer;
+ public Optional<SemVer> getSemanticVersion() {
+ return Optional.ofNullable(semVer);
}
/**
* @param semVer
* semantic version of source
*/
- public static SemVerSourceIdentifier create(final String moduleName, final String revision,
+ public static SemVerSourceIdentifier create(final String moduleName, final Revision revision,
final SemVer semVer) {
- return new SemVerSourceIdentifier(moduleName, revision, semVer);
+ return new SemVerSourceIdentifier(moduleName, Optional.ofNullable(revision), semVer);
}
/**
* @param semVer
* semantic version of source
*/
- public static SemVerSourceIdentifier create(final String moduleName,
- final Optional<String> revision, final SemVer semVer) {
+ public static SemVerSourceIdentifier create(final String moduleName, final Optional<Revision> revision,
+ final SemVer semVer) {
return new SemVerSourceIdentifier(moduleName, revision, semVer);
}