Ramon Casellas | 99c1625 | 2019-05-31 14:29:00 +0200 | [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 | * This work was partially supported by EC H2020 project METRO-HAUL (761727). |
| 17 | */ |
| 18 | package org.onosproject.drivers.odtn.openroadm; |
| 19 | |
| 20 | import org.onosproject.net.device.DeviceService; |
| 21 | |
| 22 | /** |
| 23 | * Factory class for Connection objects based on the OpenRoadmFlowRule. |
| 24 | */ |
| 25 | public final class OpenRoadmConnectionFactory { |
| 26 | |
| 27 | /** |
| 28 | * Static method to create an OpenROADM connection. |
| 29 | * |
| 30 | * @param openRoadmName name of the Connection. |
| 31 | * @param xc the associated OpenRoadmFlowRule. |
| 32 | * @param deviceService ONOS device service. |
| 33 | * @return the OpenRoadmConnectionObject |
| 34 | * @throws IllegalArgumentException |
| 35 | * |
| 36 | * Based on the cross-connection type, the method allocates and |
| 37 | * Add, Drop or Express connection object (or local, from client to client). |
| 38 | */ |
| 39 | public static OpenRoadmConnection create(String openRoadmName, |
| 40 | OpenRoadmFlowRule xc, |
| 41 | DeviceService deviceService) |
| 42 | throws IllegalArgumentException { |
| 43 | switch (xc.type()) { |
| 44 | case EXPRESS_LINK: |
| 45 | return new OpenRoadmExpressConnection(openRoadmName, xc, |
| 46 | deviceService); |
| 47 | case ADD_LINK: |
| 48 | return new OpenRoadmAddConnection(openRoadmName, xc, |
| 49 | deviceService); |
| 50 | case DROP_LINK: |
| 51 | return new OpenRoadmDropConnection(openRoadmName, xc, |
| 52 | deviceService); |
| 53 | case LOCAL: |
| 54 | return new OpenRoadmLocalConnection(openRoadmName, xc, |
| 55 | deviceService); |
| 56 | default: |
| 57 | throw new IllegalArgumentException( |
| 58 | "Unknown OpenRoadmFlowRule type"); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | private OpenRoadmConnectionFactory() { |
| 63 | // Utility classes should not have a public or default constructor. |
| 64 | // [HideUtilityClassConstructor] |
| 65 | } |
| 66 | } |