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

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

There is a newer version: 10.7.0
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 SsmlBreak extends TwiML {
    public enum Strength {
        NONE("none"),
        X_WEAK("x-weak"),
        WEAK("weak"),
        MEDIUM("medium"),
        STRONG("strong"),
        X_STRONG("x-strong");

        private final String value;

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

        public String toString() {
            return value;
        }
    }

    private final SsmlBreak.Strength strength;
    private final String time;

    /**
     * For XML Serialization/Deserialization
     */
    private SsmlBreak() {
        this(new Builder());
    }

    /**
     * Create a new {@code } element
     */
    private SsmlBreak(Builder b) {
        super("break", b);
        this.strength = b.strength;
        this.time = b.time;
    }

    /**
     * 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.getStrength() != null) {
            attrs.put("strength", this.getStrength().toString());
        }
        if (this.getTime() != null) {
            attrs.put("time", this.getTime());
        }

        return attrs;
    }

    /**
     * Set a pause based on strength
     * 
     * @return Set a pause based on strength
     */
    public SsmlBreak.Strength getStrength() {
        return strength;
    }

    /**
     * Set a pause to a specific length of time in seconds or milliseconds,
     * available values: [number]s, [number]ms
     * 
     * @return Set a pause to a specific length of time in seconds or milliseconds,
     *         available values: [number]s, [number]ms
     */
    public String getTime() {
        return time;
    }

    /**
     * Create a new {@code } element
     */
    public static class Builder extends TwiML.Builder {
        private SsmlBreak.Strength strength;
        private String time;

        /**
         * Set a pause based on strength
         */
        public Builder strength(SsmlBreak.Strength strength) {
            this.strength = strength;
            return this;
        }

        /**
         * Set a pause to a specific length of time in seconds or milliseconds,
         * available values: [number]s, [number]ms
         */
        public Builder time(String time) {
            this.time = time;
            return this;
        }

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy