nitinanand | c8b7025 | 2019-04-17 15:35:43 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019-present Open Networking Foundation |
| 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 | */ |
| 16 | package org.onosproject.workflow.api; |
| 17 | |
| 18 | |
| 19 | import com.google.common.base.MoreObjects; |
| 20 | |
| 21 | /** |
| 22 | * A class representing meta data for workflow event. |
| 23 | */ |
| 24 | public class WorkflowEventMetaData { |
| 25 | |
| 26 | private boolean isTriggerSet = false; |
| 27 | private ProgramCounter programCounter; |
| 28 | |
| 29 | /** |
| 30 | * Constructor of workflow event meta data. |
| 31 | * @param isTriggerSet trigger event set for the the workflow |
| 32 | * @param programCounter program counter representing worklet type for registered event |
| 33 | */ |
| 34 | public WorkflowEventMetaData(boolean isTriggerSet, ProgramCounter programCounter) { |
| 35 | this.isTriggerSet = isTriggerSet; |
| 36 | this.programCounter = programCounter; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Copy constructor of workflow event meta data. |
| 41 | * @param workflowEventMetaData object of WorkflowEventMetaData |
| 42 | */ |
| 43 | public WorkflowEventMetaData(WorkflowEventMetaData workflowEventMetaData) { |
| 44 | this.isTriggerSet = workflowEventMetaData.getTriggerFlag(); |
| 45 | this.programCounter = workflowEventMetaData.getProgramCounter().clone(); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Returns program counter value related to worflow event. |
| 50 | * @return programCounter |
| 51 | */ |
| 52 | public ProgramCounter getProgramCounter() { |
| 53 | return programCounter; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Returns trigger flag for the workflow. |
| 58 | * @return triggerFlag |
| 59 | */ |
| 60 | public boolean getTriggerFlag() { |
| 61 | return isTriggerSet; |
| 62 | } |
| 63 | |
| 64 | |
| 65 | /** |
| 66 | * Sets true or false for triggerFlag of the workflow. |
| 67 | * @param triggerFlag flag to indicate trigger event set for the workflow |
| 68 | */ |
| 69 | public void setTriggerFlag(boolean triggerFlag) { |
| 70 | this.isTriggerSet = triggerFlag; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Sets program counter representing worklet type for registered event of the workflow. |
| 75 | * @param programCounter program counter representing worklet type for registered event |
| 76 | */ |
| 77 | public void setProgramCounterString(ProgramCounter programCounter) { |
| 78 | this.programCounter = programCounter; |
| 79 | } |
| 80 | |
| 81 | |
| 82 | @Override |
| 83 | public String toString() { |
| 84 | return MoreObjects.toStringHelper(getClass()) |
| 85 | .add("trigger-flag", getTriggerFlag()) |
| 86 | .add("program-counter", getProgramCounter()) |
| 87 | .toString(); |
| 88 | } |
| 89 | |
| 90 | } |