|
| 1 | +/* |
| 2 | + * Copyright 2020 IBM Corp. All Rights Reserved. |
| 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 com.ibm.watson.data.client.model; |
| 17 | + |
| 18 | +import java.util.Objects; |
| 19 | +import com.fasterxml.jackson.annotation.JsonInclude; |
| 20 | +import com.fasterxml.jackson.annotation.JsonProperty; |
| 21 | +import com.ibm.watson.data.client.model.enums.BootstrapState; |
| 22 | + |
| 23 | +import java.util.ArrayList; |
| 24 | +import java.util.List; |
| 25 | + |
| 26 | +/** |
| 27 | + * BootstrapStatus |
| 28 | + */ |
| 29 | +public class BootstrapStatus { |
| 30 | + |
| 31 | + private BootstrapState status; |
| 32 | + private String currentStep; |
| 33 | + private String completionMessage; |
| 34 | + private Integer completedRecords; |
| 35 | + private Integer totalRecords; |
| 36 | + private List<String> errors = null; |
| 37 | + |
| 38 | + public BootstrapStatus status(BootstrapState status) { |
| 39 | + this.status = status; |
| 40 | + return this; |
| 41 | + } |
| 42 | + |
| 43 | + /** |
| 44 | + * Current bootstrap status |
| 45 | + * @return status |
| 46 | + **/ |
| 47 | + @JsonProperty("status") |
| 48 | + @JsonInclude(value = JsonInclude.Include.ALWAYS) |
| 49 | + public BootstrapState getStatus() { return status; } |
| 50 | + public void setStatus(BootstrapState status) { this.status = status; } |
| 51 | + |
| 52 | + public BootstrapStatus currentStep(String currentStep) { |
| 53 | + this.currentStep = currentStep; |
| 54 | + return this; |
| 55 | + } |
| 56 | + |
| 57 | + /** |
| 58 | + * Current bootstrap activity |
| 59 | + * @return currentStep |
| 60 | + **/ |
| 61 | + @javax.annotation.Nullable |
| 62 | + @JsonProperty("current_step") |
| 63 | + @JsonInclude(value = JsonInclude.Include.NON_NULL) |
| 64 | + public String getCurrentStep() { return currentStep; } |
| 65 | + public void setCurrentStep(String currentStep) { this.currentStep = currentStep; } |
| 66 | + |
| 67 | + public BootstrapStatus completionMessage(String completionMessage) { |
| 68 | + this.completionMessage = completionMessage; |
| 69 | + return this; |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * Overall outcome of the bootstrap process. Set once bootstrapping is finished. |
| 74 | + * @return completionMessage |
| 75 | + **/ |
| 76 | + @javax.annotation.Nullable |
| 77 | + @JsonProperty("completion_message") |
| 78 | + @JsonInclude(value = JsonInclude.Include.NON_NULL) |
| 79 | + public String getCompletionMessage() { return completionMessage; } |
| 80 | + public void setCompletionMessage(String completionMessage) { this.completionMessage = completionMessage; } |
| 81 | + |
| 82 | + public BootstrapStatus completedRecords(Integer completedRecords) { |
| 83 | + this.completedRecords = completedRecords; |
| 84 | + return this; |
| 85 | + } |
| 86 | + |
| 87 | + /** |
| 88 | + * Number of records already bootstrapped successfully |
| 89 | + * @return completedRecords |
| 90 | + **/ |
| 91 | + @javax.annotation.Nullable |
| 92 | + @JsonProperty("completed_records") |
| 93 | + @JsonInclude(value = JsonInclude.Include.NON_NULL) |
| 94 | + public Integer getCompletedRecords() { return completedRecords; } |
| 95 | + public void setCompletedRecords(Integer completedRecords) { this.completedRecords = completedRecords; } |
| 96 | + |
| 97 | + public BootstrapStatus totalRecords(Integer totalRecords) { |
| 98 | + this.totalRecords = totalRecords; |
| 99 | + return this; |
| 100 | + } |
| 101 | + |
| 102 | + /** |
| 103 | + * Total number of records to be processed by the bootstrap process |
| 104 | + * @return totalRecords |
| 105 | + **/ |
| 106 | + @javax.annotation.Nullable |
| 107 | + @JsonProperty("total_records") |
| 108 | + @JsonInclude(value = JsonInclude.Include.NON_NULL) |
| 109 | + public Integer getTotalRecords() { return totalRecords; } |
| 110 | + public void setTotalRecords(Integer totalRecords) { this.totalRecords = totalRecords; } |
| 111 | + |
| 112 | + public BootstrapStatus errors(List<String> errors) { |
| 113 | + this.errors = errors; |
| 114 | + return this; |
| 115 | + } |
| 116 | + |
| 117 | + public BootstrapStatus addErrorsItem(String errorsItem) { |
| 118 | + if (this.errors == null) { |
| 119 | + this.errors = new ArrayList<>(); |
| 120 | + } |
| 121 | + this.errors.add(errorsItem); |
| 122 | + return this; |
| 123 | + } |
| 124 | + |
| 125 | + /** |
| 126 | + * Bootstrap process errors |
| 127 | + * @return errors |
| 128 | + **/ |
| 129 | + @javax.annotation.Nullable |
| 130 | + @JsonProperty("errors") |
| 131 | + @JsonInclude(value = JsonInclude.Include.NON_NULL) |
| 132 | + public List<String> getErrors() { return errors; } |
| 133 | + public void setErrors(List<String> errors) { this.errors = errors; } |
| 134 | + |
| 135 | + @Override |
| 136 | + public boolean equals(Object o) { |
| 137 | + if (this == o) { return true; } |
| 138 | + if (o == null || getClass() != o.getClass()) { return false; } |
| 139 | + BootstrapStatus that = (BootstrapStatus) o; |
| 140 | + return Objects.equals(this.status, that.status) && |
| 141 | + Objects.equals(this.currentStep, that.currentStep) && |
| 142 | + Objects.equals(this.completionMessage, that.completionMessage) && |
| 143 | + Objects.equals(this.completedRecords, that.completedRecords) && |
| 144 | + Objects.equals(this.totalRecords, that.totalRecords) && |
| 145 | + Objects.equals(this.errors, that.errors); |
| 146 | + } |
| 147 | + |
| 148 | + @Override |
| 149 | + public int hashCode() { |
| 150 | + return Objects.hash(status, currentStep, completionMessage, completedRecords, |
| 151 | + totalRecords, errors); |
| 152 | + } |
| 153 | + |
| 154 | + |
| 155 | + @Override |
| 156 | + public String toString() { |
| 157 | + StringBuilder sb = new StringBuilder(); |
| 158 | + sb.append("class BootstrapStatus {\n"); |
| 159 | + sb.append(" status: ").append(toIndentedString(status)).append("\n"); |
| 160 | + sb.append(" currentStep: ").append(toIndentedString(currentStep)).append("\n"); |
| 161 | + sb.append(" completionMessage: ").append(toIndentedString(completionMessage)).append("\n"); |
| 162 | + sb.append(" completedRecords: ").append(toIndentedString(completedRecords)).append("\n"); |
| 163 | + sb.append(" totalRecords: ").append(toIndentedString(totalRecords)).append("\n"); |
| 164 | + sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); |
| 165 | + sb.append("}"); |
| 166 | + return sb.toString(); |
| 167 | + } |
| 168 | + |
| 169 | + /** |
| 170 | + * Convert the given object to string with each line indented by 4 spaces |
| 171 | + * (except the first line). |
| 172 | + */ |
| 173 | + private String toIndentedString(Object o) { |
| 174 | + if (o == null) { return "null"; } |
| 175 | + return o.toString().replace("\n", "\n "); |
| 176 | + } |
| 177 | + |
| 178 | +} |
0 commit comments