blob: 7a5d04a06e1ead6a7740ae325278e76471ed06c3 [file] [log] [blame]
Jonathan Hartaa380972014-04-03 10:24:46 -07001package net.onrc.onos.core.intent;
Toshio Koidedf2eab92014-02-20 11:24:59 -08002
3/**
Ray Milkeyb41100a2014-04-10 10:42:15 -07004 * This class is instantiated by Run-times to express intent calculation error.
Toshio Koidedf2eab92014-02-20 11:24:59 -08005 */
6public class ErrorIntent extends Intent {
Ray Milkey269ffb92014-04-03 14:43:30 -07007 public enum ErrorType {
Brian O'Connora581b9d2014-06-15 23:32:36 -07008 /**
9 * Intent not supported by runtime.
10 */
Ray Milkey269ffb92014-04-03 14:43:30 -070011 UNSUPPORTED_INTENT,
Brian O'Connora581b9d2014-06-15 23:32:36 -070012
13 /**
14 * One or more of the switches refereneced by this Intent not found.
15 */
Ray Milkey269ffb92014-04-03 14:43:30 -070016 SWITCH_NOT_FOUND,
Brian O'Connora581b9d2014-06-15 23:32:36 -070017
18 /**
19 * Path specified by Intent is not in the topology.
20 */
Ray Milkey269ffb92014-04-03 14:43:30 -070021 PATH_NOT_FOUND,
22 }
Toshio Koidedf2eab92014-02-20 11:24:59 -080023
Ray Milkey269ffb92014-04-03 14:43:30 -070024 public ErrorType errorType;
25 public String message;
26 public Intent parentIntent;
Toshio Koidedf2eab92014-02-20 11:24:59 -080027
Ray Milkey269ffb92014-04-03 14:43:30 -070028 /**
Ray Milkeyb41100a2014-04-10 10:42:15 -070029 * Default constructor for Kryo deserialization.
Ray Milkey269ffb92014-04-03 14:43:30 -070030 */
31 protected ErrorIntent() {
32 }
Toshio Koidedf2eab92014-02-20 11:24:59 -080033
Brian O'Connora581b9d2014-06-15 23:32:36 -070034 /**
35 * Constructor.
36 *
37 * @param errorType error type
38 * @param message human-readable error string
39 * @param parentIntent related parent Intent
40 */
Ray Milkey269ffb92014-04-03 14:43:30 -070041 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 Radoslavov7fb16412014-04-11 18:45:19 -070047
Brian O'Connora581b9d2014-06-15 23:32:36 -070048 /**
49 * Generates a hash code using the Intent ID.
50 *
51 * @return hashcode
52 */
Pavlin Radoslavov7fb16412014-04-11 18:45:19 -070053 @Override
54 public int hashCode() {
Brian O'Connora581b9d2014-06-15 23:32:36 -070055 return super.hashCode();
Pavlin Radoslavov7fb16412014-04-11 18:45:19 -070056 }
57
Brian O'Connora581b9d2014-06-15 23:32:36 -070058 /**
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 Radoslavov7fb16412014-04-11 18:45:19 -070064 @Override
65 public boolean equals(Object obj) {
Brian O'Connora581b9d2014-06-15 23:32:36 -070066 return super.equals(obj);
Pavlin Radoslavov7fb16412014-04-11 18:45:19 -070067 }
Toshio Koidedf2eab92014-02-20 11:24:59 -080068}