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

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

/**
 * This code was generated by
 * \ / _    _  _|   _  _
 *  | (_)\/(_)(_|\/| |(/_  v1.0.0
 *       /       /
 */

package com.twilio.twiml.voice;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.twilio.twiml.TwiML;
import com.twilio.twiml.TwiMLException;

/**
 * TwiML wrapper for {@code }
 */
@JsonDeserialize(builder = Hangup.Builder.class)
public class Hangup extends TwiML {
    /**
     * For XML Serialization/Deserialization
     */
    private Hangup() {
        this(new Builder());
    }

    /**
     * Create a new {@code } element
     */
    private Hangup(Builder b) {
        super("Hangup", b);
    }

    /**
     * Create a new {@code } element
     */
    @JsonPOJOBuilder(withPrefix = "")
    public static class Builder extends TwiML.Builder {
        /**
         * Create and return a {@code } from an XML string
         */
        public static Builder fromXml(final String xml) throws TwiMLException {
            try {
                return OBJECT_MAPPER.readValue(xml, Builder.class);
            } catch (final JsonProcessingException jpe) {
                throw new TwiMLException(
                    "Failed to deserialize a Hangup.Builder from the provided XML string: " + jpe.getMessage());
            } catch (final Exception e) {
                throw new TwiMLException("Unhandled exception: " + e.getMessage());
            }
        }

        /**
         * Add a child {@code } element
         */
        @JacksonXmlProperty(isAttribute = false, localName = "Parameter")
        public Builder parameter(Parameter parameter) {
            this.children.add(parameter);
            return this;
        }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy