2 * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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.mdsal.binding.yang.types;
10 import static org.opendaylight.mdsal.binding.model.util.BindingGeneratorUtil.encodeAngleBrackets;
12 import com.google.common.annotations.Beta;
13 import java.util.Optional;
14 import org.opendaylight.mdsal.binding.model.api.type.builder.EnumBuilder;
15 import org.opendaylight.mdsal.binding.model.api.type.builder.GeneratedTypeBuilderBase;
16 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
17 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
18 import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
21 * {@link AbstractTypeProvider} which generates full metadata, suitable for codegen purposes. For runtime purposes,
22 * considering using {@link RuntimeTypeProvider}.
25 // FIXME: make this class final after TypeProviderImpl is gone
26 public class CodegenTypeProvider extends AbstractTypeProvider {
28 * Creates new instance of class <code>TypeProviderImpl</code>.
30 * @param schemaContext contains the schema data read from YANG files
31 * @throws IllegalArgumentException if <code>schemaContext</code> is null.
33 public CodegenTypeProvider(final SchemaContext schemaContext) {
38 public void addEnumDescription(final EnumBuilder enumBuilder, final EnumTypeDefinition enumTypeDef) {
39 final Optional<String> optDesc = enumTypeDef.getDescription();
40 if (optDesc.isPresent()) {
41 enumBuilder.setDescription(encodeAngleBrackets(optDesc.get()));
46 void addCodegenInformation(final GeneratedTypeBuilderBase<?> genTOBuilder, final TypeDefinition<?> typeDef) {
47 final Optional<String> optDesc = typeDef.getDescription();
48 if (optDesc.isPresent()) {
49 genTOBuilder.setDescription(encodeAngleBrackets(optDesc.get()));
51 typeDef.getReference().ifPresent(genTOBuilder::setReference);