com.twilio.twiml.voice.Config Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of twilio Show documentation
Show all versions of twilio Show documentation
Twilio Java Helper Library
/**
* 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;
import java.util.HashMap;
import java.util.Map;
/**
* TwiML wrapper for {@code }
*/
@JsonDeserialize(builder = Config.Builder.class)
public class Config extends TwiML {
private final String name;
private final String value;
/**
* For XML Serialization/Deserialization
*/
private Config() {
this(new Builder());
}
/**
* Create a new {@code } element
*/
private Config(Builder b) {
super("Config", b);
this.name = b.name;
this.value = b.value;
}
/**
* 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.getName() != null) {
attrs.put("name", this.getName());
}
if (this.getValue() != null) {
attrs.put("value", this.getValue());
}
return attrs;
}
/**
* The name of the custom config
*
* @return The name of the custom config
*/
public String getName() {
return name;
}
/**
* The value of the custom config
*
* @return The value of the custom config
*/
public String getValue() {
return value;
}
/**
* 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 Config.Builder from the provided XML string: " + jpe.getMessage());
} catch (final Exception e) {
throw new TwiMLException("Unhandled exception: " + e.getMessage());
}
}
private String name;
private String value;
/**
* The name of the custom config
*/
@JacksonXmlProperty(isAttribute = true, localName = "name")
public Builder name(String name) {
this.name = name;
return this;
}
/**
* The value of the custom config
*/
@JacksonXmlProperty(isAttribute = true, localName = "value")
public Builder value(String value) {
this.value = value;
return this;
}
/**
* Create and return resulting {@code } element
*/
public Config build() {
return new Config(this);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy