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.stmt.rfc6020.effective.type;
10 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit;
11 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
12 import org.opendaylight.yangtools.yang.model.util.type.BitBuilder;
13 import org.opendaylight.yangtools.yang.model.util.type.EnumPairBuilder;
15 final class EffectiveTypeUtil {
16 private EffectiveTypeUtil() {
17 throw new UnsupportedOperationException();
20 static Bit buildBit(final BitEffectiveStatementImpl stmt, final long effectivePos) {
21 // TODO: code duplication with EnumPairBuilder is indicating we could use a common Builder<?> interface
22 final BitBuilder builder = BitBuilder.create(stmt.getPath(), effectivePos).setStatus(stmt.getStatus());
23 stmt.getDescription().ifPresent(builder::setDescription);
24 stmt.getReference().ifPresent(builder::setReference);
26 return builder.build();
29 static EnumPair buildEnumPair(final EnumEffectiveStatementImpl stmt, final int effectiveValue) {
30 final EnumPairBuilder builder = EnumPairBuilder.create(stmt.getName(), effectiveValue)
31 .setStatus(stmt.getStatus()).setUnknownSchemaNodes(stmt.getUnknownSchemaNodes());
32 stmt.getDescription().ifPresent(builder::setDescription);
33 stmt.getReference().ifPresent(builder::setReference);
35 return builder.build();