blob: dc7bdcd15bdeccd229572cd21f172096a3596035 [file] [log] [blame]
Carmelo Casconed4e7a772016-05-03 11:21:29 -07001/*
2 * Copyright 2016-present Open Networking Laboratory
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.drivers.bmv2.translators;
18
19import com.google.common.annotations.Beta;
20import org.onosproject.bmv2.api.model.Bmv2Model;
21import org.onosproject.net.flow.criteria.Criterion;
22
23import java.util.Map;
24
25import static org.onosproject.drivers.bmv2.translators.Bmv2FlowRuleTranslator.TranslatorConfig;
26
27/**
28 * Default implementation of a BMv2 flow rule translator configuration.
29 */
30@Beta
31public abstract class Bmv2DefaultTranslatorConfig implements TranslatorConfig {
32
33 private final Bmv2Model model;
34 private final Map<String, Criterion.Type> fieldMap;
35
36 /**
37 * Creates a new translator configuration.
38 *
39 * @param model a BMv2 packet processing model
40 * @param fieldMap a field-to-criterion type map
41 */
42 protected Bmv2DefaultTranslatorConfig(Bmv2Model model, Map<String, Criterion.Type> fieldMap) {
43 this.model = model;
44 this.fieldMap = fieldMap;
45 }
46
47 @Override
48 public Bmv2Model model() {
49 return this.model;
50 }
51
52 @Override
53 public Map<String, Criterion.Type> fieldToCriterionTypeMap() {
54 return this.fieldMap;
55 }
56}