Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.skife.config;
 
 
 public class ExactMatchEnumCoercible implements Coercible<Object>
 {
     public Coercer<Objectaccept(Class<?> clazz)
     {
         if (!clazz.isEnum()) {
            return null;
        }
        try {
            final Method m = clazz.getMethod("valueOf"String.class);
            return new Coercer<Object>()
            {
                public Object coerce(String value)
                {
                    if (value == null) {
                        return null;
                    }
                    try {
                        return m.invoke(nullvalue);
                    }
                    catch (Exception e) {
                        throw DefaultCoercibles.convertException(e);
                    }
                }
            };
        }
        catch (NoSuchMethodException e) {
            throw new IllegalStateException("<EnumType>.valueOf(String) missing! World broken!"e);
        }
    }
New to GrepCode? Check out our FAQ X