blob: 2e8dfc66572e21e42a85b5816a3f867074e5999c [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 DefaultEvcPerUnic - especially its Builder.
25 *
26 * This allows the EvcPerUniC to be modified after creation. These additions to the
27 * builder are necessary because in the EA1000 YANG model the EvcPerUniC can
28 * be added at separate stages
29 */
30public class CustomEvcPerUnic extends DefaultEvcPerUnic {
31 public static EvcPerUnicBuilder builder(EvcPerUnic evcPerUnic) {
32 return new EvcPerUnicBuilder(evcPerUnic);
33 }
34
35 public static EvcPerUnicBuilder builder() {
36 return new EvcPerUnicBuilder();
37 }
38
39 public static class EvcPerUnicBuilder extends DefaultEvcPerUnic.EvcPerUnicBuilder {
40
41 /**
42 * Allow a new builder to be constructed
43 */
44 public EvcPerUnicBuilder() {
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 EvcPerUnic
53 * @param evcPerUnic An existing EvcPerUnic
54 */
55 public EvcPerUnicBuilder(EvcPerUnic evcPerUnic) {
56 this.ceVlanMap = evcPerUnic.ceVlanMap();
57 this.evcPerUniServiceType = evcPerUnic.evcPerUniServiceType();
58 this.ingressBwpGroupIndex = evcPerUnic.ingressBwpGroupIndex();
59 this.tagManipulation = evcPerUnic.tagManipulation();
60 this.flowMapping = evcPerUnic.flowMapping();
61 this.yangEvcPerUnicOpType = evcPerUnic.yangEvcPerUnicOpType();
62 this.yangAugmentedInfoMap = evcPerUnic.yangAugmentedInfoMap();
63 this.selectLeafFlags = evcPerUnic.selectLeafFlags();
64 this.valueLeafFlags = evcPerUnic.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 EvcPerUnicBuilder 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
79 return this;
80 }
81 }
82}