001
002/*
003 * Copyright (C) 2011 Archie L. Cobbs. All rights reserved.
004 *
005 * $Id$
006 */
007
008package org.dellroad.jibxbindings.twilio.restapi;
009
010import org.dellroad.jibxbindings.ParseUtil;
011import org.jibx.runtime.JiBXParseException;
012
013/**
014 * SMS directionality.
015 */
016public enum SMSDirection {
017
018    /**
019     * Inbound SMS.
020     */
021    INBOUND("inbound", false),
022
023    /**
024     * Outbound, initiated via the REST API.
025     */
026    OUTBOUND_API("outbound-api", true),
027
028    /**
029     * Outbound, initiated during a call.
030     */
031    OUTBOUND_CALL("outbound-call", true),
032
033    /**
034     * Outbound, initiated in response to an incoming SMS.
035     */
036    OUTBOUND_REPLY("outbound-reply", true);
037
038    private final String xmlName;
039    private final boolean outbound;
040
041    private SMSDirection(String xmlName, boolean outbound) {
042        this.xmlName = xmlName;
043        this.outbound = outbound;
044    }
045
046    /**
047     * Is the SMS inbound or outbound?
048     *
049     * @return false for {@link #INBOUND}, true for all other values
050     */
051    public boolean isOutbound() {
052        return this.outbound;
053    }
054
055    @Override
056    public String toString() {
057        return this.xmlName;
058    }
059
060    public static SMSDirection deserializeXML(String string) throws JiBXParseException {
061        return ParseUtil.deserializeEnumOrNull(string, SMSDirection.class);
062    }
063}
064