import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
-import java.util.Optional;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opendaylight.yangtools.yang.common.QName;
return type;
}
- @Override
- public Optional<StatementSupport<?, ?, ?>> getImplicitParentFor(final StatementDefinition stmtDef) {
- // NOOP for most implementations and also no implicit parent
- return Optional.empty();
- }
-
@Override
public void onStatementAdded(final StmtContext.Mutable<A, D, E> stmt) {
// NOOP for most implementations
--- /dev/null
+/*
+ * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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.spi.meta;
+
+import com.google.common.annotations.Beta;
+import java.util.Optional;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
+
+/**
+ * {@link StatementSupport} trait for statements which create intermediate parent node for some of its child nodes.
+ * An example of this is RFC6020/RFC7950 choice statement, which creates implicit case statements for child containers
+ * and others.
+ *
+ * @author Robert Varga
+ */
+@Beta
+// FIXME: 3.0.0: make this interface extend StatementSupport
+public interface ImplicitParentAwareStatementSupport {
+ /**
+ * Returns implicit parent statement support for supplied statement definition, if it is defined. This allows
+ * implementations of this interface add implicit parent to the build context hierarchy before a substatement
+ * is created.
+ *
+ * @param stmtDef statement definition of substatement
+ * @return optional of implicit parent statement support
+ */
+ Optional<StatementSupport<?, ?, ?>> getImplicitParentFor(StatementDefinition stmtDef);
+}
* @param <E>
* Effective Statement representation
*/
+// FIXME: 3.0.0: do not extends ImplicitParentAwareStatementSupport
public interface StatementSupport<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
- extends StatementDefinition, StatementFactory<A, D, E> {
+ extends StatementDefinition, StatementFactory<A, D, E>, ImplicitParentAwareStatementSupport {
/**
* Returns public statement definition, which will be present in built statements.
*/
void onStatementAdded(StmtContext.Mutable<A, D, E> stmt);
- /**
- * Returns implicit parent statement support for supplied statement definition, if it is defined. This allows
- * implementations of this interface add implicit parent to the build context hierarchy before a substatement
- * is created.
- *
- * @param stmtDef
- * statement definition of substatement
- * @return optional of implicit parent statement support
- */
- Optional<StatementSupport<?, ?, ?>> getImplicitParentFor(StatementDefinition stmtDef);
+ // FIXME: 3.0.0: remove this default method
+ @Override
+ default Optional<StatementSupport<?, ?, ?>> getImplicitParentFor(final StatementDefinition stmtDef) {
+ return Optional.empty();
+ }
/**
* Invoked when statement is closed during {@link ModelProcessingPhase#SOURCE_PRE_LINKAGE} phase, only substatements