// Path: conversation-kit/src/main/java/com/conversationkit/impl/node/DialogTreeNode.java
// 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) {
//             suggestions.add(edge.getPrompt());
//         }
//         return suggestions;
//     }
// 
//     @Override
//     public Iterable<DialogTreeEdge> getEdges() {
//         return edges;
//     }
// 
//     @Override
//     public void addEdge(DialogTreeEdge edge) {
//         edges.add(edge);
//     }
// 
//     @Override
//     public int getId() {
//         return id;
//     }
// 
//     @Override
//     public JsonObject getMetadata() {
//         return metadata;
//     }
//     
//     
// 
// }
// 
// Path: nlu-core/src/main/java/com/conversationkit/model/IConversationIntent.java
// public interface IConversationIntent {
//     /**
//      * @return unique ID for the intent.
//      */
//     public String getIntentId();
//     /**
//      * Slots are parameters collected from the user's input while detecting intent. As an example, a
//      * a slot might be a color. So in the user input, "Press the red button" the intent
//      * might be <code>PRESS_BUTTON</code> with a slot of <code>color</code> set to <code>red</code>.
//      * @return map of slot keys to slot values
//      */
//     public Map<String,Object> getSlots();
//     
//     public boolean getAllRequiredSlotsFilled();
// }
// 
// Path: conversation-kit/src/main/java/com/conversationkit/model/IConversationState.java
// public interface IConversationState <S extends IConversationState> extends Function<Map,S> {
//     /**
//      * @return the id of the node representing the last message sent to the user
//      */
//     public Integer getCurrentNodeId();
//     /**
//      * @return the number of consecutive times the engine has misunderstood the user's input.
//      */
//     public Integer getMisunderstoodCount();
//     /**
//      * @return a unique string representation of the current user
//      */
//     public String getUserId();
//     /**
//      * @return the current state as a Map
//      */
//     public Map getStateAsMap();
// }


import com.conversationkit.impl.node.DialogTreeNode;
import com.conversationkit.model.IConversationIntent;
import com.conversationkit.model.IConversationState;
import java.util.function.BiFunction;
/*
 * 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.edge;


/**
 * A <code>DialogTreeEdge</code> is an implementation of
 * <code>IConversationEdge</code> that connects one
 * <code>IConversationNode</code> that is a question to the
 * <code>IConversationNode</code> matching the answer.
 * <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. Since the user can only answer questions using one
 * the supplied suggestions from the {@link DialogTreeNode}, this edge type does
 * a string match between the answer stored in the edge and the response
 * provided by the user.
 *
 * @author pdtyreus
 */
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;
    }

// Path: conversation-kit/src/main/java/com/conversationkit/impl/node/DialogTreeNode.java
// 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) {
//             suggestions.add(edge.getPrompt());
//         }
//         return suggestions;
//     }
// 
//     @Override
//     public Iterable<DialogTreeEdge> getEdges() {
//         return edges;
//     }
// 
//     @Override
//     public void addEdge(DialogTreeEdge edge) {
//         edges.add(edge);
//     }
// 
//     @Override
//     public int getId() {
//         return id;
//     }
// 
//     @Override
//     public JsonObject getMetadata() {
//         return metadata;
//     }
//     
//     
// 
// }
// 
// Path: nlu-core/src/main/java/com/conversationkit/model/IConversationIntent.java
// public interface IConversationIntent {
//     /**
//      * @return unique ID for the intent.
//      */
//     public String getIntentId();
//     /**
//      * Slots are parameters collected from the user's input while detecting intent. As an example, a
//      * a slot might be a color. So in the user input, "Press the red button" the intent
//      * might be <code>PRESS_BUTTON</code> with a slot of <code>color</code> set to <code>red</code>.
//      * @return map of slot keys to slot values
//      */
//     public Map<String,Object> getSlots();
//     
//     public boolean getAllRequiredSlotsFilled();
// }
// 
// Path: conversation-kit/src/main/java/com/conversationkit/model/IConversationState.java
// public interface IConversationState <S extends IConversationState> extends Function<Map,S> {
//     /**
//      * @return the id of the node representing the last message sent to the user
//      */
//     public Integer getCurrentNodeId();
//     /**
//      * @return the number of consecutive times the engine has misunderstood the user's input.
//      */
//     public Integer getMisunderstoodCount();
//     /**
//      * @return a unique string representation of the current user
//      */
//     public String getUserId();
//     /**
//      * @return the current state as a Map
//      */
//     public Map getStateAsMap();
// }


// Path: conversation-kit/src/main/java/com/conversationkit/impl/edge/DialogTreeEdge.java
import com.conversationkit.impl.node.DialogTreeNode;
import com.conversationkit.model.IConversationIntent;
import com.conversationkit.model.IConversationState;
import java.util.function.BiFunction;

/*
 * 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.edge;


/**
 * A <code>DialogTreeEdge</code> is an implementation of
 * <code>IConversationEdge</code> that connects one
 * <code>IConversationNode</code> that is a question to the
 * <code>IConversationNode</code> matching the answer.
 * <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. Since the user can only answer questions using one
 * the supplied suggestions from the {@link DialogTreeNode}, this edge type does
 * a string match between the answer stored in the edge and the response
 * provided by the user.
 *
 * @author pdtyreus
 */
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) {