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

com.twilio.twiml.voice.SsmlEmphasis Maven / Gradle / Ivy

There is a newer version: 10.1.5
Show newest version
/**
 * This code was generated by
 * \ / _    _  _|   _  _
 *  | (_)\/(_)(_|\/| |(/_  v1.0.0
 *       /       /
 */

package com.twilio.twiml.voice;

import com.twilio.twiml.TwiML;

import java.util.HashMap;
import java.util.Map;

/**
 * TwiML wrapper for {@code }
 */
public class SsmlEmphasis extends TwiML {
    public enum Level {
        STRONG("strong"),
        MODERATE("moderate"),
        REDUCED("reduced");

        private final String value;

        private Level(final String value) {
            this.value = value;
        }

        public String toString() {
            return value;
        }
    }

    private final SsmlEmphasis.Level level;
    private final String words;

    /**
     * For XML Serialization/Deserialization
     */
    private SsmlEmphasis() {
        this(new Builder((String) null));
    }

    /**
     * Create a new {@code } element
     */
    private SsmlEmphasis(Builder b) {
        super("emphasis", b);
        this.level = b.level;
        this.words = b.words;
    }

    /**
     * The body of the TwiML element
     *
     * @return Element body as a string if present else null
     */
    protected String getElementBody() {
        return this.getWords() == null ? null : this.getWords();
    }

    /**
     * Attributes to set on the generated XML element
     *
     * @return A Map of attribute keys to values
     */
    protected Map getElementAttributes() {
        // Preserve order of attributes
        Map attrs = new HashMap<>();

        if (this.getLevel() != null) {
            attrs.put("level", this.getLevel().toString());
        }

        return attrs;
    }

    /**
     * Specify the degree of emphasis
     *
     * @return Specify the degree of emphasis
     */
    public SsmlEmphasis.Level getLevel() {
        return level;
    }

    /**
     * Words to emphasize
     *
     * @return Words to emphasize
     */
    public String getWords() {
        return words;
    }

    /**
     * Create a new {@code } element
     */
    public static class Builder extends TwiML.Builder {
        private SsmlEmphasis.Level level;
        private String words;

        /**
         * Create a {@code } with words
         */
        public Builder(String words) {
            this.words = words;
        }

        /**
         * Specify the degree of emphasis
         */
        public Builder level(SsmlEmphasis.Level level) {
            this.level = level;
            return this;
        }

        /**
         * Create and return resulting {@code } element
         */
        public SsmlEmphasis build() {
            return new SsmlEmphasis(this);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy