blob: c8a4a05ef94bb2900d1c82a0dd893da5de3162ce [file] [log] [blame]
Brian O'Connorb876bf12014-10-02 14:59:37 -07001package org.onlab.onos.net.intent;
2
3/**
4 * Base intent implementation.
5 */
6public abstract class AbstractIntent implements Intent {
7
8 private final IntentId id;
9
10 /**
11 * Creates a base intent with the specified identifier.
12 *
13 * @param id intent identifier
14 */
15 protected AbstractIntent(IntentId id) {
16 this.id = id;
17 }
18
19 /**
20 * Constructor for serializer.
21 */
22 protected AbstractIntent() {
23 this.id = null;
24 }
25
26 @Override
tom85258ee2014-10-07 00:10:02 -070027 public IntentId id() {
Brian O'Connorb876bf12014-10-02 14:59:37 -070028 return id;
29 }
30
31 @Override
32 public boolean equals(Object o) {
33 if (this == o) {
34 return true;
35 }
36 if (o == null || getClass() != o.getClass()) {
37 return false;
38 }
39
40 AbstractIntent that = (AbstractIntent) o;
41 return id.equals(that.id);
42 }
43
44 @Override
45 public int hashCode() {
46 return id.hashCode();
47 }
48
49}