List of usage examples for org.apache.commons.lang3 EnumUtils isValidEnum
public static <E extends Enum<E>> boolean isValidEnum(final Class<E> enumClass, final String enumName)
Checks if the specified name is a valid enum for the class.
This method differs from Enum#valueOf in that checks if the name is a valid enum without needing to catch the exception.
From source file:tasly.greathealth.oms.web.orderproducer.rest.resources.TaslyOrderProducerConfigResource.java
@GET @Path("orderconsumer/stop/{eventType}") public @ResponseBody String stopOrderConsumer(@PathParam("eventType") final String eventType) { LOG.info("Stop order consumer." + eventType); if ("all".equalsIgnoreCase(eventType)) { OrderCommandsStorage.getInstance().stopAllConsumer(); return new JSONSerializer().deepSerialize(OrderCommandsStorage.getInstance().getAllConsumerStatus()); } else if (EnumUtils.isValidEnum(EventType.class, eventType) == false) { return "Not support event type " + eventType; } else {// ww w . j a v a 2 s.co m OrderCommandsStorage.getInstance().stopSingleConsumer(eventType); return new JSONSerializer().deepSerialize(OrderCommandsStorage.getInstance().getAllConsumerStatus()); } }