// Path: conversation-kit/src/main/java/com/conversationkit/impl/edge/DialogTreeEdge.java
// public class DialogTreeEdge extends ConversationEdge {
// 
//     private final String prompt;
// 
//     /**
//      * Only an exact match for the answer stored in this node will cause the
//      * conversion to advance to the endNode.
//      *
//      * @param prompt string value to match
//      * @param intentId intent id
//      * @param endNodeId next node id in the conversation
//      */
//     public DialogTreeEdge(Integer endNodeId, String intentId, String prompt) {
//         super(endNodeId, intentId);
//         this.prompt = prompt;
//     }
// 
//     public DialogTreeEdge(Integer endNodeId, String intentId, String prompt, BiFunction<IConversationIntent, IConversationState, Object>... sideEffects) {
//         super(endNodeId, intentId, (intent, state) -> {
//             return true;
//         }, sideEffects);
//         this.prompt = prompt;
//     }
// 
//     @Override
//     public String toString() {
//         return "DialogTreeEdge {" + getIntentId() + '}';
//     }
// 
//     public String getPrompt() {
//         return prompt;
//     }
// }
// 
// Path: conversation-kit/src/main/java/com/conversationkit/model/IConversationEdge.java
// public interface IConversationEdge<I extends IConversationIntent, S extends IConversationState> {
// 
//     public Integer getEndNodeId();
//     
//     public String getIntentId();
//     
//     /**
//      * Additional logic to perform before continuing the conversation along this edge. It's possible for
//      * a node to have multiple edges with the same intentId. Each edge could have different preconditions
//      * that must be met in order to match. The validate function allows the engine to check the preconditions
//      * against the current state and return true or false. If the edge intent matches but the validate
//      * fails, the engine will look at the next edge with the same intent.
//      * @param intent the intent from the current user input
//      * @param state the current conversation sate
//      * @return true if the edge should validate, false otherwise
//      */
//     public boolean validate(I intent, S state);
//     
//     /**
//      * Side effects that should occur if this edge is validated. Side effects are
//      * ways to change the state before the next step in the conversation. The type
//      * of Object returned depends on the {@link Redux} {@link Middleware}s that are installed.
//      * <p>
//      * Side effects should be used to perform actions like loading additional data
//      * from a web service or database that is required to respond to the user. The state
//      * that is passed in should not be modified directly. Instead the list of actions
//      * returned will be passed sequentially to the Redux middleware chain and executed in order.
//      * @param intent the validated intent
//      * @param state immutable copy of the state
//      * @return a list of actions to perform before the next conversation step
//      */
//     public List<Object> getSideEffects(I intent, S state);
// }
// 
// Path: conversation-kit/src/main/java/com/conversationkit/model/IConversationNode.java
// public interface IConversationNode<E extends IConversationEdge> {
// 
//     /**
//      * Returns a list of outbound edges from the current node. One matching 
//      * edge may be chosen to continue the conversation to the next node.
//      * @return outbound edges
//      */
//     public Iterable<E> getEdges();
// 
//     /**
//      * Adds an edge to the list of possible outbound edges.
//      * @param edge edge to add
//      */
//     public void addEdge(E edge);
// 
//     /**
//      * Returns the unique identifier for this node.
//      * @return the node id
//      */
//     public int getId();
//     
//     /**
//      * Node metadata is any additional information the node may
//      * need to build platform-specific implementations of itself. The values stored
//      * in the metadata will be highly dependent on the final use case and is
//      * designed to be highly flexible. 
//      * @return JSON metadata
//      */
//     public JsonObject getMetadata();
//     
// }


import com.conversationkit.impl.edge.DialogTreeEdge;
import com.conversationkit.model.IConversationEdge;
import com.conversationkit.model.IConversationNode;
import com.eclipsesource.json.JsonObject;
import java.util.ArrayList;
import java.util.List;
/*
 * The MIT License
 *
 * Copyright 2016 Synclab Consulting LLC.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package com.conversationkit.impl.node;


/**
 * A <code>DialogTreeNode</code> is an implementation of 
 * <code>IConversationNode</code> that
 * holds an array of messages to return as the response to the user.
 * <p>
 * A dialog tree is a type of branching conversation often seen in adventure
 * video games. The user is given a choice of what to say and makes subsequent
 * choices until the conversation ends. The responses to the user are scripted
 * based on the choices made. Each DialogTreeNode represents either a question
 * or statement presented to the user by the bot.
 *
 * @author pdtyreus
 */
public class DialogTreeNode implements IConversationNode<DialogTreeEdge> {

    protected final List<String> messages;
    protected final List<DialogTreeEdge> edges;
    private final int id;
    private final JsonObject metadata;

    /**
     * Creates a node with the specified text.
     *
     * @param id the unique ID of the node from the underlying data store
     * @param messages the text responses displayed to the user
     */
    public DialogTreeNode(int id, List<String> messages) {
        this.id = id;
        this.edges = new ArrayList();
        this.metadata = new JsonObject();
        this.messages = messages;
    }

    public List<String> getMessages() {
        return messages;
    }
    
