public void writeTo(Object obj, String mimeType, OutputStream os) throws IOException { // if the object is a DeliveryStatus, we know how to write that out if (obj instanceof DeliveryStatus) { DeliveryStatus ds = (DeliveryStatus) obj; ds.writeTo(os); } else { throw new IOException("unsupported object"); } }
/** * Use this in place of valueOf. * * @param value real value * @return DeliveryStatus corresponding to the value */ public static DeliveryStatus fromValue(String value) { if (value == null || "".equals(value)) { throw new IllegalArgumentException("Value cannot be null or empty!"); } for (DeliveryStatus enumEntry : DeliveryStatus.values()) { if (enumEntry.toString().equals(value)) { return enumEntry; } } throw new IllegalArgumentException("Cannot create enum from " + value + " value!"); }
static { for (DeliveryStatus s : EnumSet.allOf(DeliveryStatus.class)) { lookup.put(s.getValue(), s); } }