HONEYCOMB-58 - Routing Api
[honeycomb.git] / v3po / v3po2vpp / src / main / java / io / fd / honeycomb / translate / vpp / util / SubInterfaceUtils.java
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package io.fd.honeycomb.translate.vpp.util;
18
19 import java.util.List;
20 import javax.annotation.Nonnegative;
21 import javax.annotation.Nullable;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.Tags;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.vlan.rev161214.sub._interface.base.attributes.tags.Tag;
24
25 public final class SubInterfaceUtils {
26
27     private SubInterfaceUtils() {
28         throw new UnsupportedOperationException("Utility class cannot be instantiated.");
29     }
30
31     public static String getSubInterfaceName(final String superIfName, final int subIfaceId) {
32         return String.format("%s.%d", superIfName, subIfaceId);
33     }
34
35     /**
36      * Returns number of sub-interface tags.
37      *
38      * @param tags data object that represents sub-interface tags
39      * @return number of sub interface tags
40      */
41     @Nonnegative
42     public static int getNumberOfTags(@Nullable final Tags tags) {
43         if (tags == null) {
44             return 0;
45         }
46         final List<Tag> tagList = tags.getTag();
47         if (tagList == null) {
48             return 0;
49         }
50         return tagList.size();
51     }
52 }