tom | c1a38d3 | 2014-08-25 23:01:32 -0700 | [diff] [blame] | 1 | package org.onlab.onos.net.provider; |
tom | 0eb04ca | 2014-08-25 14:34:51 -0700 | [diff] [blame] | 2 | |
tom | 64b7aac | 2014-08-26 00:18:21 -0700 | [diff] [blame] | 3 | import java.util.Objects; |
| 4 | |
tom | eadbb46 | 2014-09-07 16:10:19 -0700 | [diff] [blame^] | 5 | import static com.google.common.base.MoreObjects.toStringHelper; |
tom | 64b7aac | 2014-08-26 00:18:21 -0700 | [diff] [blame] | 6 | |
tom | 0eb04ca | 2014-08-25 14:34:51 -0700 | [diff] [blame] | 7 | /** |
| 8 | * Notion of provider identity. |
| 9 | */ |
| 10 | public class ProviderId { |
| 11 | |
| 12 | private final String id; |
| 13 | |
tom | 64b7aac | 2014-08-26 00:18:21 -0700 | [diff] [blame] | 14 | /** |
| 15 | * Creates a new provider identifier from the specified string. |
| 16 | * The providers are expected to follow the reverse DNS convention, e.g. |
| 17 | * {@code org.onlab.onos.provider.of.device} |
| 18 | * |
| 19 | * @param id string identifier |
| 20 | */ |
tom | 0eb04ca | 2014-08-25 14:34:51 -0700 | [diff] [blame] | 21 | public ProviderId(String id) { |
| 22 | this.id = id; |
| 23 | } |
| 24 | |
| 25 | @Override |
tom | 64b7aac | 2014-08-26 00:18:21 -0700 | [diff] [blame] | 26 | public int hashCode() { |
| 27 | return Objects.hash(id); |
tom | 0eb04ca | 2014-08-25 14:34:51 -0700 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | @Override |
tom | 64b7aac | 2014-08-26 00:18:21 -0700 | [diff] [blame] | 31 | public boolean equals(Object obj) { |
| 32 | if (this == obj) { |
| 33 | return true; |
| 34 | } |
| 35 | if (obj == null || getClass() != obj.getClass()) { |
| 36 | return false; |
| 37 | } |
| 38 | final ProviderId other = (ProviderId) obj; |
| 39 | return Objects.equals(this.id, other.id); |
tom | 0eb04ca | 2014-08-25 14:34:51 -0700 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | @Override |
| 43 | public String toString() { |
tom | 64b7aac | 2014-08-26 00:18:21 -0700 | [diff] [blame] | 44 | return toStringHelper(this).add("id", id).toString(); |
tom | 0eb04ca | 2014-08-25 14:34:51 -0700 | [diff] [blame] | 45 | } |
tom | 64b7aac | 2014-08-26 00:18:21 -0700 | [diff] [blame] | 46 | |
tom | 0eb04ca | 2014-08-25 14:34:51 -0700 | [diff] [blame] | 47 | } |