|
| 1 | +/* |
| 2 | + * Copyright 2010-2021 Amazon.com, Inc. or its affiliates. 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 | + * A copy of the License is located at |
| 7 | + * |
| 8 | + * http://aws.amazon.com/apache2.0 |
| 9 | + * |
| 10 | + * or in the "license" file accompanying this file. This file is distributed |
| 11 | + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 12 | + * express or implied. See the License for the specific language governing |
| 13 | + * permissions and limitations under the License. |
| 14 | + */ |
| 15 | + |
| 16 | +package com.amazonaws.services.lexrts.model; |
| 17 | + |
| 18 | +import java.io.Serializable; |
| 19 | + |
| 20 | +/** |
| 21 | + * <p> |
| 22 | + * A context is a variable that contains information about the current state of |
| 23 | + * the conversation between a user and Amazon Lex. Context can be set |
| 24 | + * automatically by Amazon Lex when an intent is fulfilled, or it can be set at |
| 25 | + * runtime using the <code>PutContent</code>, <code>PutText</code>, or |
| 26 | + * <code>PutSession</code> operation. |
| 27 | + * </p> |
| 28 | + */ |
| 29 | +public class ActiveContext implements Serializable { |
| 30 | + /** |
| 31 | + * <p> |
| 32 | + * The name of the context. |
| 33 | + * </p> |
| 34 | + * <p> |
| 35 | + * <b>Constraints:</b><br/> |
| 36 | + * <b>Length: </b>1 - 100<br/> |
| 37 | + * <b>Pattern: </b>^([A-Za-z]_?)+$<br/> |
| 38 | + */ |
| 39 | + private String name; |
| 40 | + |
| 41 | + /** |
| 42 | + * <p> |
| 43 | + * The length of time or number of turns that a context remains active. |
| 44 | + * </p> |
| 45 | + */ |
| 46 | + private ActiveContextTimeToLive timeToLive; |
| 47 | + |
| 48 | + /** |
| 49 | + * <p> |
| 50 | + * State variables for the current context. You can use these values as |
| 51 | + * default values for slots in subsequent events. |
| 52 | + * </p> |
| 53 | + */ |
| 54 | + private java.util.Map<String, String> parameters; |
| 55 | + |
| 56 | + /** |
| 57 | + * <p> |
| 58 | + * The name of the context. |
| 59 | + * </p> |
| 60 | + * <p> |
| 61 | + * <b>Constraints:</b><br/> |
| 62 | + * <b>Length: </b>1 - 100<br/> |
| 63 | + * <b>Pattern: </b>^([A-Za-z]_?)+$<br/> |
| 64 | + * |
| 65 | + * @return <p> |
| 66 | + * The name of the context. |
| 67 | + * </p> |
| 68 | + */ |
| 69 | + public String getName() { |
| 70 | + return name; |
| 71 | + } |
| 72 | + |
| 73 | + /** |
| 74 | + * <p> |
| 75 | + * The name of the context. |
| 76 | + * </p> |
| 77 | + * <p> |
| 78 | + * <b>Constraints:</b><br/> |
| 79 | + * <b>Length: </b>1 - 100<br/> |
| 80 | + * <b>Pattern: </b>^([A-Za-z]_?)+$<br/> |
| 81 | + * |
| 82 | + * @param name <p> |
| 83 | + * The name of the context. |
| 84 | + * </p> |
| 85 | + */ |
| 86 | + public void setName(String name) { |
| 87 | + this.name = name; |
| 88 | + } |
| 89 | + |
| 90 | + /** |
| 91 | + * <p> |
| 92 | + * The name of the context. |
| 93 | + * </p> |
| 94 | + * <p> |
| 95 | + * Returns a reference to this object so that method calls can be chained |
| 96 | + * together. |
| 97 | + * <p> |
| 98 | + * <b>Constraints:</b><br/> |
| 99 | + * <b>Length: </b>1 - 100<br/> |
| 100 | + * <b>Pattern: </b>^([A-Za-z]_?)+$<br/> |
| 101 | + * |
| 102 | + * @param name <p> |
| 103 | + * The name of the context. |
| 104 | + * </p> |
| 105 | + * @return A reference to this updated object so that method calls can be |
| 106 | + * chained together. |
| 107 | + */ |
| 108 | + public ActiveContext withName(String name) { |
| 109 | + this.name = name; |
| 110 | + return this; |
| 111 | + } |
| 112 | + |
| 113 | + /** |
| 114 | + * <p> |
| 115 | + * The length of time or number of turns that a context remains active. |
| 116 | + * </p> |
| 117 | + * |
| 118 | + * @return <p> |
| 119 | + * The length of time or number of turns that a context remains |
| 120 | + * active. |
| 121 | + * </p> |
| 122 | + */ |
| 123 | + public ActiveContextTimeToLive getTimeToLive() { |
| 124 | + return timeToLive; |
| 125 | + } |
| 126 | + |
| 127 | + /** |
| 128 | + * <p> |
| 129 | + * The length of time or number of turns that a context remains active. |
| 130 | + * </p> |
| 131 | + * |
| 132 | + * @param timeToLive <p> |
| 133 | + * The length of time or number of turns that a context remains |
| 134 | + * active. |
| 135 | + * </p> |
| 136 | + */ |
| 137 | + public void setTimeToLive(ActiveContextTimeToLive timeToLive) { |
| 138 | + this.timeToLive = timeToLive; |
| 139 | + } |
| 140 | + |
| 141 | + /** |
| 142 | + * <p> |
| 143 | + * The length of time or number of turns that a context remains active. |
| 144 | + * </p> |
| 145 | + * <p> |
| 146 | + * Returns a reference to this object so that method calls can be chained |
| 147 | + * together. |
| 148 | + * |
| 149 | + * @param timeToLive <p> |
| 150 | + * The length of time or number of turns that a context remains |
| 151 | + * active. |
| 152 | + * </p> |
| 153 | + * @return A reference to this updated object so that method calls can be |
| 154 | + * chained together. |
| 155 | + */ |
| 156 | + public ActiveContext withTimeToLive(ActiveContextTimeToLive timeToLive) { |
| 157 | + this.timeToLive = timeToLive; |
| 158 | + return this; |
| 159 | + } |
| 160 | + |
| 161 | + /** |
| 162 | + * <p> |
| 163 | + * State variables for the current context. You can use these values as |
| 164 | + * default values for slots in subsequent events. |
| 165 | + * </p> |
| 166 | + * |
| 167 | + * @return <p> |
| 168 | + * State variables for the current context. You can use these values |
| 169 | + * as default values for slots in subsequent events. |
| 170 | + * </p> |
| 171 | + */ |
| 172 | + public java.util.Map<String, String> getParameters() { |
| 173 | + return parameters; |
| 174 | + } |
| 175 | + |
| 176 | + /** |
| 177 | + * <p> |
| 178 | + * State variables for the current context. You can use these values as |
| 179 | + * default values for slots in subsequent events. |
| 180 | + * </p> |
| 181 | + * |
| 182 | + * @param parameters <p> |
| 183 | + * State variables for the current context. You can use these |
| 184 | + * values as default values for slots in subsequent events. |
| 185 | + * </p> |
| 186 | + */ |
| 187 | + public void setParameters(java.util.Map<String, String> parameters) { |
| 188 | + this.parameters = parameters; |
| 189 | + } |
| 190 | + |
| 191 | + /** |
| 192 | + * <p> |
| 193 | + * State variables for the current context. You can use these values as |
| 194 | + * default values for slots in subsequent events. |
| 195 | + * </p> |
| 196 | + * <p> |
| 197 | + * Returns a reference to this object so that method calls can be chained |
| 198 | + * together. |
| 199 | + * |
| 200 | + * @param parameters <p> |
| 201 | + * State variables for the current context. You can use these |
| 202 | + * values as default values for slots in subsequent events. |
| 203 | + * </p> |
| 204 | + * @return A reference to this updated object so that method calls can be |
| 205 | + * chained together. |
| 206 | + */ |
| 207 | + public ActiveContext withParameters(java.util.Map<String, String> parameters) { |
| 208 | + this.parameters = parameters; |
| 209 | + return this; |
| 210 | + } |
| 211 | + |
| 212 | + /** |
| 213 | + * <p> |
| 214 | + * State variables for the current context. You can use these values as |
| 215 | + * default values for slots in subsequent events. |
| 216 | + * </p> |
| 217 | + * <p> |
| 218 | + * The method adds a new key-value pair into parameters parameter, and |
| 219 | + * returns a reference to this object so that method calls can be chained |
| 220 | + * together. |
| 221 | + * |
| 222 | + * @param key The key of the entry to be added into parameters. |
| 223 | + * @param value The corresponding value of the entry to be added into |
| 224 | + * parameters. |
| 225 | + * @return A reference to this updated object so that method calls can be |
| 226 | + * chained together. |
| 227 | + */ |
| 228 | + public ActiveContext addparametersEntry(String key, String value) { |
| 229 | + if (null == this.parameters) { |
| 230 | + this.parameters = new java.util.HashMap<String, String>(); |
| 231 | + } |
| 232 | + if (this.parameters.containsKey(key)) |
| 233 | + throw new IllegalArgumentException("Duplicated keys (" + key.toString() |
| 234 | + + ") are provided."); |
| 235 | + this.parameters.put(key, value); |
| 236 | + return this; |
| 237 | + } |
| 238 | + |
| 239 | + /** |
| 240 | + * Removes all the entries added into parameters. |
| 241 | + * <p> |
| 242 | + * Returns a reference to this object so that method calls can be chained |
| 243 | + * together. |
| 244 | + */ |
| 245 | + public ActiveContext clearparametersEntries() { |
| 246 | + this.parameters = null; |
| 247 | + return this; |
| 248 | + } |
| 249 | + |
| 250 | + /** |
| 251 | + * Returns a string representation of this object; useful for testing and |
| 252 | + * debugging. |
| 253 | + * |
| 254 | + * @return A string representation of this object. |
| 255 | + * @see java.lang.Object#toString() |
| 256 | + */ |
| 257 | + @Override |
| 258 | + public String toString() { |
| 259 | + StringBuilder sb = new StringBuilder(); |
| 260 | + sb.append("{"); |
| 261 | + if (getName() != null) |
| 262 | + sb.append("name: " + getName() + ","); |
| 263 | + if (getTimeToLive() != null) |
| 264 | + sb.append("timeToLive: " + getTimeToLive() + ","); |
| 265 | + if (getParameters() != null) |
| 266 | + sb.append("parameters: " + getParameters()); |
| 267 | + sb.append("}"); |
| 268 | + return sb.toString(); |
| 269 | + } |
| 270 | + |
| 271 | + @Override |
| 272 | + public int hashCode() { |
| 273 | + final int prime = 31; |
| 274 | + int hashCode = 1; |
| 275 | + |
| 276 | + hashCode = prime * hashCode + ((getName() == null) ? 0 : getName().hashCode()); |
| 277 | + hashCode = prime * hashCode + ((getTimeToLive() == null) ? 0 : getTimeToLive().hashCode()); |
| 278 | + hashCode = prime * hashCode + ((getParameters() == null) ? 0 : getParameters().hashCode()); |
| 279 | + return hashCode; |
| 280 | + } |
| 281 | + |
| 282 | + @Override |
| 283 | + public boolean equals(Object obj) { |
| 284 | + if (this == obj) |
| 285 | + return true; |
| 286 | + if (obj == null) |
| 287 | + return false; |
| 288 | + |
| 289 | + if (obj instanceof ActiveContext == false) |
| 290 | + return false; |
| 291 | + ActiveContext other = (ActiveContext) obj; |
| 292 | + |
| 293 | + if (other.getName() == null ^ this.getName() == null) |
| 294 | + return false; |
| 295 | + if (other.getName() != null && other.getName().equals(this.getName()) == false) |
| 296 | + return false; |
| 297 | + if (other.getTimeToLive() == null ^ this.getTimeToLive() == null) |
| 298 | + return false; |
| 299 | + if (other.getTimeToLive() != null |
| 300 | + && other.getTimeToLive().equals(this.getTimeToLive()) == false) |
| 301 | + return false; |
| 302 | + if (other.getParameters() == null ^ this.getParameters() == null) |
| 303 | + return false; |
| 304 | + if (other.getParameters() != null |
| 305 | + && other.getParameters().equals(this.getParameters()) == false) |
| 306 | + return false; |
| 307 | + return true; |
| 308 | + } |
| 309 | +} |
0 commit comments