2 * Copyright (c) 2016 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.honeycomb.v3po.translate.v3po.initializers;
19 import io.fd.honeycomb.v3po.vpp.data.init.AbstractDataTreeConverter;
20 import java.util.stream.Collectors;
21 import javax.annotation.Nonnull;
22 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603.VppClassifier;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603.VppClassifierBuilder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603.VppClassifierState;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classifier.rev150603.vpp.classifier.ClassifyTableBuilder;
27 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
30 * Initializes vpp-classfier node in config data tree based on operational state.
32 public class VppClasifierInitializer extends AbstractDataTreeConverter<VppClassifierState, VppClassifier> {
33 private static final InstanceIdentifier<VppClassifierState> OPER_ID =
34 InstanceIdentifier.create(VppClassifierState.class);
35 private static final InstanceIdentifier<VppClassifier> CFG_ID = InstanceIdentifier.create(VppClassifier.class);
37 public VppClasifierInitializer(@Nonnull final DataBroker bindingDataBroker) {
38 super(bindingDataBroker, OPER_ID, CFG_ID);
42 protected VppClassifier convert(final VppClassifierState operationalData) {
43 final VppClassifierBuilder builder = new VppClassifierBuilder();
44 builder.setClassifyTable(operationalData.getClassifyTable().stream()
45 .map(oper -> new ClassifyTableBuilder(oper).setName(oper.getName()).build())
46 .collect(Collectors.toList()));
47 return builder.build();