Typecasts the given enumerator to its actual value stored in the
 database.  This will only convert symbols to strings.  All other values
 will remain in the same type.
559077
def typecast_enumerator(enumerator)
        if enumerator.is_a?(Array)
          enumerator.flatten!
          enumerator.map! {|value| typecast_enumerator(value)}
          enumerator
        else
          enumerator.is_a?(Symbol) ? enumerator.to_s : enumerator
        end
      end
294479
def _value_encode(cls, member, value):
        
        try:
            field_validator = cls.fields[member]
        except KeyError:
            return cls.valueparse.encode(value)

        return field_validator.encode(value)
579845
def enum(self):
        
        value = self._schema.get("enum", None)
        if value is None:
            return
        if not isinstance(value, list):
            raise SchemaError(
                "enum value {0!r} is not a list".format(value))
        if len(value) == 0:
            raise SchemaError(
                "enum value {0!r} does not contain any"
                " elements".format(value))
        seen = set()
        for item in value:
            if item in seen:
                raise SchemaError(
                    "enum value {0!r} contains duplicate element"
                    " {1!r}".format(value, item))
            else:
                seen.add(item)
        return value
371367
public static TypeCode toTypeCode(Class<?> type) {
		if (type == null)
			return TypeCode.Unknown;
		else if (type.isArray())
			return TypeCode.Array;
		else if (type.isEnum())
			return TypeCode.Enum;
		else if (type.isPrimitive()) {
			if (_booleanType.isAssignableFrom(type))
				return TypeCode.Boolean;
			if (_doubleType.isAssignableFrom(type))
				return TypeCode.Double;
			if (_floatType.isAssignableFrom(type))
				return TypeCode.Float;
			if (_longType.isAssignableFrom(type))
				return TypeCode.Long;
			if (_integerType.isAssignableFrom(type))
				return TypeCode.Integer;
		} else {
			if (_booleanType.isAssignableFrom(type))
				return TypeCode.Boolean;
			if (_doubleType.isAssignableFrom(type))
				return TypeCode.Double;
			if (_floatType.isAssignableFrom(type))
				return TypeCode.Float;
			if (_longType.isAssignableFrom(type))
				return TypeCode.Long;
			if (_integerType.isAssignableFrom(type))
				return TypeCode.Integer;
			if (_stringType.isAssignableFrom(type))
				return TypeCode.String;
			if (_dateTimeType.isAssignableFrom(type))
				return TypeCode.DateTime;
			if (_durationType.isAssignableFrom(type))
				return TypeCode.Duration;
			if (_mapType.isAssignableFrom(type))
				return TypeCode.Map;
			if (_listType.isAssignableFrom(type))
				return TypeCode.Array;
			if (_enumType.isAssignableFrom(type))
				return TypeCode.Enum;
		}

		return TypeCode.Object;
	}
1318731
def _cast_to_type(self, value):
        
        if not isinstance(value, dict):
            self.fail('invalid', value=value)
        return value
1002911
private static Object typeCast(String str) {
        if (str == null || str.equals("")) {
            return null;
        }
        // Try to cast to boolean true
        for (String trueString : trueArray) {
            if (trueString.equals(str)) {
                return true;
            }
        }
        // Try to cast to boolean false
        for (String falseString : falseArray) {
            if (falseString.equals(str)) {
                return false;
            }
        }
        // Strings that cannot cast to int or double are treated as string
        try {
            return Integer.parseInt(str);
        } catch (Exception e1) {
            try {
                return Double.parseDouble(str);
            } catch (Exception e2) {
                return str;
            }
        }
    }
637965
def renum(type_name, values = :defined_in_block, &block)
      nest = self.is_a?(Module) ? self : Object
      EnumeratedValueTypeFactory.create(nest, type_name, values, &block)
    end
1252217
@SuppressWarnings("unchecked")
    public static final Enum<?> coerceToEnum(final ELContext ctx, final Object obj,
            @SuppressWarnings("rawtypes") Class type) {

        if (ctx != null) {
        	boolean originalIsPropertyResolved = ctx.isPropertyResolved();
        	try {
        		Object result = ctx.getELResolver().convertToType(ctx, obj, type);
        		if (ctx.isPropertyResolved()) {
        			return (Enum<?>) result;
        		}
        	} finally {
        		ctx.setPropertyResolved(originalIsPropertyResolved);
        	}
        }

        if (obj == null || "".equals(obj)) {
            return null;
        }
        if (type.isAssignableFrom(obj.getClass())) {
            return (Enum<?>) obj;
        }

        if (!(obj instanceof String)) {
            throw new ELException(MessageFactory.get("error.convert",
                    obj, obj.getClass(), type));
        }

        Enum<?> result;
        try {
             result = Enum.valueOf(type, (String) obj);
        } catch (IllegalArgumentException iae) {
            throw new ELException(MessageFactory.get("error.convert",
                    obj, obj.getClass(), type));
        }
        return result;
    }
