2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.parser.stmt.reactor;
10 import com.google.common.base.Preconditions;
11 import com.google.common.base.Verify;
12 import javax.annotation.Nonnull;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
15 import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
16 import org.opendaylight.yangtools.yang.parser.spi.source.StatementWriter;
18 final class StatementContextWriter implements StatementWriter {
19 private final ModelProcessingPhase phase;
20 private final SourceSpecificContext ctx;
22 private StatementContextBase<?, ?, ?> current;
24 StatementContextWriter(final SourceSpecificContext ctx, final ModelProcessingPhase phase) {
25 this.ctx = Preconditions.checkNotNull(ctx);
26 this.phase = Preconditions.checkNotNull(phase);
30 public void startStatement(final int childId, @Nonnull final QName name, final String argument,
31 @Nonnull final StatementSourceReference ref) {
32 current = Verify.verifyNotNull(ctx.createDeclaredChild(current, childId, name, argument, ref));
36 public void endStatement(@Nonnull final StatementSourceReference ref) {
37 Preconditions.checkState(current != null);
38 current.endDeclared(ref, phase);
39 current = current.getParentContext();
44 public ModelProcessingPhase getPhase() {