blob: eed5fb0c3b91631f1aa02620a406e49530ee48ee [file] [log] [blame]
alshabib92c65ad2014-10-08 21:56:05 -07001package org.onlab.onos.impl;
2
toma6897792014-10-08 22:21:05 -07003import org.onlab.onos.ApplicationId;
4
alshabib92c65ad2014-10-08 21:56:05 -07005import java.util.Objects;
6
toma6897792014-10-08 22:21:05 -07007import static com.google.common.base.MoreObjects.toStringHelper;
alshabib92c65ad2014-10-08 21:56:05 -07008
9/**
10 * Application id generator class.
11 */
12public class DefaultApplicationId implements ApplicationId {
13
alshabib92c65ad2014-10-08 21:56:05 -070014 private final short id;
15 private final String name;
16
alshabib92c65ad2014-10-08 21:56:05 -070017 // Ban public construction
18 protected DefaultApplicationId(Short id, String identifier) {
19 this.id = id;
20 this.name = identifier;
21 }
22
23 @Override
24 public short id() {
25 return id;
26 }
27
28 @Override
29 public String name() {
30 return name;
31 }
32
33 @Override
34 public int hashCode() {
35 return Objects.hash(id);
36 }
37
38 @Override
39 public boolean equals(Object obj) {
40 if (this == obj) {
41 return true;
42 }
toma6897792014-10-08 22:21:05 -070043 if (obj instanceof DefaultApplicationId) {
44 DefaultApplicationId other = (DefaultApplicationId) obj;
45 return Objects.equals(this.id, other.id);
alshabib92c65ad2014-10-08 21:56:05 -070046 }
toma6897792014-10-08 22:21:05 -070047 return false;
alshabib92c65ad2014-10-08 21:56:05 -070048 }
toma6897792014-10-08 22:21:05 -070049
50 @Override
51 public String toString() {
52 return toStringHelper(this).add("id", id).add("name", name).toString();
53 }
54
alshabib92c65ad2014-10-08 21:56:05 -070055}