/*
 * Copyright 2012 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package bingo.lang.convert;

import bingo.lang.Enums;
import bingo.lang.Out;

public class EnumConverter extends AbstractConverter<Enum<?>> implements Converter<Enum<?>> {

	@SuppressWarnings("unchecked")
	public boolean convertFrom(Object value, Class<?> targetType, Class<?> genericType, Out<Object> out) throws Throwable {
		
		Enum<?> enumObject = Enums.valueOf((Class<Enum<?>>)targetType, value);
		
		if(null != enumObject){
			return out.returns(enumObject);
		}
		
	    return false;
    }

}
@@ -655,16 +655,79 @@
 ert;%0D%0A%0D%0A
+import java.lang.reflect.Type;%0D%0A%0D%0Aimport bingo.lang.Converts;%0D%0A
 import b
@@ -740,24 +740,24 @@
 ang.Enums;%0D%0A
-
 import bingo
@@ -1022,20 +1022,16 @@
 able %7B%0D%0A
-%09%09%0D%0A
 %09%09Enum%3C?
@@ -1199,11 +1199,459 @@
 %0A    %7D%0D%0A
+%09%0D%0A%09@Override%0D%0A    public boolean convertTo(Enum%3C?%3E value, Class%3C?%3E targetType, Type genericType, Out%3CObject%3E out) throws Throwable %7B%0D%0A%09%09Object realValue = Enums.getValue(value);%0D%0A%09%09%0D%0A%09    return out.returns(Converts.convert(realValue, targetType, genericType));%0D%0A    %7D%0D%0A%0D%0A%09@Override%0D%0A    public String convertToString(Enum%3C?%3E value) throws Throwable %7B%0D%0A%09%09Object realValue = Enums.getValue(value);%0D%0A%09%09%0D%0A%09%09return Converts.toString(realValue);%0D%0A    %7D
 %0D%0A%7D

fix enum convert bug