+++ /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.Optional;
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
-import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.WhenEffectiveStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.AbstractEffectiveSchemaNode;
-import org.opendaylight.yangtools.yang.parser.spi.meta.CopyHistory;
-import org.opendaylight.yangtools.yang.parser.spi.meta.CopyType;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-
-public abstract class AbstractEffectiveDataSchemaNode<D extends DeclaredStatement<QName>> extends
- AbstractEffectiveSchemaNode<D> implements DataSchemaNode {
-
- private final RevisionAwareXPath whenCondition;
- private final boolean addedByUses;
- private final boolean configuration;
-
- // FIXME: YANGTOOLS-724: this field should be final
- private boolean augmenting;
-
- public AbstractEffectiveDataSchemaNode(final StmtContext<QName, D, ?> ctx) {
- super(ctx);
- this.configuration = ctx.isConfiguration();
-
- final WhenEffectiveStatement whenStmt = firstEffective(WhenEffectiveStatement.class);
- whenCondition = whenStmt != null ? whenStmt.argument() : null;
-
- // initCopyType
- final CopyHistory originalHistory = ctx.getCopyHistory();
- if (originalHistory.contains(CopyType.ADDED_BY_USES_AUGMENTATION)) {
- this.augmenting = true;
- this.addedByUses = true;
- } else {
- this.augmenting = originalHistory.contains(CopyType.ADDED_BY_AUGMENTATION);
- this.addedByUses = originalHistory.contains(CopyType.ADDED_BY_USES);
- }
- }
-
- @Override
- public final boolean isAugmenting() {
- return augmenting;
- }
-
- @Override
- public final boolean isAddedByUses() {
- return addedByUses;
- }
-
- @Override
- public final boolean isConfiguration() {
- return configuration;
- }
-
- @Override
- public final Optional<RevisionAwareXPath> getWhenCondition() {
- return Optional.ofNullable(whenCondition);
- }
-
- /**
- * Reset {@link #isAugmenting()} to false.
- *
- * @deprecated This method is a violation of immutable contract and is a side-effect of bad/incomplete lifecycle,
- * which needs to be fixed. Do not introduce new callers. This deficiency is tracked in YANGTOOLS-724.
- */
- @Deprecated
- protected final void resetAugmenting() {
- augmenting = false;
- }
-}