2 * Copyright (c) 2020 PANTHEON.tech, 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.mdsal.binding.yang.types;
10 import org.eclipse.jdt.annotation.NonNull;
11 import org.opendaylight.mdsal.binding.generator.spi.TypeProvider;
12 import org.opendaylight.mdsal.binding.model.api.Restrictions;
13 import org.opendaylight.mdsal.binding.model.api.Type;
14 import org.opendaylight.mdsal.binding.model.util.BaseYangTypes;
15 import org.opendaylight.mdsal.binding.model.util.Types;
16 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
17 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
19 @Deprecated(forRemoval = true)
20 final class BaseYangTypesProvider implements TypeProvider {
21 static final @NonNull BaseYangTypesProvider INSTANCE = new BaseYangTypesProvider();
23 private BaseYangTypesProvider() {
28 * Searches <code>Type</code> value to which is YANG <code>type</code>
32 * type definition representation of YANG type
33 * @return java <code>Type</code> representation of <code>type</code>.
34 * If <code>type</code> isn't found then <code>null</code> is
38 public Type javaTypeForSchemaDefinitionType(final TypeDefinition<?> type, final SchemaNode parentNode,
39 final boolean lenientRelativeLeafrefs) {
40 return type == null ? null : BaseYangTypes.javaTypeForYangType(type.getQName().getLocalName());
44 public Type javaTypeForSchemaDefinitionType(final TypeDefinition<?> type, final SchemaNode parentNode,
45 final Restrictions restrictions, final boolean lenientRelativeLeafrefs) {
46 final String typeName = type.getQName().getLocalName();
47 final Type mapped = BaseYangTypes.javaTypeForYangType(typeName);
48 return mapped == null || restrictions == null ? mapped : Types.restrictedType(mapped, restrictions);