blob: d08e2fa92fcbaee718b7bcf24bfa0214aabf7cc8 [file] [log] [blame]
Frank Wangcaef3142017-08-09 15:24:45 +08001/*
2 * Copyright 2017-present Open Networking Foundation
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
17package org.onosproject.incubator.protobuf.models.cfg;
18
19import org.onosproject.cfg.ConfigProperty.Type;
20import org.onosproject.grpc.cfg.models.ConfigPropertyEnumsProto.ConfigPropertyTypeProto;
21
22/**
23 * gRPC ConfigProperty.Type message to equivalent ONOS enum conversion related utilities.
24 */
25public final class ConfigPropertyEnumsProtoTranslator {
26
27 /**
28 * Translates gRPC ConfigProperty type to {@link Type}.
29 *
30 * @param configPropertyTypeProto config Property proto type
31 * @return {@link Type}
32 */
33 public static Type translate(ConfigPropertyTypeProto configPropertyTypeProto) {
34
35 return Type.valueOf(configPropertyTypeProto.name());
36 }
37
38 /**
39 * Translates {@link Type} to gRPC ConfigProperty type.
40 *
41 * @param type config Property type
42 * @return gRPC ConfigProperty type
43 */
44 public static ConfigPropertyTypeProto translate(Type type) {
45
46 return ConfigPropertyTypeProto.valueOf(type.name());
47 }
48
49 // Utility class not intended for instantiation.
50 private ConfigPropertyEnumsProtoTranslator() {}
51}