Henry Yu | 4b4a7eb | 2016-11-09 20:07:53 -0500 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2016 Open Networking Laboratory |
| 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.link; |
| 17 | |
| 18 | import com.google.common.base.MoreObjects; |
| 19 | import com.google.common.base.Objects; |
| 20 | import org.onosproject.tetopology.management.api.TeTopologyEventSubject; |
| 21 | |
| 22 | /** |
| 23 | * Representation of a TE link event. |
| 24 | */ |
| 25 | public class TeLinkEventSubject implements TeTopologyEventSubject { |
| 26 | private final TeLinkTpGlobalKey key; |
| 27 | private final TeLink teLink; |
| 28 | |
| 29 | /** |
| 30 | * Creates an instance of TE link event. |
| 31 | * |
| 32 | * @param key the TE link key |
| 33 | * @param teLink the TE link |
| 34 | */ |
| 35 | public TeLinkEventSubject(TeLinkTpGlobalKey key, TeLink teLink) { |
| 36 | this.key = key; |
| 37 | this.teLink = teLink; |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Returns the TE link global key. |
| 42 | * |
| 43 | * @return the key |
| 44 | */ |
| 45 | public TeLinkTpGlobalKey key() { |
| 46 | return key; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Returns the TE link. |
| 51 | * |
| 52 | * @return the TE link |
| 53 | */ |
| 54 | public TeLink teLink() { |
| 55 | return teLink; |
| 56 | } |
| 57 | |
| 58 | @Override |
| 59 | public int hashCode() { |
| 60 | return Objects.hashCode(key, teLink); |
| 61 | } |
| 62 | |
| 63 | @Override |
| 64 | public boolean equals(Object object) { |
| 65 | if (this == object) { |
| 66 | return true; |
| 67 | } |
| 68 | if (object instanceof TeLinkEventSubject) { |
| 69 | TeLinkEventSubject that = (TeLinkEventSubject) object; |
| 70 | return Objects.equal(key, that.key) && |
| 71 | Objects.equal(teLink, that.teLink); |
| 72 | } |
| 73 | return false; |
| 74 | } |
| 75 | |
| 76 | @Override |
| 77 | public String toString() { |
| 78 | return MoreObjects.toStringHelper(this) |
| 79 | .add("key", key) |
| 80 | .add("teLink", teLink) |
| 81 | .toString(); |
| 82 | } |
| 83 | } |