blob: 180d9eb7d97756b850ec9275f63b296b3aef9bc6 [file] [log] [blame]
jaegonkim6a7b5242018-09-12 23:09:42 +09001/*
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 */
16package org.onosproject.workflow.api;
17
18import com.google.common.base.MoreObjects;
19
jaegonkime0f45b52018-10-09 20:23:26 +090020import static org.onosproject.workflow.api.CheckCondition.check;
21
jaegonkim6a7b5242018-09-12 23:09:42 +090022
23public 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())
jaegonkime0f45b52018-10-09 20:23:26 +090033 .add("programCounter", programCounter())
jaegonkim6a7b5242018-09-12 23:09:42 +090034 .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
jaegonkime0f45b52018-10-09 20:23:26 +090056 public Builder programCounter(ProgramCounter programCounter) {
57 super.programCounter(programCounter);
jaegonkim6a7b5242018-09-12 23:09:42 +090058 return this;
59 }
60
61 /**
62 * Builds TimeoutTask.
63 * @return instance of TimeoutTask
jaegonkime0f45b52018-10-09 20:23:26 +090064 * @throws WorkflowException workflow exception
jaegonkim6a7b5242018-09-12 23:09:42 +090065 */
jaegonkime0f45b52018-10-09 20:23:26 +090066 public TimeoutTask build() throws WorkflowException {
67 check(context != null, "context is invalid");
68 check(programCounter != null, "programCounter is invalid");
jaegonkim6a7b5242018-09-12 23:09:42 +090069 return new TimeoutTask(this);
70 }
71 }
72}