2 * Copyright (c) 2017 Pantheon Technologies, s.r.o. 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.rfc7950.stmt.units;
10 import com.google.common.collect.ImmutableList;
11 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
12 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
13 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
14 import org.opendaylight.yangtools.yang.model.api.stmt.UnitsEffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.UnitsStatement;
16 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStringStatementSupport;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
21 public final class UnitsStatementSupport
22 extends BaseStringStatementSupport<UnitsStatement, UnitsEffectiveStatement> {
23 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
24 YangStmtMapping.UNITS)
26 private static final UnitsStatementSupport INSTANCE = new UnitsStatementSupport();
28 private UnitsStatementSupport() {
29 super(YangStmtMapping.UNITS);
32 public static UnitsStatementSupport getInstance() {
37 protected SubstatementValidator getSubstatementValidator() {
38 return SUBSTATEMENT_VALIDATOR;
42 protected UnitsStatement createDeclared(final StmtContext<String, UnitsStatement, ?> ctx,
43 final ImmutableList<? extends DeclaredStatement<?>> substatements) {
44 return new RegularUnitsStatement(ctx.getRawArgument(), substatements);
48 protected UnitsStatement createEmptyDeclared(final StmtContext<String, UnitsStatement, ?> ctx) {
49 return new EmptyUnitsStatement(ctx.getRawArgument());
53 protected UnitsEffectiveStatement createEffective(final Current<String, UnitsStatement> stmt,
54 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
55 return substatements.isEmpty() ? new EmptyUnitsEffectiveStatement(stmt.declared())
56 : new RegularUnitsEffectiveStatement(stmt.declared(), substatements);