package org.nutz.castor.castor;

import org.nutz.castor.Castor;
import org.nutz.castor.FailToCastObjectException;

@SuppressWarnings({"rawtypes"})
public class String2Enum extends Castor<String, Enum> {

    @SuppressWarnings("unchecked")
    @Override
    public Enum cast(String src, Class<?> toType, String... args) throws FailToCastObjectException {
        try {
            return Enum.valueOf((Class<Enum>) toType, src);
        }
        catch (IllegalArgumentException e) {
            for (Object c : toType.getEnumConstants()) {
                if (c.toString().equals(src)) return (Enum) c;
            }

            throw e;
        }
    }

}

@@ -110,16 +110,47 @@
 eption;%0D
+%0Aimport org.nutz.lang.Strings;%0D
 %0A%0D%0A@Supp
@@ -385,24 +385,85 @@
 xception %7B%0D%0A
+        if (Strings.isBlank(src))%0D%0A            return null;%0D%0A
         try 

fix https://gitee.com/nutz/nutz/issues/IFX0U