    public List<String> getSuggestedResponses() {
        List<String> suggestions = new ArrayList();
// Path: conversation-kit/src/main/java/com/conversationkit/impl/edge/DialogTreeEdge.java
// public class DialogTreeEdge extends ConversationEdge {
// 
//     private final String prompt;
// 
//     /**
//      * Only an exact match for the answer stored in this node will cause the
//      * conversion to advance to the endNode.
//      *
//      * @param prompt string value to match
//      * @param intentId intent id
//      * @param endNodeId next node id in the conversation
//      */
//     public DialogTreeEdge(Integer endNodeId, String intentId, String prompt) {
//         super(endNodeId, intentId);
//         this.prompt = prompt;
//     }
// 
//     public DialogTreeEdge(Integer endNodeId, String intentId, String prompt, BiFunction<IConversationIntent, IConversationState, Object>... sideEffects) {
//         super(endNodeId, intentId, (intent, state) -> {
//             return true;
//         }, sideEffects);
//         this.prompt = prompt;
//     }
// 
//     @Override
//     public String toString() {
//         return "DialogTreeEdge {" + getIntentId() + '}';
//     }
// 
//     public String getPrompt() {
//         return prompt;
//     }
// }
// 
// Path: conversation-kit/src/main/java/com/conversationkit/model/IConversationEdge.java
// public interface IConversationEdge<I extends IConversationIntent, S extends IConversationState> {
// 
//     public Integer getEndNodeId();
//     
//     public String getIntentId();
//     
//     /**
//      * Additional logic to perform before continuing the conversation along this edge. It's possible for
//      * a node to have multiple edges with the same intentId. Each edge could have different preconditions
//      * that must be met in order to match. The validate function allows the engine to check the preconditions
//      * against the current state and return true or false. If the edge intent matches but the validate
//      * fails, the engine will look at the next edge with the same intent.
//      * @param intent the intent from the current user input
//      * @param state the current conversation sate
//      * @return true if the edge should validate, false otherwise
//      */
//     public boolean validate(I intent, S state);
//     
//     /**
//      * Side effects that should occur if this edge is validated. Side effects are
//      * ways to change the state before the next step in the conversation. The type
//      * of Object returned depends on the {@link Redux} {@link Middleware}s that are installed.
//      * <p>
//      * Side effects should be used to perform actions like loading additional data
//      * from a web service or database that is required to respond to the user. The state
//      * that is passed in should not be modified directly. Instead the list of actions
//      * returned will be passed sequentially to the Redux middleware chain and executed in order.
//      * @param intent the validated intent
//      * @param state immutable copy of the state
//      * @return a list of actions to perform before the next conversation step
//      */
//     public List<Object> getSideEffects(I intent, S state);
// }
// 
// Path: conversation-kit/src/main/java/com/conversationkit/model/IConversationNode.java
// public interface IConversationNode<E extends IConversationEdge> {
// 
//     /**
//      * Returns a list of outbound edges from the current node. One matching 
//      * edge may be chosen to continue the conversation to the next node.
//      * @return outbound edges
//      */
//     public Iterable<E> getEdges();
// 
//     /**
//      * Adds an edge to the list of possible outbound edges.
//      * @param edge edge to add
//      */
//     public void addEdge(E edge);
// 
//     /**
//      * Returns the unique identifier for this node.
//      * @return the node id
//      */
//     public int getId();
//     
//     /**
//      * Node metadata is any additional information the node may
//      * need to build platform-specific implementations of itself. The values stored
//      * in the metadata will be highly dependent on the final use case and is
//      * designed to be highly flexible. 
//      * @return JSON metadata
//      */
//     public JsonObject getMetadata();
//     
// }


// Path: conversation-kit/src/main/java/com/conversationkit/impl/node/DialogTreeNode.java
import com.conversationkit.impl.edge.DialogTreeEdge;
import com.conversationkit.model.IConversationEdge;
import com.conversationkit.model.IConversationNode;
import com.eclipsesource.json.JsonObject;
import java.util.ArrayList;
import java.util.List;

/*
 * The MIT License
 *
 * Copyright 2016 Synclab Consulting LLC.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package com.conversationkit.impl.node;


/**
 * A <code>DialogTreeNode</code> is an implementation of 
 * <code>IConversationNode</code> that
 * holds an array of messages to return as the response to the user.
 * <p>
 * A dialog tree is a type of branching conversation often seen in adventure
 * video games. The user is given a choice of what to say and makes subsequent
 * choices until the conversation ends. The responses to the user are scripted
 * based on the choices made. Each DialogTreeNode represents either a question
 * or statement presented to the user by the bot.
 *
 * @author pdtyreus
 */
public class DialogTreeNode implements IConversationNode<DialogTreeEdge> {

    protected final List<String> messages;
    protected final List<DialogTreeEdge> edges;
    private final int id;
    private final JsonObject metadata;

    /**
     * Creates a node with the specified text.
     *
     * @param id the unique ID of the node from the underlying data store
     * @param messages the text responses displayed to the user
     */
    public DialogTreeNode(int id, List<String> messages) {
        this.id = id;
        this.edges = new ArrayList();
        this.metadata = new JsonObject();
        this.messages = messages;
    }

    public List<String> getMessages() {
        return messages;
    }
    
    public List<String> getSuggestedResponses() {
        List<String> suggestions = new ArrayList();
        for (DialogTreeEdge edge : edges) {