blob: aaa3f8d6fde56ee8fe8b1fb89cd937f30c5ece4c [file] [log] [blame]
Hyunsun Moon58ddbdc2016-03-07 16:37:17 -08001/*
Brian O'Connor80dff972017-08-03 22:46:30 -07002 * Copyright 2016-present Open Networking Foundation
Hyunsun Moon58ddbdc2016-03-07 16:37:17 -08003 *
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 Moonfd5a24e2016-10-19 19:15:48 -070016package org.opencord.cordvtn.api.node;
Hyunsun Moon58ddbdc2016-03-07 16:37:17 -080017
18/**
19 * Entity that defines possible init state of the cordvtn node.
20 */
Hyunsun Moon2c3f0ee2017-04-06 16:47:21 +090021public 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 Moon58ddbdc2016-03-07 16:37:17 -080069 /**
Hyunsun Moon2c3f0ee2017-04-06 16:47:21 +090070 * Processes the current node state to proceed to the next state.
Hyunsun Moon58ddbdc2016-03-07 16:37:17 -080071 *
Hyunsun Moon2c3f0ee2017-04-06 16:47:21 +090072 * @param handler cordvtn node state handler
73 * @param node cordvtn node
Hyunsun Moon58ddbdc2016-03-07 16:37:17 -080074 */
Hyunsun Moon2c3f0ee2017-04-06 16:47:21 +090075 public abstract void process(CordVtnNodeHandler handler, CordVtnNode node);
76
77 /**
78 * Returns the next node state.
David K. Bainbridge5c55ab42017-08-17 09:54:40 -070079 * @return next node state
Hyunsun Moon2c3f0ee2017-04-06 16:47:21 +090080 */
81 public abstract CordVtnNodeState nextState();
Hyunsun Moon58ddbdc2016-03-07 16:37:17 -080082}