2 * Copyright (c) 2020, 2022 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.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.te.types.rev200610;
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;
16 * Utility methods for dealing with {@code ietf-te-types.yang} unions.
18 public final class IetfTeUtil {
19 private static final @NonNull TeTopologyId EMPTY_TE_TOPOLOGY_ID = new TeTopologyId("");
21 private IetfTeUtil() {
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));
30 public static @NonNull TeTopologyId teTopologyIdFor(final String str) {
31 return str.isEmpty() ? EMPTY_TE_TOPOLOGY_ID : new TeTopologyId(str);
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));