b903d3b1079bf603f939168c99491c4c60ed2caf
[hc2vpp.git] /
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.v3po.translate.v3po.initializers;
18
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.vpp.classifier.ClassifyTableBuilder;
26 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
27
28 /**
29  * Initializes vpp-classfier node in config data tree based on operational state.
30  */
31 public class VppClasifierInitializer extends AbstractDataTreeConverter<VppClassifier, VppClassifier> {
32     private static final InstanceIdentifier<VppClassifier> ID = InstanceIdentifier.create(VppClassifier.class);
33
34     public VppClasifierInitializer(@Nonnull final DataBroker bindingDataBroker) {
35         super(bindingDataBroker, ID, ID);
36     }
37
38     @Override
39     protected VppClassifier convert(final VppClassifier operationalData) {
40         final VppClassifierBuilder builder = new VppClassifierBuilder();
41         builder.setClassifyTable(operationalData.getClassifyTable().stream()
42             .map(oper -> new ClassifyTableBuilder(oper).setActiveSessions(null).build())
43             .collect(Collectors.toList()));
44         return builder.build();
45     }
46 }