本文整理汇总了Java中org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier类的典型用法代码示例。如果您正苦于以下问题:Java RevisionSourceIdentifier类的具体用法?Java RevisionSourceIdentifier怎么用?Java RevisionSourceIdentifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RevisionSourceIdentifier类属于org.opendaylight.yangtools.yang.model.repo.api包,在下文中一共展示了RevisionSourceIdentifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPreLinkageDeclared
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入依赖的package包/类
@Override
public final void onPreLinkageDeclared(final Mutable<String, ModuleStatement,
EffectiveStatement<String, ModuleStatement>> stmt) {
final String moduleName = stmt.getStatementArgument();
final URI moduleNs = firstAttributeOf(stmt.declaredSubstatements(), NamespaceStatement.class);
SourceException.throwIfNull(moduleNs, stmt.getStatementSourceReference(),
"Namespace of the module [%s] is missing", stmt.getStatementArgument());
stmt.addToNs(ModuleNameToNamespace.class, moduleName, moduleNs);
final String modulePrefix = firstAttributeOf(stmt.declaredSubstatements(), PrefixStatement.class);
SourceException.throwIfNull(modulePrefix, stmt.getStatementSourceReference(),
"Prefix of the module [%s] is missing", stmt.getStatementArgument());
stmt.addToNs(ImpPrefixToNamespace.class, modulePrefix, moduleNs);
stmt.addContext(PreLinkageModuleNamespace.class, moduleName, stmt);
final Optional<Revision> revisionDate = StmtContextUtils.getLatestRevision(stmt.declaredSubstatements());
final QNameModule qNameModule = QNameModule.create(moduleNs, revisionDate.orElse(null)).intern();
stmt.addToNs(ModuleCtxToModuleQName.class, stmt, qNameModule);
stmt.setRootIdentifier(RevisionSourceIdentifier.create(stmt.getStatementArgument(), revisionDate));
}
示例2: onLinkageDeclared
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入依赖的package包/类
@Override
public final void onLinkageDeclared(
final Mutable<String, SubmoduleStatement, EffectiveStatement<String, SubmoduleStatement>> stmt) {
final SourceIdentifier submoduleIdentifier = RevisionSourceIdentifier.create(stmt.getStatementArgument(),
StmtContextUtils.getLatestRevision(stmt.declaredSubstatements()));
final StmtContext<?, SubmoduleStatement, EffectiveStatement<String, SubmoduleStatement>>
possibleDuplicateSubmodule = stmt.getFromNamespace(SubmoduleNamespace.class, submoduleIdentifier);
if (possibleDuplicateSubmodule != null && possibleDuplicateSubmodule != stmt) {
throw new SourceException(stmt.getStatementSourceReference(), "Submodule name collision: %s. At %s",
stmt.getStatementArgument(), possibleDuplicateSubmodule.getStatementSourceReference());
}
stmt.addContext(SubmoduleNamespace.class, submoduleIdentifier, stmt);
final String belongsToModuleName = firstAttributeOf(stmt.declaredSubstatements(), BelongsToStatement.class);
final StmtContext<?, ?, ?> prefixSubStmtCtx = findFirstDeclaredSubstatement(stmt, 0,
BelongsToStatement.class, PrefixStatement.class);
SourceException.throwIfNull(prefixSubStmtCtx, stmt.getStatementSourceReference(),
"Prefix of belongsTo statement is missing in submodule [%s]", stmt.getStatementArgument());
final String prefix = (String) prefixSubStmtCtx.getStatementArgument();
stmt.addToNs(BelongsToPrefixToModuleName.class, prefix, belongsToModuleName);
}
示例3: testBug6961SchemaContext
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入依赖的package包/类
@Test
public void testBug6961SchemaContext() throws Exception {
final Optional<Revision> revision = Revision.ofNullable("2016-01-01");
final SourceIdentifier foo = RevisionSourceIdentifier.create("foo", revision);
final SourceIdentifier sub1Foo = RevisionSourceIdentifier.create("sub1-foo", revision);
final SourceIdentifier sub2Foo = RevisionSourceIdentifier.create("sub2-foo", revision);
final SourceIdentifier bar = RevisionSourceIdentifier.create("bar", revision);
final SourceIdentifier sub1Bar = RevisionSourceIdentifier.create("sub1-bar", revision);
final SourceIdentifier baz = RevisionSourceIdentifier.create("baz", revision);
final Set<SourceIdentifier> testSet = ImmutableSet.of(foo, sub1Foo, sub2Foo, bar, sub1Bar, baz);
final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6961/");
assertNotNull(context);
final Set<SourceIdentifier> allModuleIdentifiers = SchemaContextUtil.getConstituentModuleIdentifiers(context);
assertNotNull(allModuleIdentifiers);
assertEquals(6, allModuleIdentifiers.size());
final SchemaContext schemaContext = SimpleSchemaContext.forModules(context.getModules());
assertNotNull(schemaContext);
final Set<SourceIdentifier> allModuleIdentifiersResolved = SchemaContextUtil.getConstituentModuleIdentifiers(
schemaContext);
assertNotNull(allModuleIdentifiersResolved);
assertEquals(6, allModuleIdentifiersResolved.size());
assertEquals(allModuleIdentifiersResolved, allModuleIdentifiers);
assertEquals(allModuleIdentifiers, testSet);
assertTrue(allModuleIdentifiers.contains(foo));
}
示例4: schemaSourceTransformerGetSourceTest
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入依赖的package包/类
@Test
public void schemaSourceTransformerGetSourceTest() {
final Provider p = new Provider();
final Registrator reg = new Registrator(p, SchemaSourceTransformerTest.SRC_CLASS,
PotentialSchemaSource.Costs.IMMEDIATE);
final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("source");
reg.register(sourceIdentifier);
this.schema = new SchemaSourceTransformer<>(p,
SchemaSourceTransformerTest.SRC_CLASS, this.consumer, SchemaSourceTransformerTest.DST_CLASS,
this.function);
final SchemaSourceProvider<YinXmlSchemaSource> prov = this.schema;
final Future<? extends YinXmlSchemaSource> source = prov.getSource(sourceIdentifier);
Assert.assertNotNull(source);
source.cancel(true);
Assert.assertTrue(source.isDone());
}
示例5: inMemorySchemaSourceCacheOfferAndGetSourcestest
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入依赖的package包/类
@Test
public void inMemorySchemaSourceCacheOfferAndGetSourcestest() throws Exception {
final InMemorySchemaSourceCache<YangSchemaSourceRepresentation> inMemorySchemaSourceCache =
InMemorySchemaSourceCache.createSoftCache(this.registry, REPRESENTATION);
final String content = "content";
final YangTextSchemaSource source = new TestingYangSource("test", "2012-12-12", content);
inMemorySchemaSourceCache.offer(source);
final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("test", Revision.of("2012-12-12"));
final ListenableFuture<? extends YangSchemaSourceRepresentation> checkedSource = inMemorySchemaSourceCache
.getSource(sourceIdentifier);
Assert.assertNotNull(checkedSource);
final YangSchemaSourceRepresentation yangSchemaSourceRepresentation = checkedSource.get();
Assert.assertNotNull(yangSchemaSourceRepresentation);
Assert.assertEquals(sourceIdentifier, yangSchemaSourceRepresentation.getIdentifier());
inMemorySchemaSourceCache.close();
}
示例6: inMemorySchemaSourceCache3test
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入依赖的package包/类
@Test
public void inMemorySchemaSourceCache3test() throws Exception {
final InMemorySchemaSourceCache<YangSchemaSourceRepresentation> inMemorySchemaSourceCache =
InMemorySchemaSourceCache.createSoftCache(this.registry, REPRESENTATION);
final InMemorySchemaSourceCache<YangSchemaSourceRepresentation> inMemorySchemaSourceCache2 =
InMemorySchemaSourceCache.createSoftCache(this.registry, REPRESENTATION, LIFETIME, UNITS);
final String content = "content";
final YangTextSchemaSource source = new TestingYangSource("test", "2012-12-12", content);
inMemorySchemaSourceCache.offer(source);
inMemorySchemaSourceCache2.offer(source);
final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("test", Revision.of("2012-12-12"));
final ListenableFuture<? extends YangSchemaSourceRepresentation> checkedSource =
inMemorySchemaSourceCache.getSource(sourceIdentifier);
final ListenableFuture<? extends SchemaSourceRepresentation> checkedSource2 =
inMemorySchemaSourceCache2.getSource(sourceIdentifier);
Assert.assertNotNull(checkedSource);
Assert.assertNotNull(checkedSource2);
Assert.assertEquals(checkedSource.get(), checkedSource2.get());
inMemorySchemaSourceCache.close();
inMemorySchemaSourceCache2.close();
}
示例7: sourceIdToFileEmptyRevWithMoreItemsInDir
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入依赖的package包/类
@Test
public void sourceIdToFileEmptyRevWithMoreItemsInDir() {
final FilesystemSchemaSourceCache<YangTextSchemaSource> cache = new FilesystemSchemaSourceCache<>(this.registry,
YangTextSchemaSource.class, this.storageDir);
final String content = "content1";
final YangTextSchemaSource source = new TestingYangSource("test", "2012-12-12", content);
final YangTextSchemaSource source2 = new TestingYangSource("test", "2013-12-12", content);
cache.offer(source);
cache.offer(source2);
final SourceIdentifier sourceIdentifier = RevisionSourceIdentifier.create("test");
final File sourceIdToFile = FilesystemSchemaSourceCache.sourceIdToFile(sourceIdentifier, this.storageDir);
Assert.assertNotNull(sourceIdToFile);
final List<File> storedFiles = Arrays.asList(this.storageDir.listFiles());
assertEquals(2, storedFiles.size());
}
示例8: setUp
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
final YangTextSchemaSource source1 = YangTextSchemaSource.forResource("/ietf/[email protected]");
final YangTextSchemaSource source2 = YangTextSchemaSource.forResource("/ietf/[email protected]");
s1 = RevisionSourceIdentifier.create("ietf-inet-types", Revision.of("2010-09-24"));
s2 = RevisionSourceIdentifier.create("iana-timezones", Revision.of("2012-07-09"));
final TextToASTTransformer transformer = TextToASTTransformer.create(repository, repository);
repository.registerSchemaSourceListener(transformer);
repository.registerSchemaSource(sourceIdentifier -> Futures.immediateFuture(source1),
PotentialSchemaSource.create(s1, YangTextSchemaSource.class, 1));
repository.registerSchemaSource(sourceIdentifier -> Futures.immediateFuture(source2),
PotentialSchemaSource.create(s2, YangTextSchemaSource.class, 1));
}
示例9: testSourceRegisteredWithDifferentSI
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入依赖的package包/类
@Test
public void testSourceRegisteredWithDifferentSI() throws Exception {
final YangTextSchemaSource source1 = YangTextSchemaSource.forResource("/ietf/[email protected]");
final YangTextSchemaSource source2 = YangTextSchemaSource.forResource("/ietf/[email protected]");
s1 = source1.getIdentifier();
s2 = source2.getIdentifier();
final SettableSchemaProvider<ASTSchemaSource> provider =
SharedSchemaRepositoryTest.getImmediateYangSourceProviderFromResource(
"/no-revision/[email protected]");
provider.setResult();
provider.register(repository);
// Register the same provider under source id without revision
final SourceIdentifier sIdWithoutRevision = RevisionSourceIdentifier.create(provider.getId().getName());
repository.registerSchemaSource(provider, PotentialSchemaSource.create(
sIdWithoutRevision, ASTSchemaSource.class, PotentialSchemaSource.Costs.IMMEDIATE.getValue()));
final SharedSchemaContextFactory sharedSchemaContextFactory = new SharedSchemaContextFactory(repository,
filter);
final ListenableFuture<SchemaContext> schemaContext =
sharedSchemaContextFactory.createSchemaContext(Arrays.asList(sIdWithoutRevision, provider.getId()));
assertNotNull(schemaContext.get());
}
示例10: setUp
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入依赖的package包/类
@Before
public void setUp() {
String source = "Test source.";
schemaSource = YangTextSchemaSource.delegateForByteSource(
RevisionSourceIdentifier.create("test", Optional.of("2015-10-30")),
ByteSource.wrap(source.getBytes(StandardCharsets.UTF_8)));
}
示例11: onLinkageDeclared
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入依赖的package包/类
@Override
public final void onLinkageDeclared(final Mutable<String, ModuleStatement,
EffectiveStatement<String, ModuleStatement>> stmt) {
final Optional<URI> moduleNs = Optional.ofNullable(firstAttributeOf(stmt.declaredSubstatements(),
NamespaceStatement.class));
SourceException.throwIf(!moduleNs.isPresent(), stmt.getStatementSourceReference(),
"Namespace of the module [%s] is missing", stmt.getStatementArgument());
final Optional<Revision> revisionDate = StmtContextUtils.getLatestRevision(stmt.declaredSubstatements());
final QNameModule qNameModule = QNameModule.create(moduleNs.get(), revisionDate.orElse(null)).intern();
final StmtContext<?, ModuleStatement, EffectiveStatement<String, ModuleStatement>> possibleDuplicateModule =
stmt.getFromNamespace(NamespaceToModule.class, qNameModule);
if (possibleDuplicateModule != null && possibleDuplicateModule != stmt) {
throw new SourceException(stmt.getStatementSourceReference(), "Module namespace collision: %s. At %s",
qNameModule.getNamespace(), possibleDuplicateModule.getStatementSourceReference());
}
final SourceIdentifier moduleIdentifier = RevisionSourceIdentifier.create(stmt.getStatementArgument(),
revisionDate);
stmt.addContext(ModuleNamespace.class, moduleIdentifier, stmt);
stmt.addContext(ModuleNamespaceForBelongsTo.class, moduleIdentifier.getName(), stmt);
stmt.addContext(NamespaceToModule.class, qNameModule, stmt);
final String modulePrefix = firstAttributeOf(stmt.declaredSubstatements(), PrefixStatement.class);
SourceException.throwIfNull(modulePrefix, stmt.getStatementSourceReference(),
"Prefix of the module [%s] is missing", stmt.getStatementArgument());
stmt.addToNs(PrefixToModule.class, modulePrefix, qNameModule);
stmt.addToNs(ModuleNameToModuleQName.class, stmt.getStatementArgument(), qNameModule);
stmt.addToNs(ModuleCtxToModuleQName.class, stmt, qNameModule);
stmt.addToNs(ModuleCtxToSourceIdentifier.class, stmt, moduleIdentifier);
stmt.addToNs(ModuleQNameToModuleName.class, qNameModule, stmt.getStatementArgument());
stmt.addToNs(ImportPrefixToModuleCtx.class, modulePrefix, stmt);
if (stmt.isEnabledSemanticVersioning()) {
addToSemVerModuleNamespace(stmt, moduleIdentifier);
}
}
示例12: onPreLinkageDeclared
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入依赖的package包/类
@Override
public final void onPreLinkageDeclared(
final Mutable<String, IncludeStatement, EffectiveStatement<String, IncludeStatement>> stmt) {
final StmtContext<Revision, ?, ?> revision = findFirstDeclaredSubstatement(stmt,
RevisionDateStatement.class);
stmt.addRequiredSource(revision == null ? RevisionSourceIdentifier.create(stmt.getStatementArgument())
: RevisionSourceIdentifier.create(stmt.getStatementArgument(), revision.getStatementArgument()));
}
示例13: onLinkageDeclared
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入依赖的package包/类
@Override
public final void onLinkageDeclared(
final Mutable<String, IncludeStatement, EffectiveStatement<String, IncludeStatement>> stmt) {
final String submoduleName = stmt.getStatementArgument();
final StmtContext<Revision, ?, ?> revision = findFirstDeclaredSubstatement(stmt,
RevisionDateStatement.class);
final ModelActionBuilder includeAction = stmt.newInferenceAction(SOURCE_LINKAGE);
final Prerequisite<StmtContext<?, ?, ?>> requiresCtxPrerequisite;
if (revision == null) {
requiresCtxPrerequisite = includeAction.requiresCtx(stmt, SubmoduleNamespace.class,
NamespaceKeyCriterion.latestRevisionModule(submoduleName), SOURCE_LINKAGE);
} else {
requiresCtxPrerequisite = includeAction.requiresCtx(stmt, SubmoduleNamespace.class,
RevisionSourceIdentifier.create(submoduleName, Optional.of(revision.getStatementArgument())),
SOURCE_LINKAGE);
}
includeAction.apply(new InferenceAction() {
@Override
public void apply(final InferenceContext ctx) {
final StmtContext<?, ?, ?> includedSubModuleContext = requiresCtxPrerequisite.resolve(ctx);
stmt.addToNs(IncludedModuleContext.class, revision != null
? RevisionSourceIdentifier.create(submoduleName, revision.getStatementArgument())
: RevisionSourceIdentifier.create(submoduleName), includedSubModuleContext);
stmt.addToNs(IncludedSubmoduleNameToModuleCtx.class, stmt.getStatementArgument(),
includedSubModuleContext);
}
@Override
public void prerequisiteFailed(final Collection<? extends Prerequisite<?>> failed) {
InferenceException.throwIf(failed.contains(requiresCtxPrerequisite),
stmt.getStatementSourceReference(),
"Included submodule '%s' was not found: ", stmt.getStatementArgument());
}
});
}
示例14: onLinkageDeclared
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入依赖的package包/类
static void onLinkageDeclared(
final Mutable<String, ImportStatement, EffectiveStatement<String, ImportStatement>> stmt) {
final ModelActionBuilder importAction = stmt.newInferenceAction(SOURCE_LINKAGE);
final Prerequisite<StmtContext<?, ?, ?>> imported;
final String moduleName = stmt.getStatementArgument();
final Revision revision = firstAttributeOf(stmt.declaredSubstatements(), RevisionDateStatement.class);
if (revision == null) {
imported = importAction.requiresCtx(stmt, ModuleNamespace.class,
NamespaceKeyCriterion.latestRevisionModule(moduleName), SOURCE_LINKAGE);
} else {
imported = importAction.requiresCtx(stmt, ModuleNamespace.class,
RevisionSourceIdentifier.create(moduleName, Optional.of(revision)), SOURCE_LINKAGE);
}
final Prerequisite<Mutable<?, ?, ?>> linkageTarget = importAction.mutatesCtx(stmt.getRoot(),
SOURCE_LINKAGE);
importAction.apply(new InferenceAction() {
@Override
public void apply(final InferenceContext ctx) {
final StmtContext<?, ?, ?> importedModule = imported.resolve(ctx);
linkageTarget.resolve(ctx).addToNs(ImportedModuleContext.class,
stmt.getFromNamespace(ModuleCtxToSourceIdentifier.class, importedModule), importedModule);
final String impPrefix = firstAttributeOf(stmt.declaredSubstatements(), PrefixStatement.class);
final URI modNs = firstAttributeOf(importedModule.declaredSubstatements(),
NamespaceStatement.class);
stmt.addToNs(ImportPrefixToModuleCtx.class, impPrefix, importedModule);
stmt.addToNs(URIStringToImportPrefix.class, modNs.toString(), impPrefix);
}
@Override
public void prerequisiteFailed(final Collection<? extends Prerequisite<?>> failed) {
if (failed.contains(imported)) {
throw new InferenceException(stmt.getStatementSourceReference(),
"Imported module [%s] was not found.", moduleName);
}
}
});
}
示例15: getSourceIdentifier
import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; //导入依赖的package包/类
private static Optional<SourceIdentifier> getSourceIdentifier(final String fileName) {
final Matcher matcher = CACHED_FILE_PATTERN.matcher(fileName);
if (matcher.matches()) {
final String moduleName = matcher.group("moduleName");
final String revision = matcher.group("revision");
return Optional.of(RevisionSourceIdentifier.create(moduleName, Revision.ofNullable(revision)));
}
return Optional.empty();
}