hiroki | fca084b | 2018-06-02 08:29:42 -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 | |
hiroki | 96ab3c2 | 2018-12-11 14:10:52 -0800 | [diff] [blame^] | 19 | import org.onosproject.yang.gen.v1.tapiconnectivity.rev20181210.tapiconnectivity.connection.ConnectionEndPoint; |
| 20 | import org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.node.OwnedNodeEdgePoint; |
| 21 | import org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.topology.Node; |
| 22 | import org.onosproject.yang.gen.v1.tapitopology.rev20181210.tapitopology.topologycontext.Topology; |
hiroki | fca084b | 2018-06-02 08:29:42 -0700 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * Util class to create TapiXXXRef class instances using classes auto-generated by onos-yang-tool compiler. |
| 26 | */ |
| 27 | public final class DcsBasedTapiObjectRefFactory { |
| 28 | |
| 29 | private DcsBasedTapiObjectRefFactory() { |
| 30 | } |
| 31 | |
| 32 | /** |
| 33 | * Factory method to create {@link TapiNodeRef}. |
| 34 | * |
| 35 | * @param topology ModelObject context/topology |
| 36 | * @param node ModelObject context/topology/node |
| 37 | * @return node reference instance |
| 38 | */ |
| 39 | public static TapiNodeRef create(Topology topology, Node node) { |
| 40 | return TapiNodeRef.create(topology.uuid().toString(), node.uuid().toString()); |
| 41 | } |
| 42 | |
| 43 | /** |
| 44 | * Factory method to create {@link TapiNepRef}. |
| 45 | * |
| 46 | * @param topology ModelObject context/topology |
| 47 | * @param node ModelObject context/topology/node |
| 48 | * @param nep ModelObject context/topology/node/ownedNodeEdgePoint |
| 49 | * @return nep reference instance |
| 50 | */ |
| 51 | public static TapiNepRef create(Topology topology, Node node, OwnedNodeEdgePoint nep) { |
| 52 | return TapiNepRef.create(topology.uuid().toString(), node.uuid().toString(), nep.uuid().toString()); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Factory method to create {@link TapiCepRef}. |
| 57 | * |
| 58 | * @param cep ModelObject context/connection/connectionEndPoint |
| 59 | * @return cep reference instance |
| 60 | */ |
| 61 | public static TapiCepRef create(ConnectionEndPoint cep) { |
hiroki | d8fd786 | 2018-10-09 15:24:24 +0900 | [diff] [blame] | 62 | return TapiCepRef.create(cep.topologyUuid().toString(), cep.nodeUuid().toString(), |
| 63 | cep.nodeEdgePointUuid().toString(), cep.connectionEndPointUuid().toString()); |
hiroki | fca084b | 2018-06-02 08:29:42 -0700 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | } |