All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ibm.watson.assistant.v1.model.OutputData Maven / Gradle / Ivy

There is a newer version: 13.0.0
Show newest version
/*
 * (C) Copyright IBM Corp. 2017, 2020.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 */
package com.ibm.watson.assistant.v1.model;

import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import com.ibm.cloud.sdk.core.service.model.DynamicModel;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * An output object that includes the response to the user, the dialog nodes that were triggered,
 * and messages from the log.
 */
public class OutputData extends DynamicModel {

  @SerializedName("nodes_visited")
  protected List nodesVisited;

  @SerializedName("nodes_visited_details")
  protected List nodesVisitedDetails;

  @SerializedName("log_messages")
  protected List logMessages;

  @SerializedName("text")
  protected List text;

  @SerializedName("generic")
  protected List generic;

  public OutputData() {
    super(new TypeToken() {});
  }

  /** Builder. */
  public static class Builder {
    private List nodesVisited;
    private List nodesVisitedDetails;
    private List logMessages;
    private List text;
    private List generic;
    private Map dynamicProperties;

    private Builder(OutputData outputData) {
      this.nodesVisited = outputData.nodesVisited;
      this.nodesVisitedDetails = outputData.nodesVisitedDetails;
      this.logMessages = outputData.logMessages;
      this.text = outputData.text;
      this.generic = outputData.generic;
      this.dynamicProperties = outputData.getProperties();
    }

    /** Instantiates a new builder. */
    public Builder() {}

    /**
     * Instantiates a new builder with required properties.
     *
     * @param logMessages the logMessages
     * @param text the text
     */
    public Builder(List logMessages, List text) {
      this.logMessages = logMessages;
      this.text = text;
    }

    /**
     * Builds a OutputData.
     *
     * @return the new OutputData instance
     */
    public OutputData build() {
      return new OutputData(this);
    }

    /**
     * Adds an nodesVisited to nodesVisited.
     *
     * @param nodesVisited the new nodesVisited
     * @return the OutputData builder
     */
    public Builder addNodesVisited(String nodesVisited) {
      com.ibm.cloud.sdk.core.util.Validator.notNull(nodesVisited, "nodesVisited cannot be null");
      if (this.nodesVisited == null) {
        this.nodesVisited = new ArrayList();
      }
      this.nodesVisited.add(nodesVisited);
      return this;
    }

    /**
     * Adds an nodesVisitedDetails to nodesVisitedDetails.
     *
     * @param nodesVisitedDetails the new nodesVisitedDetails
     * @return the OutputData builder
     */
    public Builder addNodesVisitedDetails(DialogNodeVisitedDetails nodesVisitedDetails) {
      com.ibm.cloud.sdk.core.util.Validator.notNull(
          nodesVisitedDetails, "nodesVisitedDetails cannot be null");
      if (this.nodesVisitedDetails == null) {
        this.nodesVisitedDetails = new ArrayList();
      }
      this.nodesVisitedDetails.add(nodesVisitedDetails);
      return this;
    }

    /**
     * Adds an logMessages to logMessages.
     *
     * @param logMessages the new logMessages
     * @return the OutputData builder
     */
    public Builder addLogMessages(LogMessage logMessages) {
      com.ibm.cloud.sdk.core.util.Validator.notNull(logMessages, "logMessages cannot be null");
      if (this.logMessages == null) {
        this.logMessages = new ArrayList();
      }
      this.logMessages.add(logMessages);
      return this;
    }

    /**
     * Adds an text to text.
     *
     * @param text the new text
     * @return the OutputData builder
     */
    public Builder addText(String text) {
      com.ibm.cloud.sdk.core.util.Validator.notNull(text, "text cannot be null");
      if (this.text == null) {
        this.text = new ArrayList();
      }
      this.text.add(text);
      return this;
    }

    /**
     * Adds an generic to generic.
     *
     * @param generic the new generic
     * @return the OutputData builder
     */
    public Builder addGeneric(RuntimeResponseGeneric generic) {
      com.ibm.cloud.sdk.core.util.Validator.notNull(generic, "generic cannot be null");
      if (this.generic == null) {
        this.generic = new ArrayList();
      }
      this.generic.add(generic);
      return this;
    }

    /**
     * Set the nodesVisited. Existing nodesVisited will be replaced.
     *
     * @param nodesVisited the nodesVisited
     * @return the OutputData builder
     */
    public Builder nodesVisited(List nodesVisited) {
      this.nodesVisited = nodesVisited;
      return this;
    }

    /**
     * Set the nodesVisitedDetails. Existing nodesVisitedDetails will be replaced.
     *
     * @param nodesVisitedDetails the nodesVisitedDetails
     * @return the OutputData builder
     */
    public Builder nodesVisitedDetails(List nodesVisitedDetails) {
      this.nodesVisitedDetails = nodesVisitedDetails;
      return this;
    }

    /**
     * Set the logMessages. Existing logMessages will be replaced.
     *
     * @param logMessages the logMessages
     * @return the OutputData builder
     */
    public Builder logMessages(List logMessages) {
      this.logMessages = logMessages;
      return this;
    }

    /**
     * Set the text. Existing text will be replaced.
     *
     * @param text the text
     * @return the OutputData builder
     */
    public Builder text(List text) {
      this.text = text;
      return this;
    }

    /**
     * Set the generic. Existing generic will be replaced.
     *
     * @param generic the generic
     * @return the OutputData builder
     */
    public Builder generic(List generic) {
      this.generic = generic;
      return this;
    }

    /**
     * Add an arbitrary property.
     *
     * @param name the name of the property to add
     * @param value the value of the property to add
     * @return the OutputData builder
     */
    public Builder add(String name, Object value) {
      com.ibm.cloud.sdk.core.util.Validator.notNull(name, "name cannot be null");
      if (this.dynamicProperties == null) {
        this.dynamicProperties = new HashMap();
      }
      this.dynamicProperties.put(name, value);
      return this;
    }
  }

  protected OutputData(Builder builder) {
    super(new TypeToken() {});
    com.ibm.cloud.sdk.core.util.Validator.notNull(
        builder.logMessages, "logMessages cannot be null");
    com.ibm.cloud.sdk.core.util.Validator.notNull(builder.text, "text cannot be null");
    nodesVisited = builder.nodesVisited;
    nodesVisitedDetails = builder.nodesVisitedDetails;
    logMessages = builder.logMessages;
    text = builder.text;
    generic = builder.generic;
    this.setProperties(builder.dynamicProperties);
  }

  /**
   * New builder.
   *
   * @return a OutputData builder
   */
  public Builder newBuilder() {
    return new Builder(this);
  }

  /**
   * Gets the nodesVisited.
   *
   * 

An array of the nodes that were triggered to create the response, in the order in which they * were visited. This information is useful for debugging and for tracing the path taken through * the node tree. * * @return the nodesVisited */ public List getNodesVisited() { return this.nodesVisited; } /** * Sets the nodesVisited. * * @param nodesVisited the new nodesVisited */ public void setNodesVisited(final List nodesVisited) { this.nodesVisited = nodesVisited; } /** * Gets the nodesVisitedDetails. * *

An array of objects containing detailed diagnostic information about the nodes that were * triggered during processing of the input message. Included only if **nodes_visited_details** is * set to `true` in the message request. * * @return the nodesVisitedDetails */ public List getNodesVisitedDetails() { return this.nodesVisitedDetails; } /** * Sets the nodesVisitedDetails. * * @param nodesVisitedDetails the new nodesVisitedDetails */ public void setNodesVisitedDetails(final List nodesVisitedDetails) { this.nodesVisitedDetails = nodesVisitedDetails; } /** * Gets the logMessages. * *

An array of up to 50 messages logged with the request. * * @return the logMessages */ public List getLogMessages() { return this.logMessages; } /** * Sets the logMessages. * * @param logMessages the new logMessages */ public void setLogMessages(final List logMessages) { this.logMessages = logMessages; } /** * Gets the text. * *

An array of responses to the user. * * @return the text */ public List getText() { return this.text; } /** * Sets the text. * * @param text the new text */ public void setText(final List text) { this.text = text; } /** * Gets the generic. * *

Output intended for any channel. It is the responsibility of the client application to * implement the supported response types. * * @return the generic */ public List getGeneric() { return this.generic; } /** * Sets the generic. * * @param generic the new generic */ public void setGeneric(final List generic) { this.generic = generic; } }