blob: a945354e4b57e62aa4a8d598fc91762b3255de97 [file] [log] [blame]
tomc1a38d32014-08-25 23:01:32 -07001package org.onlab.onos.net.provider;
tom0eb04ca2014-08-25 14:34:51 -07002
tom64b7aac2014-08-26 00:18:21 -07003import java.util.Objects;
4
tomeadbb462014-09-07 16:10:19 -07005import static com.google.common.base.MoreObjects.toStringHelper;
tom64b7aac2014-08-26 00:18:21 -07006
tom0eb04ca2014-08-25 14:34:51 -07007/**
8 * Notion of provider identity.
9 */
10public class ProviderId {
11
12 private final String id;
13
tom64b7aac2014-08-26 00:18:21 -070014 /**
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 */
tom0eb04ca2014-08-25 14:34:51 -070021 public ProviderId(String id) {
22 this.id = id;
23 }
24
25 @Override
tom64b7aac2014-08-26 00:18:21 -070026 public int hashCode() {
27 return Objects.hash(id);
tom0eb04ca2014-08-25 14:34:51 -070028 }
29
30 @Override
tom64b7aac2014-08-26 00:18:21 -070031 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);
tom0eb04ca2014-08-25 14:34:51 -070040 }
41
42 @Override
43 public String toString() {
tom64b7aac2014-08-26 00:18:21 -070044 return toStringHelper(this).add("id", id).toString();
tom0eb04ca2014-08-25 14:34:51 -070045 }
tom64b7aac2014-08-26 00:18:21 -070046
tom0eb04ca2014-08-25 14:34:51 -070047}