本文整理汇总了Java中org.opendaylight.yangtools.yang.model.api.meta.StatementSource类的典型用法代码示例。如果您正苦于以下问题:Java StatementSource类的具体用法?Java StatementSource怎么用?Java StatementSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StatementSource类属于org.opendaylight.yangtools.yang.model.api.meta包,在下文中一共展示了StatementSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testImplicitInputAndOutputInAction
import org.opendaylight.yangtools.yang.model.api.meta.StatementSource; //导入依赖的package包/类
@Test
public void testImplicitInputAndOutputInAction() throws Exception {
final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug9241/foo.yang");
assertNotNull(schemaContext);
final Module fooModule = schemaContext.findModule("foo", Revision.of("2017-10-13")).get();
final ContainerSchemaNode actionCont = (ContainerSchemaNode) fooModule.getDataChildByName(QName.create(
fooModule.getQNameModule(), "action-cont"));
assertNotNull(actionCont);
final ActionDefinition actionInCont = actionCont.getActions().iterator().next();
final ContainerSchemaNode input = actionInCont.getInput();
assertNotNull(input);
assertEquals(1, input.getChildNodes().size());
assertEquals(StatementSource.CONTEXT, ((EffectiveStatement<?, ?>) input).getDeclared().getStatementSource());
final ContainerSchemaNode output = actionInCont.getOutput();
assertNotNull(output);
assertEquals(1, output.getChildNodes().size());
assertEquals(StatementSource.CONTEXT, ((EffectiveStatement<?, ?>) output).getDeclared().getStatementSource());
}
示例2: testImplicitInputAndOutput
import org.opendaylight.yangtools.yang.model.api.meta.StatementSource; //导入依赖的package包/类
@Test
public void testImplicitInputAndOutput() throws Exception {
final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rpc-stmt-test/bar.yang");
assertNotNull(schemaContext);
final Module barModule = schemaContext.findModule("bar", Revision.of("2016-11-25")).get();
final Set<RpcDefinition> rpcs = barModule.getRpcs();
assertEquals(1, rpcs.size());
final RpcDefinition barRpc = rpcs.iterator().next();
final ContainerSchemaNode input = barRpc.getInput();
assertNotNull(input);
assertEquals(2, input.getChildNodes().size());
assertEquals(StatementSource.CONTEXT, ((EffectiveStatement<?, ?>) input).getDeclared().getStatementSource());
final ContainerSchemaNode output = barRpc.getOutput();
assertNotNull(output);
assertEquals(2, output.getChildNodes().size());
assertEquals(StatementSource.CONTEXT, ((EffectiveStatement<?, ?>) output).getDeclared().getStatementSource());
}
示例3: maybeReplace
import org.opendaylight.yangtools.yang.model.api.meta.StatementSource; //导入依赖的package包/类
static TypeStatement maybeReplace(final TypeStatementImpl orig) {
if (orig.declaredSubstatements().isEmpty() && orig.getStatementSource() == StatementSource.DECLARATION
&& orig.statementDefinition() == YangStmtMapping.TYPE) {
final BuiltinTypeStatement builtin = BUILTINS.get(orig.argument());
if (builtin != null) {
return builtin;
}
}
return orig;
}
示例4: endStatement
import org.opendaylight.yangtools.yang.model.api.meta.StatementSource; //导入依赖的package包/类
@Override
public void endStatement(@Nonnull final StatementSourceReference ref) {
Preconditions.checkState(current != null);
current.endDeclared(ref, phase);
StatementContextBase<?, ?, ?> parentContext = current.getParentContext();
while (parentContext != null && StatementSource.CONTEXT == parentContext.getStatementSource()) {
parentContext.endDeclared(ref, phase);
parentContext = parentContext.getParentContext();
}
current = parentContext;
}
示例5: testForwarding
import org.opendaylight.yangtools.yang.model.api.meta.StatementSource; //导入依赖的package包/类
@Test
public void testForwarding() {
final StatementSourceReference ref = mock(StatementSourceReference.class);
final ImplicitSubstatement stmt = ImplicitSubstatement.of(ref);
assertEquals(StatementSource.CONTEXT, stmt.getStatementSource());
doReturn("ref").when(ref).toString();
assertEquals("ref", stmt.toString());
}
示例6: isExplicitStatement
import org.opendaylight.yangtools.yang.model.api.meta.StatementSource; //导入依赖的package包/类
private static boolean isExplicitStatement(final ContainerSchemaNode node) {
return (node instanceof EffectiveStatement)
&& (((EffectiveStatement) node).getDeclared().getStatementSource() == StatementSource.DECLARATION);
}
示例7: isExplicitStatement
import org.opendaylight.yangtools.yang.model.api.meta.StatementSource; //导入依赖的package包/类
private static boolean isExplicitStatement(final DeclaredStatement<?> stmt) {
return stmt != null && stmt.getStatementSource() == StatementSource.DECLARATION;
}
示例8: getStatementSource
import org.opendaylight.yangtools.yang.model.api.meta.StatementSource; //导入依赖的package包/类
@Nonnull
@Override
public final StatementSource getStatementSource() {
return statementSource;
}
示例9: getStatementSource
import org.opendaylight.yangtools.yang.model.api.meta.StatementSource; //导入依赖的package包/类
@Nonnull
@Override
public StatementSource getStatementSource() {
return StatementSource.CONTEXT;
}
示例10: getStatementSource
import org.opendaylight.yangtools.yang.model.api.meta.StatementSource; //导入依赖的package包/类
@Nonnull
@Override
public final StatementSource getStatementSource() {
return getDeclared().getStatementSource();
}
示例11: getStatementSource
import org.opendaylight.yangtools.yang.model.api.meta.StatementSource; //导入依赖的package包/类
@Nonnull
@Override
public final StatementSource getStatementSource() {
return StatementSource.DECLARATION;
}
示例12: getStatementSource
import org.opendaylight.yangtools.yang.model.api.meta.StatementSource; //导入依赖的package包/类
@Nonnull
@Override
public StatementSource getStatementSource() {
return StatementSource.DECLARATION;
}
示例13: getStatementSource
import org.opendaylight.yangtools.yang.model.api.meta.StatementSource; //导入依赖的package包/类
/**
* Returns the origin of the statement.
*
* @return origin of statement
*/
@Nonnull
@Override
public StatementSource getStatementSource() {
return statementDeclSource.getStatementSource();
}
示例14: createDeclaredChild
import org.opendaylight.yangtools.yang.model.api.meta.StatementSource; //导入依赖的package包/类
StatementContextBase<?, ?, ?> createDeclaredChild(final StatementContextBase<?, ?, ?> current, final int childId,
final QName name, final String argument, final StatementSourceReference ref) {
if (current != null) {
// Fast path: we are entering a statement which was emitted in previous phase
StatementContextBase<?, ?, ?> existing = current.lookupSubstatement(childId);
while (existing != null && StatementSource.CONTEXT == existing.getStatementSource()) {
existing = existing.lookupSubstatement(childId);
}
if (existing != null) {
return existing;
}
}
StatementDefinitionContext<?, ?, ?> def = currentContext.getStatementDefinition(getRootVersion(), name);
if (def == null) {
def = currentContext.getModelDefinedStatementDefinition(name);
if (def == null) {
final StatementSupport<?, ?, ?> extension = qnameToStmtDefMap.get(name);
if (extension != null) {
def = new StatementDefinitionContext<>(extension);
currentContext.putModelDefinedStatementDefinition(name, def);
}
}
} else if (current != null && StmtContextUtils.isUnrecognizedStatement(current)) {
/*
* This code wraps statements encountered inside an extension so
* they do not get confused with regular statements.
*/
def = Preconditions.checkNotNull(current.definition().getAsUnknownStatementDefinition(def),
"Unable to create unknown statement definition of yang statement %s in unknown statement %s", def,
current);
}
InferenceException.throwIfNull(def, ref, "Statement %s does not have type mapping defined.", name);
if (def.hasArgument()) {
SourceException.throwIfNull(argument, ref, "Statement %s requires an argument", name);
} else {
SourceException.throwIf(argument != null, ref, "Statement %s does not take argument", name);
}
/*
* If the current statement definition has argument specific
* sub-definitions, get argument specific sub-definition based on given
* argument (e.g. type statement need to be specialized based on its
* argument).
*/
if (def.hasArgumentSpecificSubDefinitions()) {
def = def.getSubDefinitionSpecificForArgument(argument);
}
if (current != null) {
return current.createSubstatement(childId, def, ref, argument);
}
/*
* If root is null or root version is other than default,
* we need to create new root.
*/
if (root == null) {
root = new RootStatementContext<>(this, def, ref, argument);
} else if (!RootStatementContext.DEFAULT_VERSION.equals(root.getRootVersion())
&& inProgressPhase == ModelProcessingPhase.SOURCE_LINKAGE) {
root = new RootStatementContext<>(this, def, ref, argument, root.getRootVersion(),
root.getRootIdentifier());
} else {
final QName rootStatement = root.definition().getStatementName();
final String rootArgument = root.rawStatementArgument();
Preconditions.checkState(Objects.equals(def.getStatementName(), rootStatement)
&& Objects.equals(argument, rootArgument), "Root statement was already defined as '%s %s'.",
rootStatement, rootArgument);
}
return root;
}
示例15: getStatementSource
import org.opendaylight.yangtools.yang.model.api.meta.StatementSource; //导入依赖的package包/类
@Nonnull
@Override
public StatementSource getStatementSource() {
return source;
}