package org.studiorailgun.conversation.synthesis;

import java.util.List;

import org.studiorailgun.knowledge.Node;

/**
 * Quality noun synthesizers
 */
public class QualitySynthesizer {
    
    /**
     * Synthesizes a noun to describe a quality
     * @param nodes The collection of nodes that are the quality
     * @param quality The type of quality (color, time, weight, etc)
     * @return The text of the noun
     */
    public static String synthesize(List<Node> nodes, Node quality){
        switch(quality.getName()){
            case "Color":
            case "color": {
                return summarizeColor(nodes);
            }
            default: {
                throw new Error("Unhandled quality type! " + quality.getName());
            }
        }
    }

    /**
     * Sumarizes a set of colors into text
     * @param nodes The colors
     * @return The text
     */
    private static String summarizeColor(List<Node> nodes){
        if(nodes.size() < 1){
            throw new Error("No colors available!");
        }
        return nodes.get(0).getName();
    }

}
