Sho SHIMIZU | 15ed4fd | 2014-08-05 14:40:42 -0700 | [diff] [blame] | 1 | package net.onrc.onos.api.newintent; |
| 2 | |
| 3 | /** |
| 4 | * Base intent implementation. |
| 5 | */ |
| 6 | public 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 | |
Sho SHIMIZU | 1674fb3 | 2014-08-20 14:44:31 -0700 | [diff] [blame] | 19 | /** |
| 20 | * Constructor for serializer. |
| 21 | */ |
| 22 | protected AbstractIntent() { |
| 23 | this.id = null; |
| 24 | } |
| 25 | |
Sho SHIMIZU | 15ed4fd | 2014-08-05 14:40:42 -0700 | [diff] [blame] | 26 | @Override |
| 27 | public IntentId getId() { |
| 28 | 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 | } |