blob: 47b438ea78a74a9a9854d519f8e8234d15202dc9 [file] [log] [blame]
Sean Condonfae8e662016-12-15 10:25:13 +00001/*
2 * Copyright 2017-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 */
16package org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.uni.evc.service
17 .rev20160317.mseaunievcservice.mefservices.uni.evc.evcperuni;
18
19import org.onosproject.drivers.microsemi.yang.utils.CeVlanMapUtils;
20import org.onosproject.yang.gen.v1.http.www.microsemi.com.microsemi.edge.assure.msea.types
21 .rev20160229.mseatypes.ServiceListType;
22
23/**
24 * A custom implementation of the DefaultEvcPerUnin - especially its Builder.
25 *
26 * This allows the EvcPerUniN to be modified after creation. These additions to the
27 * builder are necessary because in the EA1000 YANG model the EvcPerUniN can
28 * be added at separate stages
29 */
30public class CustomEvcPerUnin extends DefaultEvcPerUnin {
31 public static EvcPerUninBuilder builder(EvcPerUnin evcPerUnin) {
32 return new EvcPerUninBuilder(evcPerUnin);
33 }
34
35 public static EvcPerUninBuilder builder() {
36 return new EvcPerUninBuilder();
37 }
38
39 public static class EvcPerUninBuilder extends DefaultEvcPerUnin.EvcPerUninBuilder {
40
41 /**
42 * Allow a new builder to be constructed
43 */
44 public EvcPerUninBuilder() {
45 valueLeafFlags.set(LeafIdentifier.CEVLANMAP.getLeafIndex());
46 this.ceVlanMap = new ServiceListType("0");
47 valueLeafFlags.set(LeafIdentifier.INGRESSBWPGROUPINDEX.getLeafIndex());
48 this.ingressBwpGroupIndex = 0;
49 }
50
51 /**
52 * Allow a builder to be constructed from an existing EvcPerUnin
53 * @param evcPerUnin An existing EvcPerUnin
54 */
55 public EvcPerUninBuilder(EvcPerUnin evcPerUnin) {
56 this.ceVlanMap = evcPerUnin.ceVlanMap();
57 this.evcPerUniServiceType = evcPerUnin.evcPerUniServiceType();
58 this.ingressBwpGroupIndex = evcPerUnin.ingressBwpGroupIndex();
59 this.tagManipulation = evcPerUnin.tagManipulation();
60 this.flowMapping = evcPerUnin.flowMapping();
61 this.yangEvcPerUninOpType = evcPerUnin.yangEvcPerUninOpType();
62 this.yangAugmentedInfoMap = evcPerUnin.yangAugmentedInfoMap();
63 this.selectLeafFlags = evcPerUnin.selectLeafFlags();
64 this.valueLeafFlags = evcPerUnin.valueLeafFlags();
65 }
66
67 /**
68 * Method to allow ceVlanMap to be modified.
69 * @param additionalCeVlanMap An addition to the existing ceVlanMap
70 * @return The updated builder
71 */
72 public EvcPerUninBuilder addToCeVlanMap(ServiceListType additionalCeVlanMap) {
73 String combinedCeVlanMap =
74 CeVlanMapUtils.combineVlanSets(ceVlanMap.string(), additionalCeVlanMap.string());
75 //If it contains 0 we should remove it
76 ceVlanMap = new ServiceListType(
77 CeVlanMapUtils.removeZeroIfPossible(combinedCeVlanMap));
78 return this;
79 }
80 }
81}