Jonathan Hart | aa38097 | 2014-04-03 10:24:46 -0700 | [diff] [blame] | 1 | package net.onrc.onos.core.intent; |
Toshio Koide | df2eab9 | 2014-02-20 11:24:59 -0800 | [diff] [blame] | 2 | |
| 3 | /** |
Ray Milkey | b41100a | 2014-04-10 10:42:15 -0700 | [diff] [blame] | 4 | * This class is instantiated by Run-times to express intent calculation error. |
Toshio Koide | df2eab9 | 2014-02-20 11:24:59 -0800 | [diff] [blame] | 5 | */ |
| 6 | public class ErrorIntent extends Intent { |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 7 | public enum ErrorType { |
Brian O'Connor | a581b9d | 2014-06-15 23:32:36 -0700 | [diff] [blame] | 8 | /** |
| 9 | * Intent not supported by runtime. |
| 10 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 11 | UNSUPPORTED_INTENT, |
Brian O'Connor | a581b9d | 2014-06-15 23:32:36 -0700 | [diff] [blame] | 12 | |
| 13 | /** |
| 14 | * One or more of the switches refereneced by this Intent not found. |
| 15 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 16 | SWITCH_NOT_FOUND, |
Brian O'Connor | a581b9d | 2014-06-15 23:32:36 -0700 | [diff] [blame] | 17 | |
| 18 | /** |
| 19 | * Path specified by Intent is not in the topology. |
| 20 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 21 | PATH_NOT_FOUND, |
| 22 | } |
Toshio Koide | df2eab9 | 2014-02-20 11:24:59 -0800 | [diff] [blame] | 23 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 24 | public ErrorType errorType; |
| 25 | public String message; |
| 26 | public Intent parentIntent; |
Toshio Koide | df2eab9 | 2014-02-20 11:24:59 -0800 | [diff] [blame] | 27 | |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 28 | /** |
Ray Milkey | b41100a | 2014-04-10 10:42:15 -0700 | [diff] [blame] | 29 | * Default constructor for Kryo deserialization. |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 30 | */ |
| 31 | protected ErrorIntent() { |
| 32 | } |
Toshio Koide | df2eab9 | 2014-02-20 11:24:59 -0800 | [diff] [blame] | 33 | |
Brian O'Connor | a581b9d | 2014-06-15 23:32:36 -0700 | [diff] [blame] | 34 | /** |
| 35 | * Constructor. |
| 36 | * |
| 37 | * @param errorType error type |
| 38 | * @param message human-readable error string |
| 39 | * @param parentIntent related parent Intent |
| 40 | */ |
Ray Milkey | 269ffb9 | 2014-04-03 14:43:30 -0700 | [diff] [blame] | 41 | public ErrorIntent(ErrorType errorType, String message, Intent parentIntent) { |
| 42 | super(parentIntent.getId()); |
| 43 | this.errorType = errorType; |
| 44 | this.message = message; |
| 45 | this.parentIntent = parentIntent; |
| 46 | } |
Pavlin Radoslavov | 7fb1641 | 2014-04-11 18:45:19 -0700 | [diff] [blame] | 47 | |
Brian O'Connor | a581b9d | 2014-06-15 23:32:36 -0700 | [diff] [blame] | 48 | /** |
| 49 | * Generates a hash code using the Intent ID. |
| 50 | * |
| 51 | * @return hashcode |
| 52 | */ |
Pavlin Radoslavov | 7fb1641 | 2014-04-11 18:45:19 -0700 | [diff] [blame] | 53 | @Override |
| 54 | public int hashCode() { |
Brian O'Connor | a581b9d | 2014-06-15 23:32:36 -0700 | [diff] [blame] | 55 | return super.hashCode(); |
Pavlin Radoslavov | 7fb1641 | 2014-04-11 18:45:19 -0700 | [diff] [blame] | 56 | } |
| 57 | |
Brian O'Connor | a581b9d | 2014-06-15 23:32:36 -0700 | [diff] [blame] | 58 | /** |
| 59 | * Compares two intent object by type (class) and Intent ID. |
| 60 | * |
| 61 | * @param obj other Intent |
| 62 | * @return true if equal, false otherwise |
| 63 | */ |
Pavlin Radoslavov | 7fb1641 | 2014-04-11 18:45:19 -0700 | [diff] [blame] | 64 | @Override |
| 65 | public boolean equals(Object obj) { |
Brian O'Connor | a581b9d | 2014-06-15 23:32:36 -0700 | [diff] [blame] | 66 | return super.equals(obj); |
Pavlin Radoslavov | 7fb1641 | 2014-04-11 18:45:19 -0700 | [diff] [blame] | 67 | } |
Toshio Koide | df2eab9 | 2014-02-20 11:24:59 -0800 | [diff] [blame] | 68 | } |