hiroki | ec18d3a | 2018-05-16 15:27:37 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 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 org.onosproject.odtn.utils.tapi; |
| 18 | |
| 19 | import static org.onosproject.odtn.utils.tapi.TapiGlobalClassUtil.setUuid; |
| 20 | |
| 21 | import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.DefaultContext; |
| 22 | import org.onosproject.yang.gen.v1.tapicommon.rev20180307.tapicommon.Uuid; |
| 23 | import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.context.DefaultAugmentedTapiCommonContext; |
| 24 | import org.onosproject.yang.gen.v1.tapitopology.rev20180307.tapitopology.topologycontext.DefaultTopology; |
| 25 | import org.onosproject.yang.model.ModelObject; |
| 26 | import org.onosproject.yang.model.ModelObjectData; |
| 27 | import org.onosproject.yang.model.ModelObjectId; |
| 28 | |
| 29 | /** |
| 30 | * Utility builder class for TAPI topology creation with DCS. |
| 31 | */ |
| 32 | public final class TapiTopologyBuilder extends TapiInstanceBuilder { |
| 33 | |
| 34 | private DefaultTopology topology; |
| 35 | |
| 36 | private TapiTopologyBuilder(DefaultTopology topology) { |
| 37 | this.topology = topology; |
| 38 | setUuid(this.topology); |
| 39 | } |
| 40 | |
| 41 | public static TapiTopologyBuilder builder(DefaultTopology topology) { |
| 42 | return new TapiTopologyBuilder(topology); |
| 43 | } |
| 44 | |
| 45 | |
| 46 | @Override |
| 47 | public ModelObjectData build() { |
| 48 | |
| 49 | DefaultAugmentedTapiCommonContext topologyContext = new DefaultAugmentedTapiCommonContext(); |
| 50 | topologyContext.addToTopology(topology); |
| 51 | |
| 52 | ModelObjectId objId = ModelObjectId.builder().addChild(DefaultContext.class).build(); |
| 53 | return getModelObjectData(topologyContext, objId); |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public ModelObject getModelObject() { |
| 58 | return topology; |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public Uuid getUuid() { |
| 63 | return topology.uuid(); |
| 64 | } |
| 65 | |
| 66 | } |