Do not generate union builders
[mdsal.git] / model / ietf / rfc8776-ietf-te-types / src / main / java / org / opendaylight / yang / gen / v1 / urn / ietf / params / xml / ns / yang / ietf / te / types / rev200610 / IetfTeUtil.java
1 /*
2  * Copyright (c) 2020, 2022 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev200610;
9
10 import org.eclipse.jdt.annotation.NonNull;
11 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
12 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.HexString;
13 import org.opendaylight.yangtools.yang.common.Uint32;
14
15 /**
16  * Utility methods for dealing with {@code ietf-te-types.yang} unions.
17  */
18 public final class IetfTeUtil {
19     private static final @NonNull TeTopologyId EMPTY_TE_TOPOLOGY_ID = new TeTopologyId("");
20
21     private IetfTeUtil() {
22         // Hidden on purpose
23     }
24
25     public static @NonNull AdminGroups admingGroupsFor(final String str) {
26         final HexString hex = new HexString(str);
27         return str.length() <= 11 ? new AdminGroups(new AdminGroup(hex)) : new AdminGroups(new ExtendedAdminGroup(hex));
28     }
29
30     public static @NonNull TeTopologyId teTopologyIdFor(final String str) {
31         return str.isEmpty() ? EMPTY_TE_TOPOLOGY_ID : new TeTopologyId(str);
32     }
33
34     public static @NonNull TeTpId teTpIdFor(final String str) {
35         return str.indexOf('.') == -1 && str.indexOf(':') == -1
36                 ? new TeTpId(Uint32.valueOf(str)) : new TeTpId(IetfInetUtil.ipAddressFor(str));
37     }
38 }