|
| 1 | +/** |
| 2 | + * The MIT License |
| 3 | + * |
| 4 | + * Copyright (c) 2013-2018 Jeevanandam M. (myjeeva.com) |
| 5 | + * |
| 6 | + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and |
| 7 | + * associated documentation files (the "Software"), to deal in the Software without restriction, |
| 8 | + * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
| 9 | + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
| 10 | + * furnished to do so, subject to the following conditions: |
| 11 | + * |
| 12 | + * The above copyright notice and this permission notice shall be included in all copies or |
| 13 | + * substantial portions of the Software. |
| 14 | + * |
| 15 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT |
| 16 | + * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 17 | + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
| 18 | + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 19 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 20 | + */ |
| 21 | + |
| 22 | +package com.myjeeva.digitalocean.common; |
| 23 | + |
| 24 | +import org.apache.commons.lang3.StringUtils; |
| 25 | + |
| 26 | +import com.google.gson.annotations.SerializedName; |
| 27 | + |
| 28 | +/** |
| 29 | + * <p> |
| 30 | + * Enumeration of DigitalOcean CAA Tag Types. Valid values are "issue", "issuewild", or "iodef". |
| 31 | + * </p> |
| 32 | + * |
| 33 | + * <p> |
| 34 | + * More info: https://developers.digitalocean.com/documentation/v2/#domain-records/ |
| 35 | + * </p> |
| 36 | + * |
| 37 | + * @author Jeevanandam M. (jeeva@myjeeva.com) |
| 38 | + * |
| 39 | + * @since v2.15 |
| 40 | + */ |
| 41 | +public enum CaaTagType { |
| 42 | + |
| 43 | + @SerializedName("issue") |
| 44 | + ISSUE("issue"), |
| 45 | + |
| 46 | + @SerializedName("issuewild") |
| 47 | + ISSUE_WILD("issuewild"), |
| 48 | + |
| 49 | + @SerializedName("iodef") |
| 50 | + IODEF("iodef"); |
| 51 | + |
| 52 | + private String value; |
| 53 | + |
| 54 | + private CaaTagType(String value) { |
| 55 | + this.value = value; |
| 56 | + } |
| 57 | + |
| 58 | + @Override |
| 59 | + public String toString() { |
| 60 | + return this.value; |
| 61 | + } |
| 62 | + |
| 63 | + public static CaaTagType fromValue(String value) { |
| 64 | + if (StringUtils.isBlank(value)) { |
| 65 | + throw new IllegalArgumentException("Value cannot be null or empty!"); |
| 66 | + } |
| 67 | + |
| 68 | + for (CaaTagType rt : CaaTagType.values()) { |
| 69 | + if (value.equalsIgnoreCase(rt.value)) { |
| 70 | + return rt; |
| 71 | + } |
| 72 | + } |
| 73 | + |
| 74 | + throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); |
| 75 | + } |
| 76 | +} |
0 commit comments