Java tutorial
/* * Project: admin-parent * * File Created at 2014-04-15 * * Copyright 2012 Greenline.com Corporation Limited. * All rights reserved. * * This software is the confidential and proprietary information of * Greenline Company. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Greenline.com. */ package com.greenline.hrs.admin.test.normal; import com.greenline.hrs.admin.user.bo.UserStatus; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.testng.annotations.Test; /** * @author July * @version V1.0 * @type EnumTest * @desc * @date 2014-04-15 */ public class EnumTest { private static final Log LOG = LogFactory.getLog(EnumTest.class); @Test public void testType() { Object obj = UserStatus.ACTIVATING; if (obj.getClass().isEnum()) { Enum test = (Enum) obj; LOG.info(test.name()); } else { LOG.info("hello"); } } @Test public void testConversion() { try { LOG.info(UserStatus.valueOf("wsy")); } catch (IllegalArgumentException e) { LOG.error("test:", e); } try { LOG.info(UserStatus.valueOf(null)); } catch (NullPointerException e) { LOG.error("test:", e); } } }