Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame^] | 2 | * Copyright 2016 Open Networking Foundation |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [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 | package org.onosproject.tetopology.management.api; |
| 17 | |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 18 | import com.google.common.base.Objects; |
| 19 | |
| 20 | /** |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 21 | * TE Topology identifier in String format. |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 22 | */ |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 23 | public class TeTopologyId extends ProviderClientId { |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 24 | private final String topologyId; |
| 25 | |
| 26 | /** |
| 27 | * Creates an instance of TE topology identifier. |
| 28 | * |
| 29 | * @param providerId value of provider identifier |
| 30 | * @param clientId value of client identifier |
| 31 | * @param topologyId value of topology identifier |
| 32 | */ |
| 33 | public TeTopologyId(long providerId, long clientId, String topologyId) { |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 34 | super(providerId, clientId); |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 35 | this.topologyId = topologyId; |
| 36 | } |
| 37 | |
| 38 | /** |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 39 | * Returns the topology identifier. |
| 40 | * |
| 41 | * @return topology identifier |
| 42 | */ |
| 43 | public String topologyId() { |
| 44 | return topologyId; |
| 45 | } |
| 46 | |
| 47 | @Override |
| 48 | public int hashCode() { |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 49 | return Objects.hashCode(super.hashCode(), topologyId); |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | @Override |
| 53 | public boolean equals(Object object) { |
| 54 | if (this == object) { |
| 55 | return true; |
| 56 | } |
| 57 | if (object instanceof TeTopologyId) { |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 58 | if (!super.equals(object)) { |
| 59 | return false; |
| 60 | } |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 61 | TeTopologyId that = (TeTopologyId) object; |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 62 | return Objects.equal(this.topologyId, that.topologyId); |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 63 | } |
| 64 | return false; |
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | public String toString() { |
Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame] | 69 | return toStringHelper() |
Aihua Guo | 1ce2dd1 | 2016-08-12 23:37:44 -0400 | [diff] [blame] | 70 | .add("topologyId", topologyId) |
| 71 | .toString(); |
| 72 | } |
| 73 | } |