*/
package org.opendaylight.yangtools.yang.model.api.stmt;
+import org.opendaylight.yangtools.yang.common.QName;
+
import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
-public interface InputStatement extends DeclaredStatement<Void>, DataDefinitionContainer.WithReusableDefinitions {
+public interface InputStatement extends DeclaredStatement<QName>, DataDefinitionContainer.WithReusableDefinitions {
}
*/
package org.opendaylight.yangtools.yang.model.api.stmt;
+import org.opendaylight.yangtools.yang.common.QName;
+
import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
-public interface OutputStatement extends DeclaredStatement<Void>, DataDefinitionContainer.WithReusableDefinitions {
+public interface OutputStatement extends DeclaredStatement<QName>, DataDefinitionContainer.WithReusableDefinitions {
}
*/
package org.opendaylight.yangtools.yang.parser.spi.meta;
-import java.util.Map;
+import java.util.List;
+import java.util.Map;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
@Nullable A getStatementArgument();
+ @Nullable List<Object> getArgumentsFromRoot();
+
//<K,VT, V extends VT,N extends IdentifierNamespace<K, V>>
// <K, VT, V extends VT ,N extends IdentifierNamespace<K, V>> VT getFromNamespace(Class<N> type, K key)
@Nonnull <K,V,N extends IdentifierNamespace<K, V>> V getFromNamespace(Class<N> type, K key) throws NamespaceNotAvailableException;
ModelActionBuilder newInferenceAction(ModelProcessingPhase phase);
- <K,KT extends K, N extends StatementNamespace<K, ?, ?>> void addContext(Class<N> namepsace, KT key,
+ <K,KT extends K, N extends StatementNamespace<K, ?, ?>> void addContext(Class<N> namespace, KT key,
StmtContext<?, ?, ?> stmt);
}
try {
PhaseFinished<C> phaseFin = new PhaseFinished<C>();
addReq(phaseFin);
- contextImpl(context).addPhaseCompletedListener(FULL_DECLARATION,phaseFin);
+ contextImpl(context).addPhaseCompletedListener(phase,phaseFin);
return phaseFin;
} catch (SourceException e) {
throw shouldNotHappenProbablyBug(e);
*/
package org.opendaylight.yangtools.yang.parser.stmt.reactor;
+import java.util.List;
+
+import java.util.LinkedList;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.common.QNameModule;
import java.util.Collection;
private final SourceSpecificContext sourceContext;
private final A argument;
+ private LinkedList<?> linkedList;
RootStatementContext(ContextBuilder<A, D, E> builder,
SourceSpecificContext sourceContext) throws SourceException {
return copy;
}
+ @Override
+ public List<Object> getArgumentsFromRoot() {
+ LinkedList<Object> argumentList = new LinkedList<Object>();
+ argumentList.add(argument);
+ return argumentList;
+ }
+
}
@Override
public <K,KT extends K, N extends StatementNamespace<K, ?, ?>> void addContext(
- Class<N> namepsace, KT key, StmtContext<?, ?, ?> stmt) {
- addContextToNamespace(namepsace,(K) key, stmt);
+ Class<N> namespace, KT key, StmtContext<?, ?, ?> stmt) {
+ addContextToNamespace(namespace,(K) key, stmt);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.reactor;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.GroupingUtils;
+import java.util.List;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.GroupingUtils;
import org.opendaylight.yangtools.yang.common.QNameModule;
import java.util.Collection;
import org.opendaylight.yangtools.yang.common.QName;
StatementContextBase<A,D,E> copy = new SubstatementContext<A,D,E>(this,newQNameModule, newParent);
return copy;
}
+
+ @Override
+ public List<Object> getArgumentsFromRoot() {
+ List<Object> argumentsFromRoot = parent.getArgumentsFromRoot();
+ argumentsFromRoot.add(argument);
+ return argumentsFromRoot;
+ }
+
+
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
-import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.AnyXmlEffectiveStatementImpl;
+import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
import java.util.Collection;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
@Override
public EffectiveStatement<QName,AnyxmlStatement> createEffective(StmtContext<QName,AnyxmlStatement,EffectiveStatement<QName,AnyxmlStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new AnyXmlEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
-import org.opendaylight.yangtools.yang.model.api.stmt.YinElementStatement;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ArgumentEffectiveStatementImpl;
+import org.opendaylight.yangtools.yang.model.api.stmt.YinElementStatement;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@Override
public EffectiveStatement<QName, ArgumentStatement> createEffective(
StmtContext<QName, ArgumentStatement, EffectiveStatement<QName, ArgumentStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new ArgumentEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import static org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase.EFFECTIVE_MODEL;
+
import java.util.Collection;
import javax.annotation.Nonnull;
import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.AugmentEffectiveStatementImpl;
public class AugmentStatementImpl extends AbstractDeclaredStatement<SchemaNodeIdentifier> implements AugmentStatement {
@Override
public SchemaNodeIdentifier parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) throws SourceException {
- return SchemaNodeIdentifier.create(Utils.parseAugmentPath(ctx, value), Utils.isXPathAbsolute(value));
+ return SchemaNodeIdentifier.create(AugmentUtils.parseAugmentPath(ctx, value), Utils.isXPathAbsolute(value));
}
@Override
@Override
public EffectiveStatement<SchemaNodeIdentifier, AugmentStatement> createEffective(
StmtContext<SchemaNodeIdentifier, AugmentStatement, EffectiveStatement<SchemaNodeIdentifier, AugmentStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new AugmentEffectiveStatementImpl(ctx);
+ }
+
+ @Override
+ public void onFullDefinitionDeclared(
+ final StmtContext.Mutable<SchemaNodeIdentifier, AugmentStatement, EffectiveStatement<SchemaNodeIdentifier, AugmentStatement>> augmentNode)
+ throws SourceException {
+
+ final ModelActionBuilder augmentAction = augmentNode.newInferenceAction(EFFECTIVE_MODEL);
+ final ModelActionBuilder.Prerequisite<StmtContext<SchemaNodeIdentifier, AugmentStatement, EffectiveStatement<SchemaNodeIdentifier, AugmentStatement>>> sourceCtxPrereq = augmentAction
+ .requiresCtx(augmentNode, ModelProcessingPhase.FULL_DECLARATION);
+
+ augmentAction.apply(new ModelActionBuilder.InferenceAction() {
+
+ @Override
+ public void apply() throws InferenceException {
+
+ final StatementContextBase<?, ?, ?> augmentTargetCtx = AugmentUtils
+ .getAugmentTargetCtx(augmentNode);
+ StatementContextBase<?, ?, ?> augmentSourceCtx = (StatementContextBase<?, ?, ?>) sourceCtxPrereq
+ .get();
+
+ try {
+ AugmentUtils.copyFromSourceToTarget(augmentSourceCtx, augmentTargetCtx);
+ } catch (SourceException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void prerequisiteFailed(final Collection<? extends ModelActionBuilder.Prerequisite<?>> failed)
+ throws InferenceException {
+ if (failed.contains(augmentAction)) {
+ throw new InferenceException("Augment action failed", augmentNode.getStatementSourceReference());
+ }
+ }
+ });
}
}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ * <p/>
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
+import org.opendaylight.yangtools.yang.model.api.stmt.AugmentStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
+import org.opendaylight.yangtools.yang.parser.spi.NamespaceToModule;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
+import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToModuleQName;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
+
+public class AugmentUtils {
+
+ private static final String REGEX_PATH_REL1 = "\\.\\.?\\s*/(.+)";
+ private static final String REGEX_PATH_REL2 = "//.*";
+
+ public static Iterable<QName> parseAugmentPath(StmtContext<?, ?, ?> ctx, String path) {
+
+ if (path.matches(REGEX_PATH_REL1) || path.matches(REGEX_PATH_REL2)) {
+ throw new IllegalArgumentException(
+ "An argument for augment can be only absolute path; or descendant if used in uses");
+ }
+
+ return Utils.parseXPath(ctx, path);
+ }
+
+ public static void copyFromSourceToTarget(StatementContextBase<?, ?, ?> sourceCtx,
+ StatementContextBase<?, ?, ?> targetCtx) throws SourceException {
+
+ QNameModule newQNameModule = getNewQNameModule(targetCtx, sourceCtx);
+ copyDeclaredStmts(sourceCtx, targetCtx, newQNameModule);
+ copyEffectiveStmts(sourceCtx, targetCtx, newQNameModule);
+
+ }
+
+ public static void copyDeclaredStmts(StatementContextBase<?, ?, ?> sourceCtx,
+ StatementContextBase<?, ?, ?> targetCtx, QNameModule newQNameModule) throws SourceException {
+ Collection<? extends StatementContextBase<?, ?, ?>> declaredSubstatements = sourceCtx.declaredSubstatements();
+ for (StatementContextBase<?, ?, ?> originalStmtCtx : declaredSubstatements) {
+ if (needToCopyByAugment(originalStmtCtx)) {
+ StatementContextBase<?, ?, ?> copy = originalStmtCtx.createCopy(newQNameModule, targetCtx);
+ targetCtx.addEffectiveSubstatement(copy);
+ } else if (isReusedByAugment(originalStmtCtx)) {
+ targetCtx.addEffectiveSubstatement(originalStmtCtx);
+ }
+ }
+ }
+
+ public static void copyEffectiveStmts(StatementContextBase<?, ?, ?> sourceCtx,
+ StatementContextBase<?, ?, ?> targetCtx, QNameModule newQNameModule) throws SourceException {
+ Collection<? extends StatementContextBase<?, ?, ?>> effectiveSubstatements = sourceCtx.effectiveSubstatements();
+ for (StatementContextBase<?, ?, ?> originalStmtCtx : effectiveSubstatements) {
+ if (needToCopyByAugment(originalStmtCtx)) {
+ StatementContextBase<?, ?, ?> copy = originalStmtCtx.createCopy(newQNameModule, targetCtx);
+ targetCtx.addEffectiveSubstatement(copy);
+ } else if (isReusedByAugment(originalStmtCtx)) {
+ targetCtx.addEffectiveSubstatement(originalStmtCtx);
+ }
+ }
+ }
+
+ public static QNameModule getNewQNameModule(StatementContextBase<?, ?, ?> targetCtx,
+ StatementContextBase<?, ?, ?> sourceCtx) {
+ Object targetStmtArgument = targetCtx.getStatementArgument();
+
+ final StatementContextBase<?, ?, ?> root = sourceCtx.getRoot();
+ final String moduleName = (String) root.getStatementArgument();
+ final QNameModule sourceQNameModule = root.getFromNamespace(ModuleNameToModuleQName.class, moduleName);
+
+ if (targetStmtArgument instanceof QName) {
+ QName targetQName = (QName) targetStmtArgument;
+ QNameModule targetQNameModule = targetQName.getModule();
+
+ if (targetQNameModule.equals(sourceQNameModule))
+ return null;
+ else
+ return targetQNameModule;
+ } else
+ return null;
+ }
+
+ public static boolean needToCopyByAugment(StmtContext<?, ?, ?> stmtContext) {
+
+ HashSet<StatementDefinition> noCopyDefSet = new HashSet<>();
+ noCopyDefSet.add(Rfc6020Mapping.USES);
+
+ StatementDefinition def = stmtContext.getPublicDefinition();
+ if (noCopyDefSet.contains(def))
+ return false;
+ else
+ return true;
+ }
+
+ public static boolean isReusedByAugment(StmtContext<?, ?, ?> stmtContext) {
+
+ HashSet<StatementDefinition> reusedDefSet = new HashSet<>();
+ reusedDefSet.add(Rfc6020Mapping.TYPEDEF);
+
+ StatementDefinition def = stmtContext.getPublicDefinition();
+ if (reusedDefSet.contains(def))
+ return true;
+ else
+ return false;
+ }
+
+ public static StatementContextBase<?, ?, ?> getAugmentTargetCtx(
+ final Mutable<SchemaNodeIdentifier, AugmentStatement, EffectiveStatement<SchemaNodeIdentifier, AugmentStatement>> augmentNode) {
+
+ final SchemaNodeIdentifier augmentTargetPath = augmentNode.getStatementArgument();
+
+ QNameModule module;
+ if (augmentTargetPath != null) {
+ module = augmentTargetPath.getPathFromRoot().iterator().next().getModule();
+ } else {
+ throw new IllegalArgumentException(
+ "Augment argument null, something bad happened in some of previous parsing phases");
+ }
+
+ StatementContextBase<?, ?, ?> rootStatementCtx = (StatementContextBase<?, ?, ?>) augmentNode.getFromNamespace(
+ NamespaceToModule.class, module);
+
+ final StatementContextBase<?, ?, ?> augmentTargetCtx = Utils.findCtxOfNodeInRoot(rootStatementCtx,
+ augmentTargetPath);
+
+ if (augmentTargetCtx == null) {
+
+ throw new NullPointerException(String.format(
+ "Augment path %s not found in target model so its resulting context is null",
+ augmentNode.rawStatementArgument()));
+
+ }
+
+ return augmentTargetCtx;
+ }
+}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.BaseEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@Override
public EffectiveStatement<QName, BaseStatement> createEffective(
StmtContext<QName, BaseStatement, EffectiveStatement<QName, BaseStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new BaseEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.BelongsEffectiveToStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@Override
public EffectiveStatement<String, BelongsToStatement> createEffective(
StmtContext<String, BelongsToStatement, EffectiveStatement<String, BelongsToStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new BelongsEffectiveToStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.BitEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.PositionStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
@Override
public EffectiveStatement<String, BitStatement> createEffective(
StmtContext<String, BitStatement, EffectiveStatement<String, BitStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new BitEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.CaseEffectiveStatementImpl;
+
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.PresenceEffectiveStatementImpl;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collection;
@Override public EffectiveStatement<QName, CaseStatement> createEffective(
StmtContext<QName, CaseStatement, EffectiveStatement<QName, CaseStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new CaseEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ChoiceEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collection;
@Override
public EffectiveStatement<QName, ChoiceStatement> createEffective(
StmtContext<QName, ChoiceStatement, EffectiveStatement<QName, ChoiceStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new ChoiceEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ConfigEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-
import javax.annotation.Nonnull;
public class ConfigStatementImpl extends AbstractDeclaredStatement<Boolean> implements ConfigStatement {
}
@Override public EffectiveStatement<Boolean, ConfigStatement> createEffective(StmtContext<Boolean, ConfigStatement, EffectiveStatement<Boolean, ConfigStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new ConfigEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ContactEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ContactStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-
import javax.annotation.Nonnull;
public class ContactStatementImpl extends AbstractDeclaredStatement<String> implements ContactStatement{
@Override
public EffectiveStatement<String, ContactStatement> createEffective(StmtContext<String, ContactStatement, EffectiveStatement<String, ContactStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new ContactEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DefaultEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.DefaultStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-
import javax.annotation.Nonnull;
public class DefaultStatementImpl extends AbstractDeclaredStatement<String> implements
@Override public EffectiveStatement<String, DefaultStatement> createEffective(
StmtContext<String, DefaultStatement, EffectiveStatement<String, DefaultStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new DefaultEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DeviateEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.DeviateStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-
import javax.annotation.Nonnull;
public class DeviateStatementImpl extends AbstractDeclaredStatement<String> implements DeviateStatement {
@Override public EffectiveStatement<String, DeviateStatement> createEffective(
StmtContext<String, DeviateStatement, EffectiveStatement<String, DeviateStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new DeviateEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DeviationEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.DeviationStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-
import javax.annotation.Nonnull;
public class DeviationStatementImpl extends AbstractDeclaredStatement<SchemaNodeIdentifier> implements DeviationStatement {
@Override public EffectiveStatement<SchemaNodeIdentifier, DeviationStatement> createEffective(
StmtContext<SchemaNodeIdentifier, DeviationStatement, EffectiveStatement<SchemaNodeIdentifier, DeviationStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new DeviationEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
-import org.opendaylight.yangtools.yang.model.api.stmt.ValueStatement;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EnumEffectiveStatementImpl;
+import org.opendaylight.yangtools.yang.model.api.stmt.ValueStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
@Override
public EffectiveStatement<String, EnumStatement> createEffective(
StmtContext<String, EnumStatement, EffectiveStatement<String, EnumStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new EnumEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ErrorAppTagEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ErrorAppTagStatement;
@Override
public EffectiveStatement<String, ErrorAppTagStatement> createEffective(
StmtContext<String, ErrorAppTagStatement, EffectiveStatement<String, ErrorAppTagStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new ErrorAppTagEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ErrorMessageEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ErrorMessageStatement;
@Override
public EffectiveStatement<String, ErrorMessageStatement> createEffective(
StmtContext<String, ErrorMessageStatement, EffectiveStatement<String, ErrorMessageStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new ErrorMessageEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
-import org.opendaylight.yangtools.yang.model.api.stmt.ArgumentStatement;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ExtensionEffectiveStatementImpl;
+import org.opendaylight.yangtools.yang.model.api.stmt.ArgumentStatement;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@Override
public EffectiveStatement<QName,ExtensionStatement> createEffective(StmtContext<QName,ExtensionStatement,EffectiveStatement<QName,ExtensionStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new ExtensionEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.FeatureEffectiveStatementImpl;
+
import java.util.Collection;
import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureStatement;
-
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@Override
public EffectiveStatement<QName, FeatureStatement> createEffective(
StmtContext<QName, FeatureStatement, EffectiveStatement<QName, FeatureStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new FeatureEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.IdentityEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.stmt.BaseStatement;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
@Override
public EffectiveStatement<QName, IdentityStatement> createEffective(
StmtContext<QName, IdentityStatement, EffectiveStatement<QName, IdentityStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new IdentityEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.IfFeatureEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@Override
public EffectiveStatement<QName, IfFeatureStatement> createEffective(
StmtContext<QName, IfFeatureStatement, EffectiveStatement<QName, IfFeatureStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new IfFeatureEffectiveStatementImpl(ctx);
}
}
import static org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase.SOURCE_LINKAGE;
import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.firstAttributeOf;
+
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ImportEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToModuleIdentifier;
import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
import com.google.common.base.Optional;
@Override
public EffectiveStatement<String, ImportStatement> createEffective(
StmtContext<String, ImportStatement, EffectiveStatement<String, ImportStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new ImportEffectiveStatementImpl(ctx);
}
@Override
import static org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase.SOURCE_LINKAGE;
import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.firstAttributeOf;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.IncludeEffectiveStatementImpl;
+
import java.net.URI;
import java.text.ParseException;
import java.util.Collection;
import java.util.Date;
-
import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-
import com.google.common.base.Optional;
public class IncludeStatementImpl extends AbstractDeclaredStatement<String> implements IncludeStatement {
@Override
public EffectiveStatement<String, IncludeStatement> createEffective(
StmtContext<String, IncludeStatement, EffectiveStatement<String, IncludeStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new IncludeEffectiveStatementImpl(ctx);
}
@Override
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.InputEffectiveStatementImpl;
+
+import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import java.util.Collection;
import org.opendaylight.yangtools.yang.model.api.stmt.DataDefinitionStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-public class InputStatementImpl extends AbstractDeclaredStatement<Void>
+public class InputStatementImpl extends AbstractDeclaredStatement<QName>
implements InputStatement {
- protected InputStatementImpl(
- StmtContext<Void, InputStatement, ?> context) {
+ protected InputStatementImpl(StmtContext<QName, InputStatement, ?> context) {
super(context);
}
public static class Definition
extends
- AbstractStatementSupport<Void, InputStatement, EffectiveStatement<Void, InputStatement>> {
+ AbstractStatementSupport<QName, InputStatement, EffectiveStatement<QName, InputStatement>> {
public Definition() {
super(Rfc6020Mapping.INPUT);
}
@Override
- public Void parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
+ public QName parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
throws SourceException {
- return null;
+ value = "input";
+ return Utils.qNameFromArgument(ctx, value);
}
@Override
public InputStatement createDeclared(
- StmtContext<Void, InputStatement, ?> ctx) {
+ StmtContext<QName, InputStatement, ?> ctx) {
return new InputStatementImpl(ctx);
}
@Override
- public EffectiveStatement<Void, InputStatement> createEffective(
- StmtContext<Void, InputStatement, EffectiveStatement<Void, InputStatement>> ctx) {
- throw new UnsupportedOperationException();
+ public EffectiveStatement<QName, InputStatement> createEffective(
+ StmtContext<QName, InputStatement, EffectiveStatement<QName, InputStatement>> ctx) {
+ return new InputEffectiveStatementImpl(ctx);
}
}
return allDeclared(DataDefinitionStatement.class);
}
}
-
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.KeyEffectiveStatementImpl;
+
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.KeyStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-
import com.google.common.base.Splitter;
public class KeyStatementImpl extends AbstractDeclaredStatement<Collection<SchemaNodeIdentifier>> implements
@Override
public EffectiveStatement<Collection<SchemaNodeIdentifier>, KeyStatement> createEffective(
StmtContext<Collection<SchemaNodeIdentifier>, KeyStatement, EffectiveStatement<Collection<SchemaNodeIdentifier>, KeyStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new KeyEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.LeafListEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.UnitsStatement;
-
import org.opendaylight.yangtools.yang.model.api.stmt.MaxElementsStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.MinElementsStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.MustStatement;
@Override
public EffectiveStatement<QName, LeafListStatement> createEffective(
StmtContext<QName, LeafListStatement, EffectiveStatement<QName, LeafListStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new LeafListEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.LeafEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collection;
@Override public EffectiveStatement<QName, LeafStatement> createEffective(
StmtContext<QName, LeafStatement, EffectiveStatement<QName, LeafStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new LeafEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.LengthEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ErrorAppTagStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ErrorMessageStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
-
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.LengthStatement;
@Override
public EffectiveStatement<String, LengthStatement> createEffective(
StmtContext<String, LengthStatement, EffectiveStatement<String, LengthStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new LengthEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ListEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.stmt.DataDefinitionStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.GroupingStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.KeyStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.OrderedByStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.TypedefStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.UniqueStatement;
-
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@Override
public EffectiveStatement<QName, ListStatement> createEffective(
StmtContext<QName, ListStatement, EffectiveStatement<QName, ListStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new ListEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.MandatoryEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-
import javax.annotation.Nonnull;
public class MandatoryStatementImpl extends AbstractDeclaredStatement<Boolean> implements
@Override public EffectiveStatement<Boolean, MandatoryStatement> createEffective(
StmtContext<Boolean, MandatoryStatement, EffectiveStatement<Boolean, MandatoryStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new MandatoryEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.MaxElementsEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.MaxElementsStatement;
@Override
public EffectiveStatement<String, MaxElementsStatement> createEffective(
StmtContext<String, MaxElementsStatement, EffectiveStatement<String, MaxElementsStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new MaxElementsEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.MinElementsEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.MinElementsStatement;
@Override
public EffectiveStatement<String, MinElementsStatement> createEffective(
StmtContext<String, MinElementsStatement, EffectiveStatement<String, MinElementsStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new MinElementsEffectiveStatementImpl(ctx);
}
}
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-public class ModuleStatementSupport
- extends
+public class ModuleStatementSupport extends
AbstractStatementSupport<String, ModuleStatement, EffectiveStatement<String, ModuleStatement>> {
+ private QNameModule qNameModule;
+
public ModuleStatementSupport() {
super(Rfc6020Mapping.MODULE);
}
}
@Override
- public ModuleStatement createDeclared(
- StmtContext<String, ModuleStatement, ?> ctx) {
+ public ModuleStatement createDeclared(StmtContext<String, ModuleStatement, ?> ctx) {
return new ModuleStatementImpl(ctx);
}
}
@Override
- public void onLinkageDeclared(
- Mutable<String, ModuleStatement, EffectiveStatement<String, ModuleStatement>> stmt)
+ public void onLinkageDeclared(Mutable<String, ModuleStatement, EffectiveStatement<String, ModuleStatement>> stmt)
throws InferenceException, SourceException {
- Optional<URI> moduleNs = Optional.fromNullable(firstAttributeOf(
- stmt.declaredSubstatements(), NamespaceStatement.class));
+ Optional<URI> moduleNs = Optional.fromNullable(firstAttributeOf(stmt.declaredSubstatements(),
+ NamespaceStatement.class));
if (!moduleNs.isPresent()) {
- throw new IllegalArgumentException("Namespace of the module ["
- + stmt.getStatementArgument() + "] is missing.");
+ throw new IllegalArgumentException("Namespace of the module [" + stmt.getStatementArgument()
+ + "] is missing.");
}
- Optional<Date> revisionDate = Optional.fromNullable(firstAttributeOf(
- stmt.declaredSubstatements(), RevisionStatement.class));
+ Optional<Date> revisionDate = Optional.fromNullable(firstAttributeOf(stmt.declaredSubstatements(),
+ RevisionStatement.class));
- QNameModule qNameModule = QNameModule.create(moduleNs.get(),
- revisionDate.orNull());
- ModuleIdentifier moduleIdentifier = new ModuleIdentifierImpl(
- stmt.getStatementArgument(), Optional.<URI> absent(),
- revisionDate);
+ qNameModule = QNameModule.create(moduleNs.get(), revisionDate.orNull());
+ ModuleIdentifier moduleIdentifier = new ModuleIdentifierImpl(stmt.getStatementArgument(),
+ Optional.<URI> absent(), revisionDate);
stmt.addContext(ModuleNamespace.class, moduleIdentifier, stmt);
stmt.addContext(NamespaceToModule.class, qNameModule, stmt);
- String modulePrefix = firstAttributeOf(stmt.declaredSubstatements(),
- PrefixStatement.class);
+ String modulePrefix = firstAttributeOf(stmt.declaredSubstatements(), PrefixStatement.class);
if (modulePrefix == null) {
- throw new IllegalArgumentException("Prefix of the module ["
- + stmt.getStatementArgument() + "] is missing.");
+ throw new IllegalArgumentException("Prefix of the module [" + stmt.getStatementArgument() + "] is missing.");
}
stmt.addToNs(PrefixToModule.class, modulePrefix, qNameModule);
stmt.addToNs(ModuleIdentifierToModuleQName.class, moduleIdentifier, qNameModule);
stmt.addToNs(ImpPrefixToModuleIdentifier.class, modulePrefix, moduleIdentifier);
-
}
+ @Override
+ public void onFullDefinitionDeclared(
+ final Mutable<String, ModuleStatement, EffectiveStatement<String, ModuleStatement>> stmt)
+ throws SourceException {
-
-// @Override
-// public void onFullDefinitionDeclared(
-// Mutable<String, ModuleStatement, EffectiveStatement<String, ModuleStatement>> stmt)
-// throws InferenceException, SourceException {
-//
-// Optional<Date> revisionDate = Optional.fromNullable(firstAttributeOf(
-// stmt.declaredSubstatements(), RevisionStatement.class));
-//
-// ModuleIdentifier moduleIdentifier = new ModuleIdentifierImpl(
-// stmt.getStatementArgument(), Optional.<URI> absent(),
-// revisionDate);
-//
-// String modulePrefix = firstAttributeOf(stmt.declaredSubstatements(),
-// PrefixStatement.class);
-//
-// stmt.addToNs(ImpPrefixToModuleIdentifier.class, modulePrefix, moduleIdentifier);
-// }
-
+ stmt.addContext(NamespaceToModule.class, qNameModule, stmt);
+ }
}
\ No newline at end of file
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.MustEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@Override public EffectiveStatement<RevisionAwareXPath, MustStatement> createEffective(
StmtContext<RevisionAwareXPath, MustStatement, EffectiveStatement<RevisionAwareXPath, MustStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new MustEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.NotificationEffectiveStatementImpl;
+
import javax.annotation.Nullable;
import java.util.Collection;
import org.opendaylight.yangtools.yang.model.api.stmt.DataDefinitionStatement;
@Override
public EffectiveStatement<QName, NotificationStatement> createEffective(
StmtContext<QName, NotificationStatement, EffectiveStatement<QName, NotificationStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new NotificationEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.OrderedByEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.OrderedByStatement;
@Override
public EffectiveStatement<String, OrderedByStatement> createEffective(
StmtContext<String, OrderedByStatement, EffectiveStatement<String, OrderedByStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new OrderedByEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.OrganizationEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.OrganizationStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-public class OrganizationStatementImpl extends AbstractDeclaredStatement<String>
- implements OrganizationStatement {
+public class OrganizationStatementImpl extends
+ AbstractDeclaredStatement<String> implements OrganizationStatement {
protected OrganizationStatementImpl(
StmtContext<String, OrganizationStatement, ?> context) {
@Override
public EffectiveStatement<String, OrganizationStatement> createEffective(
StmtContext<String, OrganizationStatement, EffectiveStatement<String, OrganizationStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new OrganizationEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.common.QName;
+
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.OutputEffectiveStatementImpl;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import java.util.Collection;
import org.opendaylight.yangtools.yang.model.api.stmt.DataDefinitionStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-public class OutputStatementImpl extends AbstractDeclaredStatement<Void>
+public class OutputStatementImpl extends AbstractDeclaredStatement<QName>
implements OutputStatement {
protected OutputStatementImpl(
- StmtContext<Void, OutputStatement, ?> context) {
+ StmtContext<QName, OutputStatement, ?> context) {
super(context);
}
public static class Definition
extends
- AbstractStatementSupport<Void, OutputStatement, EffectiveStatement<Void, OutputStatement>> {
+ AbstractStatementSupport<QName, OutputStatement, EffectiveStatement<QName, OutputStatement>> {
public Definition() {
super(Rfc6020Mapping.OUTPUT);
}
@Override
- public Void parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
+ public QName parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
throws SourceException {
- return null;
+ value = "output";
+ return Utils.qNameFromArgument(ctx, value);
}
@Override
public OutputStatement createDeclared(
- StmtContext<Void, OutputStatement, ?> ctx) {
+ StmtContext<QName, OutputStatement, ?> ctx) {
return new OutputStatementImpl(ctx);
}
@Override
- public EffectiveStatement<Void, OutputStatement> createEffective(
- StmtContext<Void, OutputStatement, EffectiveStatement<Void, OutputStatement>> ctx) {
- throw new UnsupportedOperationException();
+ public EffectiveStatement<QName, OutputStatement> createEffective(
+ StmtContext<QName, OutputStatement, EffectiveStatement<QName, OutputStatement>> ctx) {
+ return new OutputEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.PatternEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ErrorAppTagStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ErrorMessageStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
-
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.PatternStatement;
@Override
public EffectiveStatement<String, PatternStatement> createEffective(
StmtContext<String, PatternStatement, EffectiveStatement<String, PatternStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new PatternEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.PositionEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.PositionStatement;
@Override
public EffectiveStatement<String, PositionStatement> createEffective(
StmtContext<String, PositionStatement, EffectiveStatement<String, PositionStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new PositionEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.RangeEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ErrorAppTagStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ErrorMessageStatement;
@Override
public EffectiveStatement<String, RangeStatement> createEffective(
StmtContext<String, RangeStatement, EffectiveStatement<String, RangeStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new RangeEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.RefineEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-
import javax.annotation.Nullable;
public class RefineStatementImpl extends AbstractDeclaredStatement<SchemaNodeIdentifier> implements RefineStatement {
@Override
public EffectiveStatement<SchemaNodeIdentifier, RefineStatement> createEffective(StmtContext<SchemaNodeIdentifier, RefineStatement, EffectiveStatement<SchemaNodeIdentifier, RefineStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new RefineEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.RequireInstanceEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.RequireInstanceStatement;
@Override
public EffectiveStatement<Boolean, RequireInstanceStatement> createEffective(
StmtContext<Boolean, RequireInstanceStatement, EffectiveStatement<Boolean, RequireInstanceStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new RequireInstanceEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.RevisionDateEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.RevisionDateStatement;
@Override
public EffectiveStatement<String, RevisionDateStatement> createEffective(
StmtContext<String, RevisionDateStatement, EffectiveStatement<String, RevisionDateStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new RevisionDateEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.RevisionEffectiveStatementImpl;
+import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
import java.text.ParseException;
import java.util.Date;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
@Override
public EffectiveStatement<Date, RevisionStatement> createEffective(
StmtContext<Date, RevisionStatement, EffectiveStatement<Date, RevisionStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new RevisionEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.RpcEffectiveStatementImpl;
+
import javax.annotation.Nullable;
import java.util.Collection;
import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
@Override
public EffectiveStatement<QName, RpcStatement> createEffective(
StmtContext<QName, RpcStatement, EffectiveStatement<QName, RpcStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new RpcEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.StatusEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
@Override
public EffectiveStatement<String, StatusStatement> createEffective(
StmtContext<String, StatusStatement, EffectiveStatement<String, StatusStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new StatusEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.UnitsEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.UnitsStatement;
@Override
public EffectiveStatement<String, UnitsStatement> createEffective(
StmtContext<String, UnitsStatement, EffectiveStatement<String, UnitsStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new UnitsEffectiveStatementImpl(ctx);
}
}
import static org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase.FULL_DECLARATION;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.UsesEffectiveStatementImpl;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
import java.util.Collection;
+
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder.InferenceAction;
import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder.Prerequisite;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.UsesEffectiveStatementImpl;
-public class UsesStatementImpl extends AbstractDeclaredStatement<QName>
- implements UsesStatement {
+public class UsesStatementImpl extends AbstractDeclaredStatement<QName> implements UsesStatement {
protected UsesStatementImpl(StmtContext<QName, UsesStatement, ?> context) {
super(context);
}
- public static class Definition
- extends
+ public static class Definition extends
AbstractStatementSupport<QName, UsesStatement, EffectiveStatement<QName, UsesStatement>> {
public Definition() {
}
@Override
- public void onFullDefinitionDeclared(final StmtContext.Mutable<QName,UsesStatement,EffectiveStatement<QName,UsesStatement>> usesNode) throws InferenceException ,SourceException {
+ public void onFullDefinitionDeclared(
+ final StmtContext.Mutable<QName, UsesStatement, EffectiveStatement<QName, UsesStatement>> usesNode)
+ throws InferenceException, SourceException {
ModelActionBuilder usesAction = usesNode.newInferenceAction(FULL_DECLARATION);
final QName groupingName = usesNode.getStatementArgument();
- final Prerequisite<StmtContext<?, ?, ?>> sourceGroupingPre = usesAction.requiresCtx(usesNode, GroupingNamespace.class, groupingName, FULL_DECLARATION);
- final Prerequisite< ?extends StmtContext.Mutable<?,?,?>> targetNodePre = usesAction.mutatesCtx(usesNode.getParentContext(), FULL_DECLARATION);
+ final Prerequisite<StmtContext<?, ?, ?>> sourceGroupingPre = usesAction.requiresCtx(usesNode,
+ GroupingNamespace.class, groupingName, FULL_DECLARATION);
+ final Prerequisite<? extends StmtContext.Mutable<?, ?, ?>> targetNodePre = usesAction.mutatesCtx(
+ usesNode.getParentContext(), FULL_DECLARATION);
usesAction.apply(new InferenceAction() {
@Override
public void apply() throws InferenceException {
- StatementContextBase<?, ?, ?> targetNodeStmtCtx = (StatementContextBase<?, ?, ?>) targetNodePre.get();
- StatementContextBase<?, ?, ?> sourceGrpStmtCtx = (StatementContextBase<?, ?, ?>) sourceGroupingPre.get();
+ StatementContextBase<?, ?, ?> targetNodeStmtCtx = (StatementContextBase<?, ?, ?>) targetNodePre
+ .get();
+ StatementContextBase<?, ?, ?> sourceGrpStmtCtx = (StatementContextBase<?, ?, ?>) sourceGroupingPre
+ .get();
try {
- GroupingUtils.copyFromSourceToTarget(sourceGrpStmtCtx,targetNodeStmtCtx);
+ GroupingUtils.copyFromSourceToTarget(sourceGrpStmtCtx, targetNodeStmtCtx);
GroupingUtils.resolveUsesNode(usesNode, targetNodeStmtCtx);
} catch (SourceException e) {
// TODO Auto-generated catch block
@Override
public void prerequisiteFailed(Collection<? extends Prerequisite<?>> failed) throws InferenceException {
- if(failed.contains(sourceGroupingPre)) {
- throw new InferenceException("Grouping " + groupingName + " was not resoled.", usesNode.getStatementSourceReference());
+ if (failed.contains(sourceGroupingPre)) {
+ throw new InferenceException("Grouping " + groupingName + " was not resovled.", usesNode
+ .getStatementSourceReference());
}
- throw new InferenceException("Unknown error occured.", usesNode.getStatementSourceReference());
+ throw new InferenceException("Unknown error occurred.", usesNode.getStatementSourceReference());
}
});
}
@Override
- public UsesStatement createDeclared(
- StmtContext<QName, UsesStatement, ?> ctx) {
+ public UsesStatement createDeclared(StmtContext<QName, UsesStatement, ?> ctx) {
return new UsesStatementImpl(ctx);
}
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
+import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
+
+import javax.annotation.Nullable;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
+
import org.antlr.v4.runtime.tree.TerminalNode;
import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementParser;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
import org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToModuleQName;
import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
+
import com.google.common.base.CharMatcher;
import com.google.common.base.Splitter;
private static final CharMatcher DOUBLE_QUOTE_MATCHER = CharMatcher.is('"');
private static final CharMatcher SINGLE_QUOTE_MATCHER = CharMatcher.is('\'');
- private static final char SEPARATOR_QNAME = '/';
+ private static final char SEPARATOR_NODENAME = '/';
private static final String REGEX_PATH_ABS = "/[^/].+";
- private static final String REGEX_PATH_REL1 = "\\.\\.?\\s*/(.+)";
- private static final String REGEX_PATH_REL2 = "//.*";
public static final StatementSourceReference CONTEXT_REF = new StatementSourceReference() {
}
};
+ public static List<String> splitPathToNodeNames(String path) {
+
+ Splitter keySplitter = Splitter.on(SEPARATOR_NODENAME).omitEmptyStrings().trimResults();
+ return keySplitter.splitToList(path);
+ }
+
public static void validateXPath(String path) {
final XPath xPath = XPathFactory.newInstance().newXPath();
validateXPath(path);
- Splitter keySplitter = Splitter.on(SEPARATOR_QNAME).omitEmptyStrings().trimResults();
- List<String> nodeNames = keySplitter.splitToList(path);
+ List<String> nodeNames = splitPathToNodeNames(path);
List<QName> qNames = new ArrayList<>();
for (String nodeName : nodeNames) {
return qNames;
}
- public static Iterable<QName> parseAugmentPath(StmtContext<?, ?, ?> ctx, String path) {
-
- if (path.matches(REGEX_PATH_REL1) || path.matches(REGEX_PATH_REL2)) {
- throw new IllegalArgumentException(
- "An argument for augment can be only absolute path; or descendant if used in uses");
- }
-
- return parseXPath(ctx, path);
- }
-
public static String stringFromStringContext(final YangStatementParser.ArgumentContext context) {
StringBuilder sb = new StringBuilder();
List<TerminalNode> strings = context.STRING();
return QName.create(qNameModule, localName);
}
+
+ @Nullable
+ public static StatementContextBase<?, ?, ?> findCtxOfNodeInRoot(StatementContextBase<?, ?, ?> rootStmtCtx,
+ final SchemaNodeIdentifier node) {
+
+ StatementContextBase<?, ?, ?> parent = rootStmtCtx;
+ final Iterator<QName> pathIter = node.getPathFromRoot().iterator();
+
+ QName targetNode = pathIter.next();
+
+ while (pathIter.hasNext()) {
+
+ for (StatementContextBase<?, ?, ?> child : parent.declaredSubstatements()) {
+
+ if (targetNode.equals(child.getStatementArgument())) {
+ parent = child;
+ targetNode = pathIter.next();
+ }
+ }
+
+ if (parent.equals(rootStmtCtx)) {
+
+ return null;
+ }
+ }
+
+ StatementContextBase<?, ?, ?> targetCtx = null;
+
+ for (StatementContextBase<?, ?, ?> child : parent.declaredSubstatements()) {
+
+ if (targetNode.equals(child.getStatementArgument())) {
+ targetCtx = child;
+ }
+ }
+
+ return targetCtx;
+ }
+
+ public static SchemaPath getSchemaPath(StmtContext<?, ?, ?> ctx) {
+
+ Iterator<Object> argumentsIterator = ctx.getArgumentsFromRoot().iterator();
+ argumentsIterator.next(); // skip root argument
+
+ List<QName> qNamesFromRoot = new LinkedList<>();
+
+ while (argumentsIterator.hasNext()) {
+ Object argument = argumentsIterator.next();
+ if (argument instanceof QName) {
+ QName qname = (QName) argument;
+ qNamesFromRoot.add(qname);
+ } else
+ return SchemaPath.SAME;
+ }
+
+ return SchemaPath.create(qNamesFromRoot, true);
+ }
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ValueEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ValueStatement;
@Override
public EffectiveStatement<String, ValueStatement> createEffective(
StmtContext<String, ValueStatement, EffectiveStatement<String, ValueStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new ValueEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.WhenEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@Override public EffectiveStatement<RevisionAwareXPath, WhenStatement> createEffective(
StmtContext<RevisionAwareXPath, WhenStatement, EffectiveStatement<RevisionAwareXPath, WhenStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new WhenEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.YangVersionEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.YangVersionStatement;
import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-
import javax.annotation.Nonnull;
public class YangVersionStatementImpl extends AbstractDeclaredStatement<String> implements YangVersionStatement {
@Override
public EffectiveStatement<String, YangVersionStatement> createEffective(StmtContext<String, YangVersionStatement, EffectiveStatement<String, YangVersionStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new YangVersionEffectiveStatementImpl(ctx);
}
}
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.YinElementEffectiveStatementImpl;
+
import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.YinElementStatement;
@Override
public EffectiveStatement<Boolean, YinElementStatement> createEffective(
StmtContext<Boolean, YinElementStatement, EffectiveStatement<Boolean, YinElementStatement>> ctx) {
- throw new UnsupportedOperationException();
+ return new YinElementEffectiveStatementImpl(ctx);
}
}
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+import com.google.common.collect.ImmutableSet;
+
+import com.google.common.collect.ImmutableMap;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
-
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
-import java.util.Map;
import java.util.Set;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
extends AbstractEffectiveDocumentedNode<A, D> implements
DataNodeContainer {
- private final Map<QName, DataSchemaNode> childNodes;
- private final Set<GroupingDefinition> groupings;
- private final Set<UsesNode> uses;
- private final Set<TypeDefinition<?>> typeDefinitions;
- private final Set<DataSchemaNode> publicChildNodes;
+ private final ImmutableMap<QName, DataSchemaNode> childNodes;
+ private final ImmutableSet<GroupingDefinition> groupings;
+ private final ImmutableSet<UsesNode> uses;
+ private final ImmutableSet<TypeDefinition<?>> typeDefinitions;
+ private final ImmutableSet<DataSchemaNode> publicChildNodes;
protected AbstractEffectiveDocumentedDataNodeContainer(
final StmtContext<A, D, ?> ctx) {
Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
- childNodes = new HashMap<QName, DataSchemaNode>();
- groupings = new HashSet<GroupingDefinition>();
- uses = new HashSet<UsesNode>();
- typeDefinitions = new HashSet<TypeDefinition<?>>();
- publicChildNodes = new HashSet<DataSchemaNode>();
+ HashMap<QName, DataSchemaNode> childNodes = new HashMap<QName, DataSchemaNode>();
+ HashSet<GroupingDefinition> groupings = new HashSet<GroupingDefinition>();
+ HashSet<UsesNode> uses = new HashSet<UsesNode>();
+ HashSet<TypeDefinition<?>> typeDefinitions = new HashSet<TypeDefinition<?>>();
+ HashSet<DataSchemaNode> publicChildNodes = new HashSet<DataSchemaNode>();
for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
if (effectiveStatement instanceof DataSchemaNode) {
groupings.add(grp);
}
}
+
+ this.childNodes = ImmutableMap.copyOf(childNodes);
+ this.groupings = ImmutableSet.copyOf(groupings);
+ this.publicChildNodes = ImmutableSet.copyOf(publicChildNodes);
+ this.typeDefinitions = ImmutableSet.copyOf(typeDefinitions);
+ this.uses = ImmutableSet.copyOf(uses);
}
@Override
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
import com.google.common.base.Optional;
import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
import org.opendaylight.yangtools.yang.model.api.UsesNode;
-
public abstract class AbstractEffectiveSchemaContext implements SchemaContext {
protected static final Supplier<TreeSet<Module>> MODULE_SET_SUPPLIER = new Supplier<TreeSet<Module>>() {
@Override
public Set<Module> findModuleByNamespace(final URI namespace) {
final Set<Module> ret = getNamespaceToModules().get(namespace);
- return ret == null ? Collections.<Module>emptySet() : ret;
+ return ret == null ? Collections.<Module> emptySet() : ret;
}
@Override
- public Module findModuleByNamespaceAndRevision(final URI namespace, final Date revision) {
+ public Module findModuleByNamespaceAndRevision(final URI namespace,
+ final Date revision) {
if (namespace == null) {
return null;
}
return Collections.emptySet();
}
- //FIXME: should work for submodules too
+ // FIXME: should work for submodules too
@Override
public Set<ModuleIdentifier> getAllModuleIdentifiers() {
return getIdentifiersToSources().keySet();
}
@Override
- public Optional<String> getModuleSource(final ModuleIdentifier moduleIdentifier) {
+ public Optional<String> getModuleSource(
+ final ModuleIdentifier moduleIdentifier) {
String maybeSource = getIdentifiersToSources().get(moduleIdentifier);
return Optional.fromNullable(maybeSource);
}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.AnyxmlStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
+import java.util.List;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
+import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+
+public class AnyXmlEffectiveStatementImpl extends
+ AbstractEffectiveDocumentedNode<QName, AnyxmlStatement> implements
+ AnyXmlSchemaNode, DerivableSchemaNode {
+ private final QName qname;
+ private final SchemaPath path;
+
+ boolean configuration;
+ AnyXmlSchemaNode original;
+ ConstraintDefinition constraintsDef;
+ boolean augmenting;
+ boolean addedByUses;
+
+ ImmutableList<UnknownSchemaNode> unknownNodes;
+
+ public AnyXmlEffectiveStatementImpl(
+ StmtContext<QName, AnyxmlStatement, EffectiveStatement<QName, AnyxmlStatement>> ctx) {
+ super(ctx);
+ this.qname = ctx.getStatementArgument();
+ this.path = Utils.getSchemaPath(ctx);
+
+ initSubstatementCollections();
+ }
+
+ private void initSubstatementCollections() {
+ Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
+
+ LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
+
+ for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
+ if (effectiveStatement instanceof UnknownSchemaNode) {
+ UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
+ unknownNodes.add(unknownNode);
+ }
+ }
+
+ this.unknownNodes = ImmutableList.copyOf(unknownNodes);
+ }
+
+ @Override
+ public QName getQName() {
+ return qname;
+ }
+
+ @Override
+ public SchemaPath getPath() {
+ return path;
+ }
+
+ @Override
+ public boolean isAugmenting() {
+ return augmenting;
+ }
+
+ @Override
+ public boolean isAddedByUses() {
+ return addedByUses;
+ }
+
+ @Override
+ public Optional<AnyXmlSchemaNode> getOriginal() {
+ return Optional.fromNullable(original);
+ }
+
+ @Override
+ public boolean isConfiguration() {
+ return configuration;
+ }
+
+ @Override
+ public ConstraintDefinition getConstraints() {
+ return constraintsDef;
+ }
+
+ @Override
+ public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+ return unknownNodes;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+ result = prime * result + ((path == null) ? 0 : path.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ AnyXmlEffectiveStatementImpl other = (AnyXmlEffectiveStatementImpl) obj;
+ if (qname == null) {
+ if (other.qname != null) {
+ return false;
+ }
+ } else if (!qname.equals(other.qname)) {
+ return false;
+ }
+ if (path == null) {
+ if (other.path != null) {
+ return false;
+ }
+ } else if (!path.equals(other.path)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(
+ AnyXmlEffectiveStatementImpl.class.getSimpleName());
+ sb.append("[");
+ sb.append("qname=").append(qname);
+ sb.append(", path=").append(path);
+ sb.append("]");
+ return sb.toString();
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.stmt.ArgumentStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class ArgumentEffectiveStatementImpl extends
+ EffectiveStatementBase<QName, ArgumentStatement> {
+
+ public ArgumentEffectiveStatementImpl(
+ StmtContext<QName, ArgumentStatement, ?> ctx) {
+ super(ctx);
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import java.util.Collection;
+import java.util.LinkedList;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.AugmentStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
+import java.net.URI;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.NamespaceRevisionAware;
+import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+
+public class AugmentEffectiveStatementImpl
+ extends
+ AbstractEffectiveDocumentedDataNodeContainer<SchemaNodeIdentifier, AugmentStatement>
+ implements AugmentationSchema, NamespaceRevisionAware,
+ Comparable<AugmentEffectiveStatementImpl> {
+ private final int order;
+ private final SchemaPath targetPath;
+ RevisionAwareXPath whenCondition;
+
+ URI namespace;
+ Date revision;
+ ImmutableList<UnknownSchemaNode> unknownNodes;
+ private AugmentationSchema copyOf;
+
+ public AugmentEffectiveStatementImpl(
+ StmtContext<SchemaNodeIdentifier, AugmentStatement, EffectiveStatement<SchemaNodeIdentifier, AugmentStatement>> ctx) {
+ super(ctx);
+
+ SchemaNodeIdentifier schemaNodeIdentifier = ctx.getStatementArgument();
+ this.targetPath = SchemaPath.create(
+ schemaNodeIdentifier.getPathFromRoot(),
+ schemaNodeIdentifier.isAbsolute());
+
+ // :TODO init other fields
+ this.order = 1;
+ // firstEffective(WhenEffectiveStatementImpl.class);
+
+ initSubstatementCollections();
+ }
+
+ private void initSubstatementCollections() {
+ Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
+
+ LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
+
+ for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
+ if (effectiveStatement instanceof UnknownSchemaNode) {
+ UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
+ unknownNodes.add(unknownNode);
+ }
+ }
+
+ this.unknownNodes = ImmutableList.copyOf(unknownNodes);
+ }
+
+ public void setCopyOf(final AugmentationSchema build) {
+ this.copyOf = build;
+ }
+
+ @Override
+ public Optional<AugmentationSchema> getOriginalDefinition() {
+ return Optional.fromNullable(this.copyOf);
+ }
+
+ @Override
+ public SchemaPath getTargetPath() {
+ return targetPath;
+ }
+
+ @Override
+ public RevisionAwareXPath getWhenCondition() {
+ return whenCondition;
+ }
+
+ @Override
+ public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+ return unknownNodes;
+ }
+
+ @Override
+ public URI getNamespace() {
+ return namespace;
+ }
+
+ @Override
+ public Date getRevision() {
+ return revision;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 17;
+ int result = 1;
+ result = prime * result
+ + ((targetPath == null) ? 0 : targetPath.hashCode());
+ result = prime * result
+ + ((whenCondition == null) ? 0 : whenCondition.hashCode());
+ result = prime * result + getChildNodes().hashCode();
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ AugmentEffectiveStatementImpl other = (AugmentEffectiveStatementImpl) obj;
+ if (targetPath == null) {
+ if (other.targetPath != null) {
+ return false;
+ }
+ } else if (!targetPath.equals(other.targetPath)) {
+ return false;
+ }
+ if (whenCondition == null) {
+ if (other.whenCondition != null) {
+ return false;
+ }
+ } else if (!whenCondition.equals(other.whenCondition)) {
+ return false;
+ }
+ if (!getChildNodes().equals(other.getChildNodes())) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(
+ AugmentEffectiveStatementImpl.class.getSimpleName());
+ sb.append("[");
+ sb.append("targetPath=").append(targetPath);
+ sb.append(", when=").append(whenCondition);
+ sb.append("]");
+ return sb.toString();
+ }
+
+ @Override
+ public int compareTo(final AugmentEffectiveStatementImpl o) {
+ checkNotNull(o);
+ Iterator<QName> thisIt = this.targetPath.getPathFromRoot().iterator();
+ Iterator<QName> otherIt = o.getTargetPath().getPathFromRoot()
+ .iterator();
+ while (thisIt.hasNext()) {
+ if (otherIt.hasNext()) {
+ int comp = thisIt.next().compareTo(otherIt.next());
+ if (comp != 0) {
+ return comp;
+ }
+ } else {
+ return 1;
+ }
+ }
+ if (otherIt.hasNext()) {
+ return -1;
+ }
+ return this.order - o.order;
+ }
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.stmt.BaseStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class BaseEffectiveStatementImpl extends
+ EffectiveStatementBase<QName, BaseStatement> {
+
+ public BaseEffectiveStatementImpl(StmtContext<QName, BaseStatement, ?> ctx) {
+ super(ctx);
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class BelongsEffectiveToStatementImpl extends
+ EffectiveStatementBase<String, BelongsToStatement> {
+
+ public BelongsEffectiveToStatementImpl(
+ StmtContext<String, BelongsToStatement, ?> ctx) {
+ super(ctx);
+ }
+
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.BitStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class BitEffectiveStatementImpl extends
+ EffectiveStatementBase<String, BitStatement> {
+
+ public BitEffectiveStatementImpl(StmtContext<String, BitStatement, ?> ctx) {
+ super(ctx);
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.CaseStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import java.util.Set;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
+import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
+import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+
+public class CaseEffectiveStatementImpl extends
+ AbstractEffectiveDocumentedDataNodeContainer<QName, CaseStatement>
+ implements ChoiceCaseNode, DerivableSchemaNode {
+ private final QName qname;
+ private final SchemaPath path;
+
+ boolean augmenting;
+ boolean addedByUses;
+ ChoiceCaseNode original;
+ ConstraintDefinition constraints;
+
+ ImmutableSet<AugmentationSchema> augmentations;
+ ImmutableList<UnknownSchemaNode> unknownNodes;
+
+ public CaseEffectiveStatementImpl(
+ StmtContext<QName, CaseStatement, EffectiveStatement<QName, CaseStatement>> ctx) {
+ super(ctx);
+ this.qname = ctx.getStatementArgument();
+ this.path = Utils.getSchemaPath(ctx);
+ // :TODO init other fields
+
+ initSubstatementCollections();
+ }
+
+ private void initSubstatementCollections() {
+ Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
+
+ LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
+ HashSet<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
+
+ for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
+ if (effectiveStatement instanceof UnknownSchemaNode) {
+ UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
+ unknownNodes.add(unknownNode);
+ }
+ if (effectiveStatement instanceof AugmentationSchema) {
+ AugmentationSchema augmentationSchema = (AugmentationSchema) effectiveStatement;
+ augmentations.add(augmentationSchema);
+ }
+ }
+
+ this.unknownNodes = ImmutableList.copyOf(unknownNodes);
+ this.augmentations = ImmutableSet.copyOf(augmentations);
+ }
+
+ @Override
+ public QName getQName() {
+ return qname;
+ }
+
+ @Override
+ public SchemaPath getPath() {
+ return path;
+ }
+
+ @Override
+ public boolean isConfiguration() {
+ return false;
+ }
+
+ @Override
+ public ConstraintDefinition getConstraints() {
+ return constraints;
+ }
+
+ @Override
+ public boolean isAugmenting() {
+ return augmenting;
+ }
+
+ @Override
+ public boolean isAddedByUses() {
+ return addedByUses;
+ }
+
+ @Override
+ public Optional<ChoiceCaseNode> getOriginal() {
+ return Optional.fromNullable(original);
+ }
+
+ @Override
+ public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+ return unknownNodes;
+ }
+
+ @Override
+ public Set<AugmentationSchema> getAvailableAugmentations() {
+ return augmentations;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+ result = prime * result + ((path == null) ? 0 : path.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ CaseEffectiveStatementImpl other = (CaseEffectiveStatementImpl) obj;
+ if (qname == null) {
+ if (other.qname != null) {
+ return false;
+ }
+ } else if (!qname.equals(other.qname)) {
+ return false;
+ }
+ if (path == null) {
+ if (other.path != null) {
+ return false;
+ }
+ } else if (!path.equals(other.path)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(
+ CaseEffectiveStatementImpl.class.getSimpleName());
+ sb.append("[");
+ sb.append("qname=");
+ sb.append(qname);
+ sb.append("]");
+ return sb.toString();
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ChoiceStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import java.util.Set;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
+import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
+import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+
+public class ChoiceEffectiveStatementImpl extends AbstractEffectiveDocumentedNode<QName, ChoiceStatement> implements ChoiceSchemaNode, DerivableSchemaNode {
+ private final QName qname;
+ private final SchemaPath path;
+
+ boolean augmenting;
+ boolean addedByUses;
+ ChoiceSchemaNode original;
+ boolean configuration;
+ ConstraintDefinition constraints;
+ String defaultCase;
+
+ ImmutableSet<ChoiceCaseNode> cases;
+ ImmutableSet<AugmentationSchema> augmentations;
+ ImmutableList<UnknownSchemaNode> unknownNodes;
+
+ public ChoiceEffectiveStatementImpl(StmtContext<QName, ChoiceStatement, EffectiveStatement<QName, ChoiceStatement>> ctx) {
+ super(ctx);
+
+ this.qname = ctx.getStatementArgument();
+ this.path = Utils.getSchemaPath(ctx);
+ //:TODO init other fields
+
+ initSubstatementCollections();
+
+ }
+
+ private void initSubstatementCollections() {
+ Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
+
+ LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
+ HashSet<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
+ HashSet<ChoiceCaseNode> cases = new HashSet<ChoiceCaseNode>();
+
+ for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
+ if (effectiveStatement instanceof UnknownSchemaNode) {
+ UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
+ unknownNodes.add(unknownNode);
+ }
+ if (effectiveStatement instanceof AugmentationSchema) {
+ AugmentationSchema augmentationSchema = (AugmentationSchema) effectiveStatement;
+ augmentations.add(augmentationSchema);
+ }
+ if (effectiveStatement instanceof ChoiceCaseNode) {
+ ChoiceCaseNode choiceCaseNode = (ChoiceCaseNode) effectiveStatement;
+ cases.add(choiceCaseNode);
+ }
+ }
+
+ this.unknownNodes = ImmutableList.copyOf(unknownNodes);
+ this.augmentations = ImmutableSet.copyOf(augmentations);
+ this.cases = ImmutableSet.copyOf(cases);
+ }
+
+ @Override
+ public QName getQName() {
+ return qname;
+ }
+
+ @Override
+ public SchemaPath getPath() {
+ return path;
+ }
+
+ @Override
+ public boolean isAugmenting() {
+ return augmenting;
+ }
+
+ @Override
+ public boolean isAddedByUses() {
+ return addedByUses;
+ }
+
+ @Override
+ public Optional<ChoiceSchemaNode> getOriginal() {
+ return Optional.fromNullable(original);
+ }
+
+ @Override
+ public boolean isConfiguration() {
+ return configuration;
+ }
+
+ @Override
+ public ConstraintDefinition getConstraints() {
+ return constraints;
+ }
+
+ @Override
+ public Set<AugmentationSchema> getAvailableAugmentations() {
+ return augmentations;
+ }
+
+ @Override
+ public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+ return unknownNodes;
+ }
+
+ @Override
+ public Set<ChoiceCaseNode> getCases() {
+ return cases;
+ }
+
+ @Override
+ public ChoiceCaseNode getCaseNodeByName(final QName name) {
+ if (name == null) {
+ throw new IllegalArgumentException("Choice Case QName cannot be NULL!");
+ }
+ for (final ChoiceCaseNode caseNode : cases) {
+ if (caseNode != null && name.equals(caseNode.getQName())) {
+ return caseNode;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public ChoiceCaseNode getCaseNodeByName(final String name) {
+ if (name == null) {
+ throw new IllegalArgumentException("Choice Case string Name cannot be NULL!");
+ }
+ for (final ChoiceCaseNode caseNode : cases) {
+ if (caseNode != null && (caseNode.getQName() != null)
+ && name.equals(caseNode.getQName().getLocalName())) {
+ return caseNode;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public String getDefaultCase() {
+ return defaultCase;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+ result = prime * result + ((path == null) ? 0 : path.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ ChoiceEffectiveStatementImpl other = (ChoiceEffectiveStatementImpl) obj;
+ if (qname == null) {
+ if (other.qname != null) {
+ return false;
+ }
+ } else if (!qname.equals(other.qname)) {
+ return false;
+ }
+ if (path == null) {
+ if (other.path != null) {
+ return false;
+ }
+ } else if (!path.equals(other.path)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(ChoiceEffectiveStatementImpl.class.getSimpleName());
+ sb.append("[");
+ sb.append("qname=").append(qname);
+ sb.append("]");
+ return sb.toString();
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class ConfigEffectiveStatementImpl extends
+ EffectiveStatementBase<Boolean, ConfigStatement> {
+
+ public ConfigEffectiveStatementImpl(
+ StmtContext<Boolean, ConfigStatement, ?> ctx) {
+ super(ctx);
+
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.ContactStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class ContactEffectiveStatementImpl extends
+ EffectiveStatementBase<String, ContactStatement> {
+
+ public ContactEffectiveStatementImpl(
+ StmtContext<String, ContactStatement, ?> ctx) {
+ super(ctx);
+
+ }
+}
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
-import java.util.HashSet;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableList;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
+import java.util.HashSet;
import java.util.LinkedList;
import java.util.Collection;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
implements ContainerSchemaNode, DerivableSchemaNode {
private final QName qname;
private final SchemaPath path;
+ private final boolean presence;
boolean augmenting;
boolean addedByUses;
ContainerSchemaNode original;
ConstraintDefinition constraints;
- boolean presence;
-
- private Set<AugmentationSchema> augmentations;
- private List<UnknownSchemaNode> unknownNodes;
+ private ImmutableSet<AugmentationSchema> augmentations;
+ private ImmutableList<UnknownSchemaNode> unknownNodes;
public ContainerEffectiveStatementImpl(
StmtContext<QName, ContainerStatement, EffectiveStatement<QName, ContainerStatement>> ctx) {
super(ctx);
- qname = ctx.getStatementArgument();
-
- initSubstatementCollections();
- initPresence();
-
- // :TODO init other fields
- path = null;
-
- }
- private void initPresence() {
+ qname = ctx.getStatementArgument();
+ path = Utils.getSchemaPath(ctx);
presence = (firstEffective(PresenceEffectiveStatementImpl.class) == null) ? false
: true;
+ // :TODO init other fields
+
+ initSubstatementCollections();
}
private void initSubstatementCollections() {
Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
- unknownNodes = new LinkedList<UnknownSchemaNode>();
- augmentations = new HashSet<AugmentationSchema>();
+ LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
+ HashSet<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
if (effectiveStatement instanceof UnknownSchemaNode) {
}
}
- // :TODO other substatement collections ...
+ this.unknownNodes = ImmutableList.copyOf(unknownNodes);
+ this.augmentations = ImmutableSet.copyOf(augmentations);
}
@Override
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.DefaultStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class DefaultEffectiveStatementImpl extends
+ EffectiveStatementBase<String, DefaultStatement> {
+
+ public DefaultEffectiveStatementImpl(
+ StmtContext<String, DefaultStatement, ?> ctx) {
+ super(ctx);
+ }
+
+}
\ No newline at end of file
import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
-public class DescriptionEffectiveStatementImpl extends EffectiveStatementBase<String, DescriptionStatement> {
+public class DescriptionEffectiveStatementImpl extends
+ EffectiveStatementBase<String, DescriptionStatement> {
public DescriptionEffectiveStatementImpl(
StmtContext<String, DescriptionStatement, ?> ctx) {
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.DeviateStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class DeviateEffectiveStatementImpl extends
+ EffectiveStatementBase<String, DeviateStatement> {
+ public DeviateEffectiveStatementImpl(
+ StmtContext<String, DeviateStatement, ?> ctx) {
+ super(ctx);
+ }
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.DeviationStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class DeviationEffectiveStatementImpl extends
+ EffectiveStatementBase<SchemaNodeIdentifier, DeviationStatement> {
+
+ public DeviationEffectiveStatementImpl(
+ StmtContext<SchemaNodeIdentifier, DeviationStatement, ?> ctx) {
+ super(ctx);
+
+ }
+
+}
\ No newline at end of file
public class EffectiveSchemaContext extends AbstractEffectiveSchemaContext {
- private final Map<ModuleIdentifier, String> identifiersToSources;
- private final SetMultimap<URI, Module> namespaceToModules;
- private final SetMultimap<String, Module> nameToModules;
- private final Set<Module> modules;
-
+ private final Map<ModuleIdentifier, String> identifiersToSources;
+ private final SetMultimap<URI, Module> namespaceToModules;
+ private final SetMultimap<String, Module> nameToModules;
+ private final Set<Module> modules;
private final ImmutableList<DeclaredStatement<?>> rootDeclaredStatements;
- private final ImmutableList<EffectiveStatement<?,?>> rootEffectiveStatements;
+ private final ImmutableList<EffectiveStatement<?, ?>> rootEffectiveStatements;
- public EffectiveSchemaContext(List<DeclaredStatement<?>> rootDeclaredStatements, List<EffectiveStatement<?,?>> rootEffectiveStatements) {
- this.rootDeclaredStatements = ImmutableList.copyOf(rootDeclaredStatements);
- this.rootEffectiveStatements = ImmutableList.copyOf(rootEffectiveStatements);
+ public EffectiveSchemaContext(
+ List<DeclaredStatement<?>> rootDeclaredStatements,
+ List<EffectiveStatement<?, ?>> rootEffectiveStatements) {
+ this.rootDeclaredStatements = ImmutableList
+ .copyOf(rootDeclaredStatements);
+ this.rootEffectiveStatements = ImmutableList
+ .copyOf(rootEffectiveStatements);
HashSet<Module> modules = new HashSet<Module>();
for (EffectiveStatement<?, ?> rootEffectiveStatement : rootEffectiveStatements) {
- if(rootEffectiveStatement instanceof Module) {
+ if (rootEffectiveStatement instanceof Module) {
Module module = (Module) rootEffectiveStatement;
modules.add(module);
}
}
this.modules = ImmutableSet.copyOf(modules);
- final SetMultimap<URI, Module> nsMap = Multimaps.newSetMultimap(
- new TreeMap<URI, Collection<Module>>(), MODULE_SET_SUPPLIER);
- final SetMultimap<String, Module> nameMap = Multimaps.newSetMultimap(
- new TreeMap<String, Collection<Module>>(), MODULE_SET_SUPPLIER);
+ final SetMultimap<URI, Module> nsMap = Multimaps.newSetMultimap(
+ new TreeMap<URI, Collection<Module>>(), MODULE_SET_SUPPLIER);
+ final SetMultimap<String, Module> nameMap = Multimaps.newSetMultimap(
+ new TreeMap<String, Collection<Module>>(), MODULE_SET_SUPPLIER);
- for (Module m : modules) {
- nameMap.put(m.getName(), m);
- nsMap.put(m.getNamespace(), m);
- }
+ for (Module m : modules) {
+ nameMap.put(m.getName(), m);
+ nsMap.put(m.getNamespace(), m);
+ }
- namespaceToModules = ImmutableSetMultimap.copyOf(nsMap);
- nameToModules = ImmutableSetMultimap.copyOf(nameMap);
+ namespaceToModules = ImmutableSetMultimap.copyOf(nsMap);
+ nameToModules = ImmutableSetMultimap.copyOf(nameMap);
- //:TODO
- //this.identifiersToSources = ImmutableMap.copyOf(identifiersToSources);
- this.identifiersToSources = null;
+ // :TODO
+ // this.identifiersToSources =
+ // ImmutableMap.copyOf(identifiersToSources);
+ this.identifiersToSources = null;
}
return rootDeclaredStatements;
}
- public ImmutableList<EffectiveStatement<?,?>> getRootEffectiveStatements() {
+ public ImmutableList<EffectiveStatement<?, ?>> getRootEffectiveStatements() {
return rootEffectiveStatements;
}
@Override
- protected Map<ModuleIdentifier, String> getIdentifiersToSources(){
+ protected Map<ModuleIdentifier, String> getIdentifiersToSources() {
return identifiersToSources;
}
@Override
- public Set<Module> getModules(){
+ public Set<Module> getModules() {
return modules;
}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.EnumStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class EnumEffectiveStatementImpl extends
+ EffectiveStatementBase<String, EnumStatement> {
+
+ public EnumEffectiveStatementImpl(StmtContext<String, EnumStatement, ?> ctx) {
+ super(ctx);
+
+ }
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.ErrorAppTagStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class ErrorAppTagEffectiveStatementImpl extends
+ EffectiveStatementBase<String, ErrorAppTagStatement> {
+
+ public ErrorAppTagEffectiveStatementImpl(
+ StmtContext<String, ErrorAppTagStatement, ?> ctx) {
+ super(ctx);
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.ErrorMessageStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class ErrorMessageEffectiveStatementImpl extends
+ EffectiveStatementBase<String, ErrorMessageStatement> {
+
+ public ErrorMessageEffectiveStatementImpl(
+ StmtContext<String, ErrorMessageStatement, ?> ctx) {
+ super(ctx);
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ExtensionStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import com.google.common.collect.ImmutableList;
+import java.util.List;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+
+public class ExtensionEffectiveStatementImpl extends
+ AbstractEffectiveDocumentedNode<QName, ExtensionStatement> implements
+ ExtensionDefinition {
+ private final QName qname;
+ String argument;
+ private final SchemaPath schemaPath;
+
+ ImmutableList<UnknownSchemaNode> unknownNodes;
+ boolean yin;
+
+ public ExtensionEffectiveStatementImpl(
+ StmtContext<QName, ExtensionStatement, EffectiveStatement<QName, ExtensionStatement>> ctx) {
+ super(ctx);
+
+ this.qname = ctx.getStatementArgument();
+ this.schemaPath = Utils.getSchemaPath(ctx);
+
+ initSubstatementCollections();
+ initFields();
+
+ }
+
+ private void initFields() {
+
+ ArgumentEffectiveStatementImpl argumentSubstatement = firstEffective(ArgumentEffectiveStatementImpl.class);
+
+ if (argumentSubstatement != null) {
+ this.argument = argumentSubstatement.argument().getLocalName();
+ }
+
+ YinElementEffectiveStatementImpl yinElement = firstEffective(YinElementEffectiveStatementImpl.class);
+
+ if (yinElement != null) {
+ this.yin = yinElement.argument();
+ } else
+ yin = false;
+
+ }
+
+ private void initSubstatementCollections() {
+ Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
+
+ LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
+
+ for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
+ if (effectiveStatement instanceof UnknownSchemaNode) {
+ UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
+ unknownNodes.add(unknownNode);
+ }
+ }
+
+ this.unknownNodes = ImmutableList.copyOf(unknownNodes);
+ }
+
+ @Override
+ public QName getQName() {
+ return qname;
+ }
+
+ @Override
+ public SchemaPath getPath() {
+ return schemaPath;
+ }
+
+ @Override
+ public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+ return unknownNodes;
+ }
+
+ @Override
+ public String getArgument() {
+ return argument;
+ }
+
+ @Override
+ public boolean isYinElement() {
+ return yin;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+ result = prime * result
+ + ((schemaPath == null) ? 0 : schemaPath.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ ExtensionEffectiveStatementImpl other = (ExtensionEffectiveStatementImpl) obj;
+ if (qname == null) {
+ if (other.qname != null) {
+ return false;
+ }
+ } else if (!qname.equals(other.qname)) {
+ return false;
+ }
+ if (schemaPath == null) {
+ if (other.schemaPath != null) {
+ return false;
+ }
+ } else if (!schemaPath.equals(other.schemaPath)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(
+ ExtensionEffectiveStatementImpl.class.getSimpleName());
+ sb.append("[");
+ sb.append("argument=").append(argument);
+ sb.append(", qname=").append(qname);
+ sb.append(", schemaPath=").append(schemaPath);
+ sb.append(", extensionSchemaNodes=").append(unknownNodes);
+ sb.append(", yin=").append(yin);
+ sb.append("]");
+ return sb.toString();
+ }
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.stmt.FeatureStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class FeatureEffectiveStatementImpl extends
+ EffectiveStatementBase<QName, FeatureStatement> {
+
+ public FeatureEffectiveStatementImpl(
+ StmtContext<QName, FeatureStatement, ?> ctx) {
+ super(ctx);
+
+ }
+
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.FractionDigitsStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class FractionDigitsEffectiveStatementImpl extends
+ EffectiveStatementBase<String, FractionDigitsStatement> {
+
+ public FractionDigitsEffectiveStatementImpl(
+ StmtContext<String, FractionDigitsStatement, ?> ctx) {
+ super(ctx);
+
+ }
+
+}
\ No newline at end of file
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
+
import java.util.Collection;
import java.util.LinkedList;
import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
super(ctx);
qname = ctx.getStatementArgument();
+ path = Utils.getSchemaPath(ctx);
// :TODO init other fields
- path = null;
initSubstatementCollections();
}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import java.util.Collection;
+import java.util.LinkedList;
+
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.IdentityStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import com.google.common.collect.ImmutableList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+
+public class IdentityEffectiveStatementImpl extends
+ AbstractEffectiveDocumentedNode<QName, IdentityStatement> implements
+ IdentitySchemaNode {
+ private final QName qname;
+ private final SchemaPath path;
+ IdentitySchemaNode baseIdentity;
+ private final Set<IdentitySchemaNode> derivedIdentities;
+
+ ImmutableList<UnknownSchemaNode> unknownNodes;
+
+ public IdentityEffectiveStatementImpl(
+ StmtContext<QName, IdentityStatement, EffectiveStatement<QName, IdentityStatement>> ctx) {
+ super(ctx);
+
+ this.qname = ctx.getStatementArgument();
+ this.path = Utils.getSchemaPath(ctx);
+
+ initSubstatementCollections();
+
+ // :TODO init other fields
+ this.derivedIdentities = null;
+ }
+
+ private void initSubstatementCollections() {
+ Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
+
+ LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
+
+ for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
+ if (effectiveStatement instanceof UnknownSchemaNode) {
+ UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
+ unknownNodes.add(unknownNode);
+ }
+ }
+
+ this.unknownNodes = ImmutableList.copyOf(unknownNodes);
+ }
+
+ @Override
+ public QName getQName() {
+ return qname;
+ }
+
+ @Override
+ public IdentitySchemaNode getBaseIdentity() {
+ return baseIdentity;
+ }
+
+ @Override
+ public Set<IdentitySchemaNode> getDerivedIdentities() {
+ return Collections.unmodifiableSet(derivedIdentities);
+ }
+
+ @Override
+ public SchemaPath getPath() {
+ return path;
+ }
+
+ @Override
+ public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+ return unknownNodes;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+ result = prime * result + ((path == null) ? 0 : path.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ IdentityEffectiveStatementImpl other = (IdentityEffectiveStatementImpl) obj;
+ if (qname == null) {
+ if (other.qname != null) {
+ return false;
+ }
+ } else if (!qname.equals(other.qname)) {
+ return false;
+ }
+ if (path == null) {
+ if (other.path != null) {
+ return false;
+ }
+ } else if (!path.equals(other.path)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(
+ IdentityEffectiveStatementImpl.class.getSimpleName());
+ sb.append("[");
+ sb.append("base=").append(baseIdentity);
+ sb.append(", qname=").append(qname);
+ sb.append("]");
+ return sb.toString();
+ }
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class IfFeatureEffectiveStatementImpl extends
+ EffectiveStatementBase<QName, IfFeatureStatement> {
+
+ public IfFeatureEffectiveStatementImpl(
+ StmtContext<QName, IfFeatureStatement, ?> ctx) {
+ super(ctx);
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.ImportStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class ImportEffectiveStatementImpl extends
+ EffectiveStatementBase<String, ImportStatement> {
+
+ public ImportEffectiveStatementImpl(
+ StmtContext<String, ImportStatement, ?> ctx) {
+ super(ctx);
+ }
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.IncludeStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class IncludeEffectiveStatementImpl extends
+ EffectiveStatementBase<String, IncludeStatement> {
+
+ public IncludeEffectiveStatementImpl(
+ StmtContext<String, IncludeStatement, ?> ctx) {
+ super(ctx);
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import java.util.Set;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import java.util.Collection;
+import org.opendaylight.yangtools.yang.model.api.stmt.InputStatement;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class InputEffectiveStatementImpl extends
+ AbstractEffectiveDocumentedDataNodeContainer<QName, InputStatement>
+ implements ContainerSchemaNode {
+
+ private final QName qname;
+ private final SchemaPath path;
+ private final boolean presence;
+
+ boolean augmenting;
+ boolean addedByUses;
+ boolean configuration;
+ ContainerSchemaNode original;
+ ConstraintDefinition constraints;
+
+ private ImmutableSet<AugmentationSchema> augmentations;
+ private ImmutableList<UnknownSchemaNode> unknownNodes;
+
+ public InputEffectiveStatementImpl(
+ StmtContext<QName, InputStatement, EffectiveStatement<QName, InputStatement>> ctx) {
+ super(ctx);
+
+ qname = ctx.getStatementArgument();
+ path = Utils.getSchemaPath(ctx);
+ presence = (firstEffective(PresenceEffectiveStatementImpl.class) == null) ? false
+ : true;
+ // :TODO init other fields
+
+ initSubstatementCollections();
+ }
+
+ private void initSubstatementCollections() {
+ Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
+
+ LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
+ HashSet<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
+
+ for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
+ if (effectiveStatement instanceof UnknownSchemaNode) {
+ UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
+ unknownNodes.add(unknownNode);
+ }
+ if (effectiveStatement instanceof AugmentationSchema) {
+ AugmentationSchema augmentationSchema = (AugmentationSchema) effectiveStatement;
+ augmentations.add(augmentationSchema);
+ }
+ }
+
+ this.unknownNodes = ImmutableList.copyOf(unknownNodes);
+ this.augmentations = ImmutableSet.copyOf(augmentations);
+ }
+
+ @Override
+ public QName getQName() {
+ return qname;
+ }
+
+ @Override
+ public SchemaPath getPath() {
+ return path;
+ }
+
+ @Override
+ public boolean isAugmenting() {
+ return augmenting;
+ }
+
+ @Override
+ public boolean isAddedByUses() {
+ return addedByUses;
+ }
+
+ @Override
+ public boolean isConfiguration() {
+ return configuration;
+ }
+
+ @Override
+ public ConstraintDefinition getConstraints() {
+ return constraints;
+ }
+
+ @Override
+ public Set<AugmentationSchema> getAvailableAugmentations() {
+ return augmentations;
+ }
+
+ @Override
+ public boolean isPresenceContainer() {
+ return presence;
+ }
+
+ @Override
+ public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+ return unknownNodes;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+ result = prime * result + ((path == null) ? 0 : path.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ InputEffectiveStatementImpl other = (InputEffectiveStatementImpl) obj;
+ if (qname == null) {
+ if (other.qname != null) {
+ return false;
+ }
+ } else if (!qname.equals(other.qname)) {
+ return false;
+ }
+ if (path == null) {
+ if (other.path != null) {
+ return false;
+ }
+ } else if (!path.equals(other.path)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "RPC input " + qname.getLocalName();
+ }
+
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import java.util.Collection;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.KeyStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class KeyEffectiveStatementImpl extends
+ EffectiveStatementBase<Collection<SchemaNodeIdentifier>, KeyStatement> {
+
+ public KeyEffectiveStatementImpl(
+ StmtContext<Collection<SchemaNodeIdentifier>, KeyStatement, ?> ctx) {
+ super(ctx);
+ }
+
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import java.util.Collection;
+import java.util.LinkedList;
+
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.model.api.stmt.LeafStatement;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
+import java.util.List;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
+import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+
+public class LeafEffectiveStatementImpl extends
+ AbstractEffectiveDocumentedNode<QName, LeafStatement> implements
+ LeafSchemaNode, DerivableSchemaNode {
+ private final QName qname;
+ private final SchemaPath path;
+
+ boolean augmenting;
+ boolean addedByUses;
+ LeafSchemaNode original;
+ boolean configuration;
+ ConstraintDefinition constraintsDef;
+ TypeDefinition<?> type;
+ String defaultStr;
+ String unitsStr;
+
+ private ImmutableList<UnknownSchemaNode> unknownNodes;
+
+ public LeafEffectiveStatementImpl(
+ StmtContext<QName, LeafStatement, EffectiveStatement<QName, LeafStatement>> ctx) {
+ super(ctx);
+ this.qname = ctx.getStatementArgument();
+ this.path = Utils.getSchemaPath(ctx);
+ // :TODO init other fields
+
+ initSubstatementCollections();
+ }
+
+ private void initSubstatementCollections() {
+ Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
+
+ LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
+
+ for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
+ if (effectiveStatement instanceof UnknownSchemaNode) {
+ UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
+ unknownNodes.add(unknownNode);
+ }
+ }
+
+ this.unknownNodes = ImmutableList.copyOf(unknownNodes);
+ }
+
+ @Override
+ public QName getQName() {
+ return qname;
+ }
+
+ @Override
+ public SchemaPath getPath() {
+ return path;
+ }
+
+ @Override
+ public boolean isAugmenting() {
+ return augmenting;
+ }
+
+ @Override
+ public boolean isAddedByUses() {
+ return addedByUses;
+ }
+
+ @Override
+ public Optional<LeafSchemaNode> getOriginal() {
+ return Optional.fromNullable(original);
+ }
+
+ @Override
+ public boolean isConfiguration() {
+ return configuration;
+ }
+
+ @Override
+ public ConstraintDefinition getConstraints() {
+ return constraintsDef;
+ }
+
+ @Override
+ public TypeDefinition<?> getType() {
+ return type;
+ }
+
+ @Override
+ public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+ return unknownNodes;
+ }
+
+ @Override
+ public String getDefault() {
+ return defaultStr;
+ }
+
+ @Override
+ public String getUnits() {
+ return unitsStr;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+ result = prime * result + ((path == null) ? 0 : path.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ LeafEffectiveStatementImpl other = (LeafEffectiveStatementImpl) obj;
+ if (qname == null) {
+ if (other.qname != null) {
+ return false;
+ }
+ } else if (!qname.equals(other.qname)) {
+ return false;
+ }
+ if (path == null) {
+ if (other.path != null) {
+ return false;
+ }
+ } else if (!path.equals(other.path)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(
+ LeafEffectiveStatementImpl.class.getSimpleName());
+ sb.append("[");
+ sb.append("qname=").append(qname);
+ sb.append(", path=").append(path);
+ sb.append("]");
+ return sb.toString();
+ }
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import java.util.Collection;
+import java.util.LinkedList;
+
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.model.api.stmt.LeafListStatement;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
+import java.util.List;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
+import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+
+public class LeafListEffectiveStatementImpl extends AbstractEffectiveDocumentedNode<QName, LeafListStatement> implements LeafListSchemaNode, DerivableSchemaNode {
+ private final QName qname;
+ private final SchemaPath path;
+
+ boolean augmenting;
+ boolean addedByUses;
+ LeafListSchemaNode original;
+ boolean configuration;
+ ConstraintDefinition constraintsDef;
+ TypeDefinition<?> type;
+ boolean userOrdered;
+
+ private ImmutableList<UnknownSchemaNode> unknownNodes;
+
+ public LeafListEffectiveStatementImpl(StmtContext<QName, LeafListStatement, EffectiveStatement<QName, LeafListStatement>> ctx) {
+ super(ctx);
+ this.qname = ctx.getStatementArgument();
+ this.path = Utils.getSchemaPath(ctx);
+ //:TODO init other fields
+
+ initSubstatementCollections();
+ }
+
+ private void initSubstatementCollections() {
+ Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
+
+ LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
+
+ for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
+ if (effectiveStatement instanceof UnknownSchemaNode) {
+ UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
+ unknownNodes.add(unknownNode);
+ }
+ }
+
+ this.unknownNodes = ImmutableList.copyOf(unknownNodes);
+ }
+
+ @Override
+ public QName getQName() {
+ return qname;
+ }
+
+ @Override
+ public SchemaPath getPath() {
+ return path;
+ }
+
+ @Override
+ public boolean isAugmenting() {
+ return augmenting;
+ }
+
+ @Override
+ public boolean isAddedByUses() {
+ return addedByUses;
+ }
+
+ @Override
+ public Optional<LeafListSchemaNode> getOriginal() {
+ return Optional.fromNullable(original);
+ }
+
+ @Override
+ public boolean isConfiguration() {
+ return configuration;
+ }
+
+ @Override
+ public ConstraintDefinition getConstraints() {
+ return constraintsDef;
+ }
+
+ @Override
+ public TypeDefinition<?> getType() {
+ return type;
+ }
+
+ @Override
+ public boolean isUserOrdered() {
+ return userOrdered;
+ }
+
+ @Override
+ public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+ return unknownNodes;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+ result = prime * result + ((path == null) ? 0 : path.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ LeafListEffectiveStatementImpl other = (LeafListEffectiveStatementImpl) obj;
+ if (qname == null) {
+ if (other.qname != null) {
+ return false;
+ }
+ } else if (!qname.equals(other.qname)) {
+ return false;
+ }
+ if (path == null) {
+ if (other.path != null) {
+ return false;
+ }
+ } else if (!path.equals(other.path)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(LeafListEffectiveStatementImpl.class.getSimpleName());
+ sb.append("[");
+ sb.append(qname);
+ sb.append("]");
+ return sb.toString();
+ }
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.LengthStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class LengthEffectiveStatementImpl extends
+ EffectiveStatementBase<String, LengthStatement> {
+
+ public LengthEffectiveStatementImpl(
+ StmtContext<String, LengthStatement, ?> ctx) {
+ super(ctx);
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.model.api.stmt.ListStatement;
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import java.util.Set;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
+import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+
+public class ListEffectiveStatementImpl extends
+ AbstractEffectiveDocumentedDataNodeContainer<QName, ListStatement>
+ implements ListSchemaNode, DerivableSchemaNode {
+ private final QName qname;
+ private final SchemaPath path;
+
+ boolean augmenting;
+ boolean addedByUses;
+ ListSchemaNode original;
+ boolean configuration;
+ ConstraintDefinition constraints;
+ boolean userOrdered;
+
+ ImmutableList<QName> keyDefinition;
+ ImmutableSet<AugmentationSchema> augmentations;
+ ImmutableList<UnknownSchemaNode> unknownNodes;
+
+ public ListEffectiveStatementImpl(
+ StmtContext<QName, ListStatement, EffectiveStatement<QName, ListStatement>> ctx) {
+ super(ctx);
+ this.qname = ctx.getStatementArgument();
+ this.path = Utils.getSchemaPath(ctx);
+ // :TODO init other fields
+
+ initKeyDefinition();
+ initSubstatementCollections();
+ }
+
+ /**
+ *
+ */
+ private void initKeyDefinition() {
+ List<QName> keyDefinition = new LinkedList<QName>();
+ KeyEffectiveStatementImpl key = firstEffective(KeyEffectiveStatementImpl.class);
+
+ if (key != null) {
+ Collection<SchemaNodeIdentifier> keyParts = key.argument();
+ for (SchemaNodeIdentifier keyPart : keyParts) {
+ keyDefinition.add(keyPart.getLastComponent());
+ }
+ }
+
+ this.keyDefinition = ImmutableList.copyOf(keyDefinition);
+ }
+
+ private void initSubstatementCollections() {
+ Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
+
+ LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
+ HashSet<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
+
+ for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
+ if (effectiveStatement instanceof UnknownSchemaNode) {
+ UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
+ unknownNodes.add(unknownNode);
+ }
+ if (effectiveStatement instanceof AugmentationSchema) {
+ AugmentationSchema augmentationSchema = (AugmentationSchema) effectiveStatement;
+ augmentations.add(augmentationSchema);
+ }
+ }
+
+ this.unknownNodes = ImmutableList.copyOf(unknownNodes);
+ this.augmentations = ImmutableSet.copyOf(augmentations);
+ }
+
+ @Override
+ public QName getQName() {
+ return qname;
+ }
+
+ @Override
+ public SchemaPath getPath() {
+ return path;
+ }
+
+ @Override
+ public List<QName> getKeyDefinition() {
+ return keyDefinition;
+ }
+
+ @Override
+ public boolean isAugmenting() {
+ return augmenting;
+ }
+
+ @Override
+ public boolean isAddedByUses() {
+ return addedByUses;
+ }
+
+ @Override
+ public Optional<ListSchemaNode> getOriginal() {
+ return Optional.fromNullable(original);
+ }
+
+ @Override
+ public boolean isConfiguration() {
+ return configuration;
+ }
+
+ @Override
+ public ConstraintDefinition getConstraints() {
+ return constraints;
+ }
+
+ @Override
+ public Set<AugmentationSchema> getAvailableAugmentations() {
+ return augmentations;
+ }
+
+ @Override
+ public boolean isUserOrdered() {
+ return userOrdered;
+ }
+
+ @Override
+ public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+ return unknownNodes;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+ result = prime * result + ((path == null) ? 0 : path.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final ListEffectiveStatementImpl other = (ListEffectiveStatementImpl) obj;
+ if (qname == null) {
+ if (other.qname != null) {
+ return false;
+ }
+ } else if (!qname.equals(other.qname)) {
+ return false;
+ }
+ if (path == null) {
+ if (other.path != null) {
+ return false;
+ }
+ } else if (!path.equals(other.path)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "list " + qname.getLocalName();
+ }
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class MandatoryEffectiveStatementImpl extends
+ EffectiveStatementBase<Boolean, MandatoryStatement> {
+
+ public MandatoryEffectiveStatementImpl(
+ StmtContext<Boolean, MandatoryStatement, ?> ctx) {
+ super(ctx);
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.MaxElementsStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class MaxElementsEffectiveStatementImpl extends
+ EffectiveStatementBase<String, MaxElementsStatement> {
+
+ public MaxElementsEffectiveStatementImpl(
+ StmtContext<String, MaxElementsStatement, ?> ctx) {
+ super(ctx);
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.MinElementsStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class MinElementsEffectiveStatementImpl extends
+ EffectiveStatementBase<String, MinElementsStatement> {
+
+ public MinElementsEffectiveStatementImpl(
+ StmtContext<String, MinElementsStatement, ?> ctx) {
+ super(ctx);
+
+ }
+
+}
\ No newline at end of file
*/
package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
-import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToModuleQName;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToModuleQName;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
AbstractEffectiveDocumentedDataNodeContainer<String, ModuleStatement>
implements Module, Immutable {
- private QNameModule qnameModule;
- private String name;
+ private final QNameModule qnameModule;
+ private final String name;
private String sourcePath;
private String prefix;
private String yangVersion;
private String organization;
private String contact;
- private Set<ModuleImport> imports;
- private Set<Module> submodules;
- private Set<FeatureDefinition> features;
- private Set<NotificationDefinition> notifications;
- private Set<AugmentationSchema> augmentations;
- private Set<RpcDefinition> rpcs;
- private Set<Deviation> deviations;
- private List<ExtensionDefinition> extensionNodes;
- private Set<IdentitySchemaNode> identities;
- private List<UnknownSchemaNode> unknownNodes;
+ private ImmutableSet<ModuleImport> imports;
+ private ImmutableSet<Module> submodules;
+ private ImmutableSet<FeatureDefinition> features;
+ private ImmutableSet<NotificationDefinition> notifications;
+ private ImmutableSet<AugmentationSchema> augmentations;
+ private ImmutableSet<RpcDefinition> rpcs;
+ private ImmutableSet<Deviation> deviations;
+ private ImmutableList<ExtensionDefinition> extensionNodes;
+ private ImmutableSet<IdentitySchemaNode> identities;
+ private ImmutableList<UnknownSchemaNode> unknownNodes;
private String source;
public ModuleEffectiveStatementImpl(
name = argument();
qnameModule = ctx.getFromNamespace(ModuleNameToModuleQName.class, name);
+ // :TODO init other fields
initSubstatementCollections();
- // :TODO init other fields
}
private void initSubstatementCollections() {
Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
- unknownNodes = new LinkedList<UnknownSchemaNode>();
- augmentations = new HashSet<AugmentationSchema>();
+ LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
+ HashSet<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
if (effectiveStatement instanceof UnknownSchemaNode) {
}
}
+ this.unknownNodes = ImmutableList.copyOf(unknownNodes);
+ this.augmentations = ImmutableSet.copyOf(augmentations);
+
// :TODO other substatement collections ...
}
--- /dev/null
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
+import org.opendaylight.yangtools.yang.model.api.stmt.MustStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class MustEffectiveStatementImpl extends
+ EffectiveStatementBase<RevisionAwareXPath, MustStatement> {
+
+ public MustEffectiveStatementImpl(
+ StmtContext<RevisionAwareXPath, MustStatement, ?> ctx) {
+ super(ctx);
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.NotificationStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import java.util.Set;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+
+public class NotificationEffectiveStatementImpl
+ extends
+ AbstractEffectiveDocumentedDataNodeContainer<QName, NotificationStatement>
+ implements NotificationDefinition {
+ private final QName qname;
+ private final SchemaPath path;
+ ImmutableSet<AugmentationSchema> augmentations;
+ ImmutableList<UnknownSchemaNode> unknownNodes;
+
+ public NotificationEffectiveStatementImpl(
+ StmtContext<QName, NotificationStatement, EffectiveStatement<QName, NotificationStatement>> ctx) {
+ super(ctx);
+ this.qname = ctx.getStatementArgument();
+ this.path = Utils.getSchemaPath(ctx);
+
+ initSubstatementCollections();
+ }
+
+ private void initSubstatementCollections() {
+ Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
+
+ LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
+ HashSet<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
+
+ for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
+ if (effectiveStatement instanceof UnknownSchemaNode) {
+ UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
+ unknownNodes.add(unknownNode);
+ }
+ if (effectiveStatement instanceof AugmentationSchema) {
+ AugmentationSchema augmentationSchema = (AugmentationSchema) effectiveStatement;
+ augmentations.add(augmentationSchema);
+ }
+ }
+
+ this.unknownNodes = ImmutableList.copyOf(unknownNodes);
+ this.augmentations = ImmutableSet.copyOf(augmentations);
+ }
+
+ @Override
+ public QName getQName() {
+ return qname;
+ }
+
+ @Override
+ public SchemaPath getPath() {
+ return path;
+ }
+
+ @Override
+ public Set<AugmentationSchema> getAvailableAugmentations() {
+ return augmentations;
+ }
+
+ @Override
+ public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+ return unknownNodes;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+ result = prime * result + ((path == null) ? 0 : path.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final NotificationEffectiveStatementImpl other = (NotificationEffectiveStatementImpl) obj;
+ if (qname == null) {
+ if (other.qname != null) {
+ return false;
+ }
+ } else if (!qname.equals(other.qname)) {
+ return false;
+ }
+ if (path == null) {
+ if (other.path != null) {
+ return false;
+ }
+ } else if (!path.equals(other.path)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(
+ NotificationEffectiveStatementImpl.class.getSimpleName());
+ sb.append("[qname=").append(qname).append(", path=").append(path)
+ .append("]");
+ return sb.toString();
+ }
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.OrderedByStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class OrderedByEffectiveStatementImpl extends
+ EffectiveStatementBase<String, OrderedByStatement> {
+
+ public OrderedByEffectiveStatementImpl(
+ StmtContext<String, OrderedByStatement, ?> ctx) {
+ super(ctx);
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.OrganizationStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class OrganizationEffectiveStatementImpl extends
+EffectiveStatementBase<String, OrganizationStatement> {
+
+ public OrganizationEffectiveStatementImpl(
+ StmtContext<String, OrganizationStatement, ?> ctx) {
+ super(ctx);
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import java.util.Set;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import java.util.Collection;
+import org.opendaylight.yangtools.yang.model.api.stmt.OutputStatement;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class OutputEffectiveStatementImpl extends
+ AbstractEffectiveDocumentedDataNodeContainer<QName, OutputStatement>
+ implements ContainerSchemaNode {
+
+ private final QName qname;
+ private final SchemaPath path;
+ private final boolean presence;
+
+ boolean augmenting;
+ boolean addedByUses;
+ boolean configuration;
+ ContainerSchemaNode original;
+ ConstraintDefinition constraints;
+
+ private ImmutableSet<AugmentationSchema> augmentations;
+ private ImmutableList<UnknownSchemaNode> unknownNodes;
+
+ public OutputEffectiveStatementImpl(
+ StmtContext<QName, OutputStatement, EffectiveStatement<QName, OutputStatement>> ctx) {
+ super(ctx);
+
+ qname = ctx.getStatementArgument();
+ path = Utils.getSchemaPath(ctx);
+ presence = (firstEffective(PresenceEffectiveStatementImpl.class) == null) ? false
+ : true;
+ // :TODO init other fields
+
+ initSubstatementCollections();
+ }
+
+ private void initSubstatementCollections() {
+ Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
+
+ LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
+ HashSet<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
+
+ for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
+ if (effectiveStatement instanceof UnknownSchemaNode) {
+ UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
+ unknownNodes.add(unknownNode);
+ }
+ if (effectiveStatement instanceof AugmentationSchema) {
+ AugmentationSchema augmentationSchema = (AugmentationSchema) effectiveStatement;
+ augmentations.add(augmentationSchema);
+ }
+ }
+
+ this.unknownNodes = ImmutableList.copyOf(unknownNodes);
+ this.augmentations = ImmutableSet.copyOf(augmentations);
+ }
+
+ @Override
+ public QName getQName() {
+ return qname;
+ }
+
+ @Override
+ public SchemaPath getPath() {
+ return path;
+ }
+
+ @Override
+ public boolean isAugmenting() {
+ return augmenting;
+ }
+
+ @Override
+ public boolean isAddedByUses() {
+ return addedByUses;
+ }
+
+ @Override
+ public boolean isConfiguration() {
+ return configuration;
+ }
+
+ @Override
+ public ConstraintDefinition getConstraints() {
+ return constraints;
+ }
+
+ @Override
+ public Set<AugmentationSchema> getAvailableAugmentations() {
+ return augmentations;
+ }
+
+ @Override
+ public boolean isPresenceContainer() {
+ return presence;
+ }
+
+ @Override
+ public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+ return unknownNodes;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+ result = prime * result + ((path == null) ? 0 : path.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ OutputEffectiveStatementImpl other = (OutputEffectiveStatementImpl) obj;
+ if (qname == null) {
+ if (other.qname != null) {
+ return false;
+ }
+ } else if (!qname.equals(other.qname)) {
+ return false;
+ }
+ if (path == null) {
+ if (other.path != null) {
+ return false;
+ }
+ } else if (!path.equals(other.path)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "RPC Output " + qname.getLocalName();
+ }
+
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.PatternStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class PatternEffectiveStatementImpl extends
+ EffectiveStatementBase<String, PatternStatement> {
+
+ public PatternEffectiveStatementImpl(
+ StmtContext<String, PatternStatement, ?> ctx) {
+ super(ctx);
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.PositionStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class PositionEffectiveStatementImpl extends
+ EffectiveStatementBase<String, PositionStatement> {
+
+ public PositionEffectiveStatementImpl(
+ StmtContext<String, PositionStatement, ?> ctx) {
+ super(ctx);
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.RangeStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class RangeEffectiveStatementImpl extends
+ EffectiveStatementBase<String, RangeStatement> {
+
+ public RangeEffectiveStatementImpl(
+ StmtContext<String, RangeStatement, ?> ctx) {
+ super(ctx);
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ * <p/>
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.RefineStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class RefineEffectiveStatementImpl extends
+ EffectiveStatementBase<SchemaNodeIdentifier, RefineStatement> {
+
+ public RefineEffectiveStatementImpl(
+ StmtContext<SchemaNodeIdentifier, RefineStatement, ?> ctx) {
+ super(ctx);
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.RequireInstanceStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class RequireInstanceEffectiveStatementImpl extends
+ EffectiveStatementBase<Boolean, RequireInstanceStatement> {
+
+ public RequireInstanceEffectiveStatementImpl(
+ StmtContext<Boolean, RequireInstanceStatement, ?> ctx) {
+ super(ctx);
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.RevisionDateStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class RevisionDateEffectiveStatementImpl extends
+ EffectiveStatementBase<String, RevisionDateStatement> {
+
+ public RevisionDateEffectiveStatementImpl(
+ StmtContext<String, RevisionDateStatement, ?> ctx) {
+ super(ctx);
+ }
+
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import java.util.Date;
+import org.opendaylight.yangtools.yang.model.api.stmt.RevisionStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class RevisionEffectiveStatementImpl extends
+ EffectiveStatementBase<Date, RevisionStatement> {
+
+ public RevisionEffectiveStatementImpl(
+ StmtContext<Date, RevisionStatement, ?> ctx) {
+ super(ctx);
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.model.api.stmt.RpcStatement;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import java.util.Set;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
+import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+
+public class RpcEffectiveStatementImpl extends AbstractEffectiveDocumentedNode<QName, RpcStatement> implements RpcDefinition {
+ private final QName qname;
+ private final SchemaPath path;
+
+ private ContainerSchemaNode input;
+ private ContainerSchemaNode output;
+
+ ImmutableSet<TypeDefinition<?>> typeDefinitions;
+ ImmutableSet<GroupingDefinition> groupings;
+ ImmutableList<UnknownSchemaNode> unknownNodes;
+
+ public RpcEffectiveStatementImpl(StmtContext<QName, RpcStatement, EffectiveStatement<QName, RpcStatement>> ctx) {
+ super(ctx);
+ this.qname = ctx.getStatementArgument();
+ this.path = Utils.getSchemaPath(ctx);
+
+ initSubstatements();
+
+ }
+
+ private void initSubstatements() {
+ Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
+
+ LinkedList<UnknownSchemaNode> unknownNodes = new LinkedList<UnknownSchemaNode>();
+ HashSet<GroupingDefinition> groupings = new HashSet<GroupingDefinition>();
+ HashSet<TypeDefinition<?>> typeDefinitions = new HashSet<TypeDefinition<?>>();
+
+ for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
+ if (effectiveStatement instanceof UnknownSchemaNode) {
+ UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
+ unknownNodes.add(unknownNode);
+ }
+ if (effectiveStatement instanceof GroupingDefinition) {
+ GroupingDefinition groupingDefinition = (GroupingDefinition) effectiveStatement;
+ groupings.add(groupingDefinition);
+ }
+ if (effectiveStatement instanceof TypeDefinition) {
+ TypeDefinition<?> typeDefinition = (TypeDefinition<?>) effectiveStatement;
+ typeDefinitions.add(typeDefinition);
+ }
+ if (this.input == null && effectiveStatement instanceof InputEffectiveStatementImpl) {
+ this.input = (InputEffectiveStatementImpl) effectiveStatement;
+ }
+ if (this.output == null && effectiveStatement instanceof OutputEffectiveStatementImpl) {
+ this.output = (OutputEffectiveStatementImpl) effectiveStatement;
+ }
+ }
+
+ this.unknownNodes = ImmutableList.copyOf(unknownNodes);
+ this.groupings = ImmutableSet.copyOf(groupings);
+ this.typeDefinitions = ImmutableSet.copyOf(typeDefinitions);
+ }
+
+ @Override
+ public QName getQName() {
+ return qname;
+ }
+
+ @Override
+ public SchemaPath getPath() {
+ return path;
+ }
+
+ @Override
+ public ContainerSchemaNode getInput() {
+ return input;
+ }
+
+ void setInput(final ContainerSchemaNode input) {
+ this.input = input;
+ }
+
+ @Override
+ public ContainerSchemaNode getOutput() {
+ return output;
+ }
+
+ void setOutput(final ContainerSchemaNode output) {
+ this.output = output;
+ }
+
+ @Override
+ public Set<TypeDefinition<?>> getTypeDefinitions() {
+ return typeDefinitions;
+ }
+
+ @Override
+ public Set<GroupingDefinition> getGroupings() {
+ return groupings;
+ }
+
+ @Override
+ public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+ return unknownNodes;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+ result = prime * result + ((path == null) ? 0 : path.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final RpcEffectiveStatementImpl other = (RpcEffectiveStatementImpl) obj;
+ if (qname == null) {
+ if (other.qname != null) {
+ return false;
+ }
+ } else if (!qname.equals(other.qname)) {
+ return false;
+ }
+ if (path == null) {
+ if (other.path != null) {
+ return false;
+ }
+ } else if (!path.equals(other.path)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(RpcEffectiveStatementImpl.class.getSimpleName());
+ sb.append("[");
+ sb.append("qname=");
+ sb.append(qname);
+ sb.append(", path=");
+ sb.append(path);
+ sb.append(", input=");
+ sb.append(input);
+ sb.append(", output=");
+ sb.append(output);
+ sb.append("]");
+ return sb.toString();
+ }
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class StatusEffectiveStatementImpl extends
+ EffectiveStatementBase<String, StatusStatement> {
+
+ public StatusEffectiveStatementImpl(
+ StmtContext<String, StatusStatement, ?> ctx) {
+ super(ctx);
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement;
+
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class SubmoduleEffectiveStatementImpl extends
+ ModuleEffectiveStatementImpl {
+
+ public SubmoduleEffectiveStatementImpl(
+ StmtContext<String, ModuleStatement, ?> ctx) {
+ super(ctx);
+
+ }
+
+}
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.UnitsStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class UnitsEffectiveStatementImpl extends
+ EffectiveStatementBase<String, UnitsStatement> {
+
+ public UnitsEffectiveStatementImpl(
+ StmtContext<String, UnitsStatement, ?> ctx) {
+ super(ctx);
+ }
+
+}
-/*
- * Copyright (c) 2013-2015 Cisco Systems, Inc. and others. All rights reserved.
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.ValueStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class ValueEffectiveStatementImpl extends
+ EffectiveStatementBase<String, ValueStatement> {
+
+ public ValueEffectiveStatementImpl(
+ StmtContext<String, ValueStatement, ?> ctx) {
+ super(ctx);
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
+import org.opendaylight.yangtools.yang.model.api.stmt.WhenStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class WhenEffectiveStatementImpl extends
+ EffectiveStatementBase<RevisionAwareXPath, WhenStatement> {
+
+ public WhenEffectiveStatementImpl(
+ StmtContext<RevisionAwareXPath, WhenStatement, ?> ctx) {
+ super(ctx);
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.YangVersionStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class YangVersionEffectiveStatementImpl extends
+ EffectiveStatementBase<String, YangVersionStatement> {
+
+ public YangVersionEffectiveStatementImpl(
+ StmtContext<String, YangVersionStatement, ?> ctx) {
+ super(ctx);
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.YinElementStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class YinElementEffectiveStatementImpl extends
+ EffectiveStatementBase<Boolean, YinElementStatement> {
+
+ public YinElementEffectiveStatementImpl(
+ StmtContext<Boolean, YinElementStatement, ?> ctx) {
+ super(ctx);
+ }
+
+}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext;
-import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
-import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.Module;
+
import java.net.URI;
+
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.junit.Test;
import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext;
public class EffectiveBuildTest {
- private static final YangFileStatementSource SIMPLE_MODULE = new YangFileStatementSource("/stmt-test/effective-build/simple-module.yang");
+ private static final YangStatementSourceImpl SIMPLE_MODULE = new YangStatementSourceImpl(
+ "/stmt-test/effective-build/simple-module.yang");
private static final QNameModule SIMPLE_MODULE_QNAME = QNameModule.create(URI.create("simple.yang"), null);
@Test
assertNotNull(result);
- Module simpleModule = result.findModuleByName("simple-module",null);
+ Module simpleModule = result.findModuleByName("simple-module", null);
assertNotNull(simpleModule);
QName q1 = QName.create(SIMPLE_MODULE_QNAME, "root-container");
QName q6 = QName.create(SIMPLE_MODULE_QNAME, "sub-sub-container2");
QName q7 = QName.create(SIMPLE_MODULE_QNAME, "grp");
- ContainerSchemaNode rootCon = (ContainerSchemaNode)simpleModule.getDataChildByName(q1);
+ ContainerSchemaNode rootCon = (ContainerSchemaNode) simpleModule.getDataChildByName(q1);
assertNotNull(rootCon);
- ContainerSchemaNode subCon = (ContainerSchemaNode)rootCon.getDataChildByName(q2);
+ ContainerSchemaNode subCon = (ContainerSchemaNode) rootCon.getDataChildByName(q2);
assertNotNull(subCon);
- ContainerSchemaNode subSubCon = (ContainerSchemaNode)subCon.getDataChildByName(q3);
+ ContainerSchemaNode subSubCon = (ContainerSchemaNode) subCon.getDataChildByName(q3);
assertNotNull(subSubCon);
- ContainerSchemaNode rootCon2 = (ContainerSchemaNode)simpleModule.getDataChildByName(q4);
+ ContainerSchemaNode rootCon2 = (ContainerSchemaNode) simpleModule.getDataChildByName(q4);
assertNotNull(rootCon2);
- ContainerSchemaNode subCon2 = (ContainerSchemaNode)rootCon2.getDataChildByName(q5);
+ ContainerSchemaNode subCon2 = (ContainerSchemaNode) rootCon2.getDataChildByName(q5);
assertNotNull(subCon2);
- ContainerSchemaNode subSubCon2 = (ContainerSchemaNode)subCon2.getDataChildByName(q6);
+ ContainerSchemaNode subSubCon2 = (ContainerSchemaNode) subCon2.getDataChildByName(q6);
assertNotNull(subSubCon2);
GroupingDefinition grp = simpleModule.getGroupings().iterator().next();
assertNotNull(grp);
- assertEquals(q7,grp.getQName());
+ assertEquals(q7, grp.getQName());
ContainerSchemaNode grpSubCon2 = (ContainerSchemaNode) grp.getDataChildByName(q5);
assertNotNull(grpSubCon2);
- ContainerSchemaNode grpSubSubCon2 = (ContainerSchemaNode)grpSubCon2.getDataChildByName(q6);
+ ContainerSchemaNode grpSubSubCon2 = (ContainerSchemaNode) grpSubCon2.getDataChildByName(q6);
assertNotNull(grpSubSubCon2);
+ assertEquals(SchemaPath.create(true, q1, q2, q3), subSubCon.getPath());
+ assertEquals(SchemaPath.create(true, q4, q5, q6), subSubCon2.getPath());
+ assertEquals(SchemaPath.create(true, q7, q5, q6), grpSubSubCon2.getPath());
+
}
private void log(Throwable e, String indent) {
}
- private void addSources(BuildAction reactor,
- YangFileStatementSource... sources) {
- for (YangFileStatementSource source : sources) {
+ private void addSources(BuildAction reactor, YangStatementSourceImpl... sources) {
+ for (YangStatementSourceImpl source : sources) {
reactor.addSource(source);
}
}
--- /dev/null
+package org.opendaylight.yangtools.yang.stmt.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext;
+
+import java.net.URI;
+
+public class AugmentProcessTest {
+
+ private static final YangStatementSourceImpl AUGMENTED = new YangStatementSourceImpl(
+ "/stmt-test/effective-build/augmented.yang");
+ private static final YangStatementSourceImpl ROOT = new YangStatementSourceImpl(
+ "/stmt-test/effective-build/aug-root.yang");
+
+ private static final QNameModule AUGMENTED_QNAME_MODULE = QNameModule.create(URI.create("aug"), null);
+
+ QName augParent1 = QName.create(AUGMENTED_QNAME_MODULE, "aug-parent1");
+ QName augParent2 = QName.create(AUGMENTED_QNAME_MODULE, "aug-parent2");
+ QName contTarget = QName.create(AUGMENTED_QNAME_MODULE, "cont-target");
+
+ QName contAdded1 = QName.create(AUGMENTED_QNAME_MODULE, "cont-added1");
+ QName contAdded2 = QName.create(AUGMENTED_QNAME_MODULE, "cont-added2");
+
+ QName list1 = QName.create(AUGMENTED_QNAME_MODULE, "list1");
+ QName axml = QName.create(AUGMENTED_QNAME_MODULE, "axml");
+
+ QName contGrp = QName.create(AUGMENTED_QNAME_MODULE, "cont-grp");
+ QName axmlGrp = QName.create(AUGMENTED_QNAME_MODULE, "axml-grp");
+
+ @Test
+ public void readAndParseYangFileTest() throws SourceException, ReactorException {
+
+ CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+ addSources(reactor, AUGMENTED, ROOT);
+
+ final EffectiveSchemaContext result = reactor.buildEffective();
+
+ assertNotNull(result);
+
+ Module augmentedModule = result.findModuleByName("augmented", null);
+ assertNotNull(augmentedModule);
+
+ ContainerSchemaNode augParent1Node = (ContainerSchemaNode) result.getDataChildByName(augParent1);
+ ContainerSchemaNode augParent2Node = (ContainerSchemaNode) augParent1Node.getDataChildByName(augParent2);
+ ContainerSchemaNode targetContNode = (ContainerSchemaNode) augParent2Node.getDataChildByName(contTarget);
+ assertNotNull(targetContNode);
+
+ assertNotNull(targetContNode.getChildNodes());
+ assertEquals(3, targetContNode.getChildNodes().size());
+
+ ContainerSchemaNode contAdded1Node = (ContainerSchemaNode) targetContNode.getDataChildByName(contAdded1);
+ assertNotNull(contAdded1Node);
+ ListSchemaNode list1Node = (ListSchemaNode) contAdded1Node.getDataChildByName(list1);
+ assertNotNull(list1Node);
+
+ ContainerSchemaNode contAdded2Node = (ContainerSchemaNode) targetContNode.getDataChildByName(contAdded2);
+ assertNotNull(contAdded2Node);
+ AnyXmlSchemaNode axmlNode = (AnyXmlSchemaNode) contAdded2Node.getDataChildByName(axml);
+ assertNotNull(axmlNode);
+
+ ContainerSchemaNode contGrpNode = (ContainerSchemaNode) targetContNode.getDataChildByName(contGrp);
+ assertNotNull(contGrpNode);
+ AnyXmlSchemaNode axmlGrpNode = (AnyXmlSchemaNode) contGrpNode.getDataChildByName(axmlGrp);
+ assertNotNull(axmlGrpNode);
+ }
+
+ private void addSources(CrossSourceStatementReactor.BuildAction reactor, StatementStreamSource... sources) {
+ for (StatementStreamSource source : sources) {
+ reactor.addSource(source);
+ }
+ }
+}
--- /dev/null
+package org.opendaylight.yangtools.yang.stmt.test;
+
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
+
+import static org.junit.Assert.assertNotNull;
+
+public class AugmentSimplestTest {
+
+ private static final TestYangFileStatementSource AUGMENTED = new TestYangFileStatementSource("/semantic-statement-parser/augmented.yang");
+ private static final TestYangFileStatementSource ROOT = new TestYangFileStatementSource("/semantic-statement-parser/root.yang");
+
+ @Test
+ public void readAndParseYangFileTest() throws SourceException, ReactorException {
+ CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+ addSources(reactor, AUGMENTED, ROOT);
+
+ EffectiveModelContext result = reactor.build();
+ assertNotNull(result);
+ }
+
+ private void addSources(CrossSourceStatementReactor.BuildAction reactor, StatementStreamSource... sources) {
+ for (StatementStreamSource source : sources) {
+ reactor.addSource(source);
+ }
+ }
+}
private static final YangStatementSourceImpl EXTUSE = new YangStatementSourceImpl("/semantic-statement-parser/ext-use.yang");
@Test
- public void readAndParseYangFileTest() throws SourceException, ReactorException {
+ public void readAndParseYangFileTest1() throws SourceException, ReactorException {
CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
addSources(reactor, YANGFILE, SIMPLENODES, IMPORTEDYANGFILE, FOO);
- addSources(reactor, FILE1, FILE2, FILE3, FILE4);
+ EffectiveModelContext result = reactor.build();
+ assertNotNull(result);
+ }
+
+ // TODO uncomment when Augment in Uses implemented
+// @Test
+// public void readAndParseYangFileTest2() throws SourceException, ReactorException {
+// CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+// addSources(reactor, FILE1, FILE2, FILE3, FILE4);
+// EffectiveModelContext result = reactor.build();
+// assertNotNull(result);
+// }
+
+ @Test
+ public void readAndParseYangFileTest3() throws SourceException, ReactorException {
+ CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
addSources(reactor, EXTFILE, EXTUSE);
EffectiveModelContext result = reactor.build();
assertNotNull(result);
BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
addSources(reactor, VALID_ABS);
- EffectiveModelContext result = reactor.build();
- assertNotNull(result);
+ try {
+ reactor.build();
+ } catch (Exception e) {
+ // if augment argument is correct we only catch an exception that it cannot be found in mock model
+ assertEquals(NullPointerException.class, e.getClass());
+ }
}
@Test
BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
addSources(reactor, IMPORTED, VALID_ABS_PREFIXED);
- EffectiveModelContext result = reactor.build();
- assertNotNull(result);
+ try {
+ reactor.build();
+ } catch (Exception e) {
+ // if augment argument is correct we only catch an exception that it cannot be found in mock model
+ assertEquals(NullPointerException.class, e.getClass());
+ }
}
@Test
BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
addSources(reactor, VALID_REL);
- EffectiveModelContext result = reactor.build();
- assertNotNull(result);
+ try {
+ reactor.build();
+ } catch (Exception e) {
+ // if augment argument is correct we only catch an exception that it cannot be found in mock model
+ assertEquals(NullPointerException.class, e.getClass());
+ }
}
@Test
BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
addSources(reactor, IMPORTED, VALID_REL_PREFIXED);
- EffectiveModelContext result = reactor.build();
- assertNotNull(result);
+ try {
+ reactor.build();
+ } catch (Exception e) {
+ // if augment argument is correct we only catch an exception that it cannot be found in mock model
+ assertEquals(NullPointerException.class, e.getClass());
+ }
}
@Test
@Override
public void writeLinkageAndStatementDefinitions(StatementWriter writer, QNameToStatementDefinition stmtDef,
- PrefixToModule prefixes) throws SourceException {
+ PrefixToModule prefixes) throws SourceException {
this.writer = writer;
header();
extensions();
belongs-to foo {
prefix f;
- }
+ }
import bar {
prefix "br";
--- /dev/null
+module augmented {
+ prefix augmented_pref;
+ namespace augmented_ns;
+
+ container cont1 {
+ container cont2 {
+ container cont-target {
+ }
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+module root {
+ prefix root_pref;
+ namespace root_ns;
+
+ import augmented {
+ prefix imp;
+ }
+
+ augment /imp:cont1/imp:cont2/imp:cont-target {
+ leaf added {
+ type string;
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+module aug-root {
+ namespace root;
+ prefix root;
+
+ import augmented {
+ prefix aug;
+ }
+
+ augment "aug:aug-parent1/aug:aug-parent2/aug:cont-target" {
+ container cont-added1 {
+ list list1 {
+ }
+ }
+
+ container cont-added2 {
+ anyxml axml;
+ }
+
+ uses aug:grp;
+ }
+}
\ No newline at end of file
--- /dev/null
+module augmented {
+ namespace aug;
+ prefix aug;
+
+ container aug-parent1 {
+ container aug-parent2 {
+ container cont-target {
+
+ }
+ }
+ }
+
+ grouping grp {
+ container cont-grp {
+ anyxml axml-grp;
+ }
+ }
+}
\ No newline at end of file