Hyunsun Moon | 58ddbdc | 2016-03-07 16:37:17 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 8e57fd5 | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Hyunsun Moon | 58ddbdc | 2016-03-07 16:37:17 -0800 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Hyunsun Moon | fd5a24e | 2016-10-19 19:15:48 -0700 | [diff] [blame] | 16 | package org.opencord.cordvtn.api.node; |
Hyunsun Moon | 58ddbdc | 2016-03-07 16:37:17 -0800 | [diff] [blame] | 17 | |
| 18 | /** |
| 19 | * Entity that defines possible init state of the cordvtn node. |
| 20 | */ |
Hyunsun Moon | 2c3f0ee | 2017-04-06 16:47:21 +0900 | [diff] [blame] | 21 | public enum CordVtnNodeState { |
| 22 | |
| 23 | INIT { |
| 24 | @Override |
| 25 | public void process(CordVtnNodeHandler handler, CordVtnNode node) { |
| 26 | handler.processInitState(node); |
| 27 | } |
| 28 | |
| 29 | @Override |
| 30 | public CordVtnNodeState nextState() { |
| 31 | return DEVICE_CREATED; |
| 32 | } |
| 33 | }, |
| 34 | DEVICE_CREATED { |
| 35 | @Override |
| 36 | public void process(CordVtnNodeHandler handler, CordVtnNode node) { |
| 37 | handler.processDeviceCreatedState(node); |
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | public CordVtnNodeState nextState() { |
| 42 | return PORT_CREATED; |
| 43 | } |
| 44 | }, |
| 45 | PORT_CREATED { |
| 46 | @Override |
| 47 | public void process(CordVtnNodeHandler handler, CordVtnNode node) { |
| 48 | handler.processPortCreatedState(node); |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public CordVtnNodeState nextState() { |
| 53 | return COMPLETE; |
| 54 | } |
| 55 | }, |
| 56 | COMPLETE { |
| 57 | @Override |
| 58 | public void process(CordVtnNodeHandler handler, CordVtnNode node) { |
| 59 | handler.processCompleteState(node); |
| 60 | } |
| 61 | |
| 62 | @Override |
| 63 | public CordVtnNodeState nextState() { |
| 64 | // last state |
| 65 | return COMPLETE; |
| 66 | } |
| 67 | }; |
| 68 | |
Hyunsun Moon | 58ddbdc | 2016-03-07 16:37:17 -0800 | [diff] [blame] | 69 | /** |
Hyunsun Moon | 2c3f0ee | 2017-04-06 16:47:21 +0900 | [diff] [blame] | 70 | * Processes the current node state to proceed to the next state. |
Hyunsun Moon | 58ddbdc | 2016-03-07 16:37:17 -0800 | [diff] [blame] | 71 | * |
Hyunsun Moon | 2c3f0ee | 2017-04-06 16:47:21 +0900 | [diff] [blame] | 72 | * @param handler cordvtn node state handler |
| 73 | * @param node cordvtn node |
Hyunsun Moon | 58ddbdc | 2016-03-07 16:37:17 -0800 | [diff] [blame] | 74 | */ |
Hyunsun Moon | 2c3f0ee | 2017-04-06 16:47:21 +0900 | [diff] [blame] | 75 | public abstract void process(CordVtnNodeHandler handler, CordVtnNode node); |
| 76 | |
| 77 | /** |
| 78 | * Returns the next node state. |
| 79 | */ |
| 80 | public abstract CordVtnNodeState nextState(); |
Hyunsun Moon | 58ddbdc | 2016-03-07 16:37:17 -0800 | [diff] [blame] | 81 | } |