2 * Copyright (c) 2018 Cisco and/or its affiliates.
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:
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package io.fd.hc2vpp.common.translate.util;
19 import static com.google.common.base.Preconditions.checkNotNull;
21 import io.fd.vpp.jvpp.core.types.FibMplsLabel;
22 import javax.annotation.Nonnull;
25 * Utility for Translating between different representations of MPLS label.
27 public interface MplsLabelTranslator {
29 * Make available also from static context.
31 MplsLabelTranslator INSTANCE = new MplsLabelTranslator() {
35 * Builds {@link FibMplsLabel} from its YANG representation.
37 * @param label YANG representation of MPLS Label
38 * @return VPP representation of MPLS label
40 default FibMplsLabel translate(@Nonnull final Long label) {
41 checkNotNull(label, "MPLS label should not be null");
42 return translate(label.intValue());
46 * Builds {@link FibMplsLabel} from int value.
48 * @param label MPLS Label value
49 * @return VPP representation of MPLS label
51 default FibMplsLabel translate(final int label) {
52 final FibMplsLabel fibMplsLabel = new FibMplsLabel();
53 fibMplsLabel.label = label;