Sho SHIMIZU | e3cc0b9 | 2014-11-20 16:18:29 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Laboratory |
Sho SHIMIZU | e3cc0b9 | 2014-11-20 16:18:29 -0800 | [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 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.core; |
Sho SHIMIZU | e3cc0b9 | 2014-11-20 16:18:29 -0800 | [diff] [blame] | 17 | |
| 18 | import com.google.common.base.MoreObjects; |
| 19 | |
| 20 | import java.util.Objects; |
| 21 | |
| 22 | /** |
| 23 | * Default implementation of {@link GroupId}. |
| 24 | */ |
Prince Pereira | 3ff504c | 2016-08-30 14:23:43 +0530 | [diff] [blame] | 25 | @Deprecated |
| 26 | public class DefaultGroupId extends GroupId { |
Sho SHIMIZU | e3cc0b9 | 2014-11-20 16:18:29 -0800 | [diff] [blame] | 27 | |
| 28 | public DefaultGroupId(int id) { |
Prince Pereira | 3ff504c | 2016-08-30 14:23:43 +0530 | [diff] [blame] | 29 | super(id); |
Sho SHIMIZU | e3cc0b9 | 2014-11-20 16:18:29 -0800 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | // Constructor for serialization |
| 33 | private DefaultGroupId() { |
Prince Pereira | 3ff504c | 2016-08-30 14:23:43 +0530 | [diff] [blame] | 34 | super(0); |
Sho SHIMIZU | e3cc0b9 | 2014-11-20 16:18:29 -0800 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | @Override |
| 38 | public int hashCode() { |
Prince Pereira | 3ff504c | 2016-08-30 14:23:43 +0530 | [diff] [blame] | 39 | return identifier; |
Sho SHIMIZU | e3cc0b9 | 2014-11-20 16:18:29 -0800 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | @Override |
| 43 | public boolean equals(Object obj) { |
| 44 | if (this == obj) { |
| 45 | return true; |
| 46 | } |
| 47 | if (!(obj instanceof DefaultGroupId)) { |
| 48 | return false; |
| 49 | } |
| 50 | final DefaultGroupId other = (DefaultGroupId) obj; |
Prince Pereira | 3ff504c | 2016-08-30 14:23:43 +0530 | [diff] [blame] | 51 | return Objects.equals(this.identifier, other.identifier); |
Sho SHIMIZU | e3cc0b9 | 2014-11-20 16:18:29 -0800 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public String toString() { |
| 56 | return MoreObjects.toStringHelper(this) |
Prince Pereira | 3ff504c | 2016-08-30 14:23:43 +0530 | [diff] [blame] | 57 | .add("id", "0x" + Integer.toHexString(identifier)) |
Sho SHIMIZU | e3cc0b9 | 2014-11-20 16:18:29 -0800 | [diff] [blame] | 58 | .toString(); |
| 59 | } |
| 60 | } |