1package eu.siacs.conversations.xmpp.jingle.stanzas;
2
3import android.support.annotation.NonNull;
4
5import com.google.common.base.CaseFormat;
6
7public enum Reason {
8 SUCCESS, DECLINE, BUSY, CANCEL, CONNECTIVITY_ERROR, FAILED_TRANSPORT, FAILED_APPLICATION, TIMEOUT, UNKNOWN;
9
10 public static Reason of(final String value) {
11 try {
12 return Reason.valueOf(CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_UNDERSCORE, value));
13 } catch (Exception e) {
14 return UNKNOWN;
15 }
16 }
17
18 @Override
19 @NonNull
20 public String toString() {
21 return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, super.toString());
22 }
23}