209445
public static void convertValue(CodeBuilder b, Class from, Class to) {
        if (from == to) {
            return;
        }

        TypeDesc fromType = TypeDesc.forClass(from);
        TypeDesc toType = TypeDesc.forClass(to);

        // Let CodeBuilder have a crack at the conversion first.
        try {
            b.convert(fromType, toType);
            return;
        } catch (IllegalArgumentException e) {
            if (to != String.class && to != Object.class && to != CharSequence.class) {
                throw e;
            }
        }

        // Fallback case is to convert to a String.

        if (fromType.isPrimitive()) {
            b.invokeStatic(TypeDesc.STRING, "valueOf", TypeDesc.STRING, new TypeDesc[]{fromType});
        } else {
            // If object on stack is null, then just leave it alone.
            b.dup();
            Label isNull = b.createLabel();
            b.ifNullBranch(isNull, true);
            b.invokeStatic(TypeDesc.STRING, "valueOf", TypeDesc.STRING,
                           new TypeDesc[]{TypeDesc.OBJECT});
            isNull.setLocation();
        }
    }
170627
def _getEnumValues(self, data):
        
        enumstr = data.attrib.get('enumValues')
        if not enumstr:
            return None
        if ':' in enumstr:
            return {self._cast(k): v for k, v in [kv.split(':') for kv in enumstr.split('|')]}
        return enumstr.split('|')
596224
public static final<E extends Enum> E getEnumValue(String str, Class<E> enumClass) {
        str = str.trim();
        if (StringUtils.isBlank(str)) return null;
        for (E e : enumClass.getEnumConstants()) {
            if (e.toString().equalsIgnoreCase(str)) return e;
        }
        throw new IllegalArgumentException("Invalid enum string provided for ["+enumClass+"]: " + str);
    }
831914
private static Converter<List<String>, Object> createStringConstructorConverter(Class<?> resultClass) {
    try {
      final Constructor<?> constructor = resultClass.getConstructor(String.class);
      return new BasicConverter(defaultValue(resultClass)) {
        @Override
        protected Object convert(String value) throws Exception {
          return constructor.newInstance(value);
        }
      };
    } catch (Exception e) {
      return null;
    }
  }
204356
def _cast_to_type(self, value):
        
        if isinstance(value, datetime.datetime):
            return value
        if isinstance(value, datetime.date):
            value = datetime.datetime(value.year, value.month, value.day)
            return value
        try:
            value = date_parser(value)
            return value
        except ValueError:
            self.fail('invalid', value=value)
1230199
def _type_to_str(self, type):
        
        for key, val in self.TYPE_NAMES.items():
            if key == type:
                return val
778529
@SuppressWarnings("PMD.LooseCoupling")
    public static Object castValue(Method m, Class<?> castType, String value) {

        try {
            if (castType.isEnum()) {
                Method valueOf;
                try {
                    valueOf = castType.getMethod("valueOf", String.class);
                    return valueOf.invoke(null, value);
                } catch (Exception e) {
                    log.info("enum value of excute error : (" + castType.getName() + ") | " + value);
                    return null;
                }
            } else if (castType == Integer.class || castType == int.class) {
                return Integer.parseInt(value);
            } else if (castType == Long.class || castType == long.class) {
                return Long.parseLong(value);
            } else if (castType == Double.class || castType == double.class) {
                return Double.parseDouble(value);
            } else if (castType == Boolean.class || castType == boolean.class) {
                return Boolean.parseBoolean(value);
            } else if (castType == Float.class || castType == float.class) {
                return Float.parseFloat(value);
            } else if (castType == String.class) {
                return value;
            } else if (castType == ArrayList.class || castType == List.class) {
                ParameterizedType paramType = (ParameterizedType) m.getGenericParameterTypes()[0];
                Class<?> paramClass = (Class<?>) paramType.getActualTypeArguments()[0];
                List<Object> castList = new ArrayList<>();
                String[] values = value.split(",");
                for (String v : values) {
                    castList.add(castValue(m, paramClass, v));
                }

                return castList;
            } else {
                log.info("invalid castType : " + castType);
                return null;
            }
        } catch (NumberFormatException e) {
            log.info("value : " + value + " is invalid value, setter parameter type is  : " + castType);
            return null;
        }
    }
1303678
@SuppressWarnings("unchecked")
    public static <T> T convert(Object fromValue, Class<T> toType) throws TypeCastException {
        return convert(fromValue, toType, (String) null);
    }
1081514
def values(self):
        
        enm = javabridge.call(self.jobject, "enumerateValues", "()Ljava/util/Enumeration;")
        if enm is None:
            return None
        else:
            return types.enumeration_to_list(enm)