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 * Call directionality. 015 */ 016public enum CallDirection { 017 018 /** 019 * Inbound call. 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 by a TwiML <code><Dial></code> verb. 030 */ 031 OUTBOUND_DIAL("outbound-dial", true); 032 033 private final String xmlName; 034 private final boolean outbound; 035 036 private CallDirection(String xmlName, boolean outbound) { 037 this.xmlName = xmlName; 038 this.outbound = outbound; 039 } 040 041 /** 042 * Is the call inbound or outbound? 043 * 044 * @return false for {@link #INBOUND}, true for all other values 045 */ 046 public boolean isOutbound() { 047 return this.outbound; 048 } 049 050 @Override 051 public String toString() { 052 return this.xmlName; 053 } 054 055 public static CallDirection deserializeXML(String string) throws JiBXParseException { 056 return ParseUtil.deserializeEnumOrNull(string, CallDirection.class); 057 } 058} 059