jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-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 | import com.google.common.base.MoreObjects; |
| 19 | |
jaegonkim | e0f45b5 | 2018-10-09 20:23:26 +0900 | [diff] [blame] | 20 | import static org.onosproject.workflow.api.CheckCondition.check; |
| 21 | |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 22 | |
| 23 | public final class TimeoutTask extends HandlerTask { |
| 24 | |
| 25 | private TimeoutTask(Builder builder) { |
| 26 | super(builder); |
| 27 | } |
| 28 | |
| 29 | @Override |
| 30 | public String toString() { |
| 31 | return MoreObjects.toStringHelper(getClass()) |
| 32 | .add("context", context()) |
jaegonkim | e0f45b5 | 2018-10-09 20:23:26 +0900 | [diff] [blame] | 33 | .add("programCounter", programCounter()) |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 34 | .toString(); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Gets a instance of builder. |
| 39 | * @return instance of builder |
| 40 | */ |
| 41 | public static Builder builder() { |
| 42 | return new Builder(); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Builder of TimeoutTask. |
| 47 | */ |
| 48 | public static class Builder extends HandlerTask.Builder { |
| 49 | @Override |
| 50 | public Builder context(WorkflowContext context) { |
| 51 | super.context(context); |
| 52 | return this; |
| 53 | } |
| 54 | |
| 55 | @Override |
jaegonkim | e0f45b5 | 2018-10-09 20:23:26 +0900 | [diff] [blame] | 56 | public Builder programCounter(ProgramCounter programCounter) { |
| 57 | super.programCounter(programCounter); |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 58 | return this; |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Builds TimeoutTask. |
| 63 | * @return instance of TimeoutTask |
jaegonkim | e0f45b5 | 2018-10-09 20:23:26 +0900 | [diff] [blame] | 64 | * @throws WorkflowException workflow exception |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 65 | */ |
jaegonkim | e0f45b5 | 2018-10-09 20:23:26 +0900 | [diff] [blame] | 66 | public TimeoutTask build() throws WorkflowException { |
| 67 | check(context != null, "context is invalid"); |
| 68 | check(programCounter != null, "programCounter is invalid"); |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 69 | return new TimeoutTask(this); |
| 70 | } |
| 71 | } |
| 72 | } |