Simon Hunt | c13082f | 2016-08-03 21:20:23 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Simon Hunt | c13082f | 2016-08-03 21:20:23 -0700 | [diff] [blame] | 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.ui.model.topo; |
| 18 | |
| 19 | import org.onosproject.net.region.RegionId; |
| 20 | |
| 21 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 22 | |
| 23 | /** |
| 24 | * A synthetic link that encapsulates a UiLink instance and the region to |
| 25 | * which it belongs. |
| 26 | */ |
| 27 | public class UiSynthLink { |
| 28 | |
| 29 | private final RegionId regionId; |
| 30 | private final UiLink link; |
Simon Hunt | 0e16109 | 2017-05-08 17:41:38 -0700 | [diff] [blame] | 31 | private final UiLink original; |
Simon Hunt | c13082f | 2016-08-03 21:20:23 -0700 | [diff] [blame] | 32 | |
| 33 | /** |
| 34 | * Constructs a synthetic link with the given parameters. |
| 35 | * |
| 36 | * @param regionId the region to which the link belongs |
| 37 | * @param link the link instance |
Simon Hunt | 0e16109 | 2017-05-08 17:41:38 -0700 | [diff] [blame] | 38 | * @param original the original link (device or edge) |
| 39 | * from which this was derived |
Simon Hunt | c13082f | 2016-08-03 21:20:23 -0700 | [diff] [blame] | 40 | */ |
Simon Hunt | 0e16109 | 2017-05-08 17:41:38 -0700 | [diff] [blame] | 41 | public UiSynthLink(RegionId regionId, UiLink link, UiLink original) { |
Simon Hunt | c13082f | 2016-08-03 21:20:23 -0700 | [diff] [blame] | 42 | this.regionId = regionId; |
| 43 | this.link = link; |
Simon Hunt | 0e16109 | 2017-05-08 17:41:38 -0700 | [diff] [blame] | 44 | this.original = original; |
Simon Hunt | c13082f | 2016-08-03 21:20:23 -0700 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | @Override |
| 48 | public String toString() { |
| 49 | return toStringHelper(this) |
| 50 | .add("region", regionId) |
| 51 | .add("link", link) |
Simon Hunt | 0e16109 | 2017-05-08 17:41:38 -0700 | [diff] [blame] | 52 | .add("original", original) |
Simon Hunt | c13082f | 2016-08-03 21:20:23 -0700 | [diff] [blame] | 53 | .toString(); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Returns the region identifier. |
| 58 | * |
| 59 | * @return the region ID |
| 60 | */ |
| 61 | public RegionId regionId() { |
| 62 | return regionId; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Returns the link. |
| 67 | * |
| 68 | * @return the link |
| 69 | */ |
| 70 | public UiLink link() { |
| 71 | return link; |
| 72 | } |
Simon Hunt | 0e16109 | 2017-05-08 17:41:38 -0700 | [diff] [blame] | 73 | |
| 74 | /** |
| 75 | * Returns the original link from which this was derived. |
| 76 | * |
| 77 | * @return the original link |
| 78 | */ |
| 79 | public UiLink original() { |
| 80 | return original; |
| 81 | } |
Simon Hunt | c13082f | 2016-08-03 21:20:23 -0700 | [diff] [blame] | 82 | } |