Converts a value to the type of the given field.
@param value
@param field
@return
550577
public static Object convertToClass(String value, Class<?> clazz) {
    Object propertyValue;
    if (clazz.isAssignableFrom(int.class)) {
      propertyValue = Integer.parseInt(value);
    }
    else if (clazz.isAssignableFrom(long.class)) {
      propertyValue = Long.parseLong(value);
    }
    else if (clazz.isAssignableFrom(float.class)) {
      propertyValue = Float.parseFloat(value);
    }
    else if (clazz.isAssignableFrom(boolean.class)) {
      propertyValue = Boolean.parseBoolean(value);
    } else {
      propertyValue = value;
    }
    return propertyValue;
  }
994316
public String getValue(final String field)
    {
        FieldValue fieldValue = Iterables.find
        (
            fieldValues,
            new Predicate<FieldValue>()
            {
                @Override
                public boolean apply(FieldValue fv)
                {
                    return fv.getField().equals(field);
                }
            },
            null
        );
        return (fieldValue != null) ? fieldValue.getValue() : null;
    }
956334
@SuppressWarnings({ "unchecked", "rawtypes" })
    public static Object convert(Object value, Class<?> type) {
        if (value == null || type == null || type.isAssignableFrom(value.getClass())) {
            return value;
        }
        if (value instanceof String) {
            String string = (String) value;
            if (char.class.equals(type) || Character.class.equals(type)) {
                if (string.length() != 1) {
                    throw new IllegalArgumentException(String.format("can not convert String(%s) to char!" +
                        " when convert String to char, the String must only 1 char.", string));
                }
                return string.charAt(0);
            } else if (type.isEnum()) {
                return Enum.valueOf((Class<Enum>) type, string);
            } else if (type == BigInteger.class) {
                return new BigInteger(string);
            } else if (type == BigDecimal.class) {
                return new BigDecimal(string);
            } else if (type == Short.class || type == short.class) {
                return Short.valueOf(string);
            } else if (type == Integer.class || type == int.class) {
                return Integer.valueOf(string);
            } else if (type == Long.class || type == long.class) {
                return Long.valueOf(string);
            } else if (type == Double.class || type == double.class) {
                return new Double(string);
            } else if (type == Float.class || type == float.class) {
                return new Float(string);
            } else if (type == Byte.class || type == byte.class) {
                return Byte.valueOf(string);
            } else if (type == Boolean.class || type == boolean.class) {
                return Boolean.valueOf(string);
            } else if (type == Date.class || type == java.sql.Date.class || type == java.sql.Time.class ||
                type == java.sql.Timestamp.class) {
                try {
                    if (type == Date.class) {
                        return DateUtils.strToDate(string, DateUtils.DATE_FORMAT_TIME);
                    } else if (type == java.sql.Date.class) {
                        return new java.sql.Date(DateUtils.strToLong(string));
                    } else if (type == java.sql.Timestamp.class) {
                        return new java.sql.Timestamp(DateUtils.strToLong(string));
                    } else {
                        return new java.sql.Time(DateUtils.strToLong(string));
                    }
                } catch (ParseException e) {
                    throw new IllegalStateException("Failed to parse date " + value + " by format " +
                        DateUtils.DATE_FORMAT_TIME + ", cause: " + e.getMessage(), e);
                }
            } else if (type == Class.class) {
                return ClassTypeUtils.getClass((String) value);
            }
        } else if (value instanceof Number) {
            Number number = (Number) value;
            if (type == byte.class || type == Byte.class) {
                return number.byteValue();
            } else if (type == short.class || type == Short.class) {
                return number.shortValue();
            } else if (type == int.class || type == Integer.class) {
                return number.intValue();
            } else if (type == long.class || type == Long.class) {
                return number.longValue();
            } else if (type == float.class || type == Float.class) {
                return number.floatValue();
            } else if (type == double.class || type == Double.class) {
                return number.doubleValue();
            } else if (type == BigInteger.class) {
                return BigInteger.valueOf(number.longValue());
            } else if (type == BigDecimal.class) {
                return BigDecimal.valueOf(number.doubleValue());
            } else if (type == Date.class) {
                return new Date(number.longValue());
            } else if (type == java.sql.Date.class) {
                return new java.sql.Date(number.longValue());
            } else if (type == java.sql.Time.class) {
                return new java.sql.Time(number.longValue());
            } else if (type == java.sql.Timestamp.class) {
                return new java.sql.Timestamp(number.longValue());
            }
        } else if (value instanceof Collection) {
            Collection collection = (Collection) value;
            if (type.isArray()) {
                int length = collection.size();
                Object array = Array.newInstance(type.getComponentType(), length);
                int i = 0;
                for (Object item : collection) {
                    Array.set(array, i++, item);
                }
                return array;
            } else if (!type.isInterface()) {
                try {
                    Collection result = (Collection) type.newInstance();
                    result.addAll(collection);
                    return result;
                } catch (Throwable ignore) { // NOPMD
                }
            } else if (type == List.class) {
                return new ArrayList<Object>(collection);
            } else if (type == Set.class) {
                return new HashSet<Object>(collection);
            }
        } else if (value.getClass().isArray() && Collection.class.isAssignableFrom(type)) {
            Collection collection;
            if (!type.isInterface()) {
                try {
                    collection = (Collection) type.newInstance();
                } catch (Throwable e) {
                    collection = new ArrayList<Object>();
                }
            } else if (type == Set.class) {
                collection = new HashSet<Object>();
            } else {
                collection = new ArrayList<Object>();
            }
            int length = Array.getLength(value);
            for (int i = 0; i < length; i++) {
                collection.add(Array.get(value, i));
            }
            return collection;
        }
        return value;
    }
307331
public ZealotKhala notLike(String field, Object value) {
        return this.doLike(ZealotConst.ONE_SPACE, field, value, true, false);
    }
357774
def convert_value(value, field):
        
        clz = field.field_type

        if clz is Boolean:
            if not isinstance(value, bool):
                return bool(value)

        elif clz is Date:
            if not isinstance(value, str):
                value = str(value)
            return parser.parse(value)

        elif clz is Number:
            if not isinstance(value, int):
                return int(value)

        elif clz is Object:
            if not isinstance(value, dict):
                return ast.literal_eval(value)

        elif clz is Text or clz is Symbol:
            if not isinstance(value, str):
                return str(value)

        elif clz is List or clz is MultipleAssets or clz is MultipleEntries:
            if not isinstance(value, list):
                return [value]

        # No need to convert :class:`.fields.Link` types as the expected value
        # should be of type :class:`.resources.ResourceLink` for links.

        return value
432887
public ZealotKhala andNotLike(String field, Object value) {
        return this.doLike(ZealotConst.AND_PREFIX, field, value, true, false);
    }
1097029
public ByteBuffer getValue(String field) throws IOException {
        int hash = Arrays.hashCode(field.getBytes());
        return getValue(structure.valueHash2Index.get(hash));
    }
1162715
private void writeField(FieldType field, Object value) throws IOException
   {
      String fieldName = field.name().toLowerCase();
      writeField(fieldName, field.getDataType(), value);
   }
712747
function(field) {
  var converted = field.fieldId;
  converted.values = field.fieldValues;
  converted.sectionIndex = field.sectionIndex;
  return converted;
}
292351
public boolean set(String field, String value) {
		boolean result = false;
		if(value == null)return false;
		//返回值（1:新字段被设置,0:已经存在值被更新）
		try {
			result = getJedisCommands(groupName).hset(key, field, value) >= 0;
			//设置超时时间
			if(result)setExpireIfNot(expireTime);
			return result;
		} finally {
			getJedisProvider(groupName).release();
		}
	}
538831
private static void typeCheckFieldSet(Field field, Class<?> valueType, Object value) throws IllegalAccessException {
		if (!isPrimitive(valueType)) {
			//Call the version of this method that considers autoboxing
			typeCheckFieldSet(field, value);
		}
		else {
			//Value type is primitive.
			//  Note: In this case value was a primitive value that became boxed, so it can't be null.
			Class<?> fieldType = field.getType();
			if (!Utils.isConvertableFrom(fieldType, valueType)) {
				throw Exceptions.illegalSetFieldTypeException(field, valueType, value);
			}
		}
	}
4478
@Override
    public void set(Object value)
    {
        try
        {
            Object v = ConvertUtility.convert(type, value);
            if (field != null)
            {
                field.set(getBase(), v);
            }
            else
            {
                setter.invoke(getBase(), v);
            }
        }
        catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex)
        {
            throw new IllegalArgumentException(ex);
        }
    }
858835
function parse(value, field, options) {
  options = options || {};
  var parsed = utils.standardizeInput(value);

  // Integer
  if (field.type.key === "BOOLEAN") {
    parsed = utils.toBoolean(parsed);
  }
  else if (field.type.key === "INTEGER") {
    parsed = utils.toInteger(parsed);
  }
  else if (field.type.key === "FLOAT") {
    parsed = utils.toFloat(parsed);
  }
  else if (field.type.key === "DATEONLY") {
    parsed = utils.toDate(parsed, options.dateFormat);
  }
  else if (field.type.key === "DATE") {
    parsed = utils.toDateTime(parsed, options.datetimeFormat);
  }
  else if (field.type.key === "STRING") {
    parsed = utils.toString(parsed);
  }

  return parsed;
}
1222664
public static Object convert(Type type, String value) {
        if (null == value) {
            return value;
        }

        if ("".equals(value)) {

            if (type.equals(String.class)) {
                return value;
            }
            if (type.equals(int.class) || type.equals(double.class) ||
                    type.equals(short.class) || type.equals(long.class) ||
                    type.equals(byte.class) || type.equals(float.class)) {
                return 0;
            }
            if (type.equals(boolean.class)) {
                return false;
            }
            return null;
        }

        if (type.equals(int.class) || type.equals(Integer.class)) {
            return Integer.parseInt(value);
        } else if (type.equals(String.class)) {
            return value;
        } else if (type.equals(Double.class) || type.equals(double.class)) {
            return Double.parseDouble(value);
        } else if (type.equals(Float.class) || type.equals(float.class)) {
            return Float.parseFloat(value);
        } else if (type.equals(Long.class) || type.equals(long.class)) {
            return Long.parseLong(value);
        } else if (type.equals(Boolean.class) || type.equals(boolean.class)) {
            return Boolean.parseBoolean(value);
        } else if (type.equals(Short.class) || type.equals(short.class)) {
            return Short.parseShort(value);
        } else if (type.equals(Byte.class) || type.equals(byte.class)) {
            return Byte.parseByte(value);
        } else if (type.equals(BigDecimal.class)) {
            return new BigDecimal(value);
        } else if (type.equals(Date.class)) {
            if (value.length() == 10) return DateKit.toDate(value, "yyyy-MM-dd");
            return DateKit.toDateTime(value, "yyyy-MM-dd HH:mm:ss");
        } else if (type.equals(LocalDate.class)) {
            return DateKit.toLocalDate(value, "yyyy-MM-dd");
        } else if (type.equals(LocalDateTime.class)) {
            return DateKit.toLocalDateTime(value, "yyyy-MM-dd HH:mm:ss");
        }
        return value;
    }
981799
public Object getFieldValueByType(Object fieldValue) throws Exception {
        return ClassUtils.getValeByType(field.getType(), fieldValue);
    }
1002930
public ZealotKhala orLike(String field, Object value) {
        return this.doLike(ZealotConst.OR_PREFIX, field, value, true, true);
    }
563477
private void checkType(FieldType type, Field field) {
        Class<?> cls = field.getType();

        if (type == FieldType.OBJECT || type == FieldType.ENUM) {
            return;
        }

        String javaType = type.getJavaType();
        if (Integer.class.getSimpleName().equals(javaType)) {
            if (cls.getSimpleName().equals("int") || Integer.class.getSimpleName().equals(cls.getSimpleName())) {
                return;
            }
            throw new IllegalArgumentException(getMismatchTypeErroMessage(type, field));
        }
        if (!javaType.equalsIgnoreCase(cls.getSimpleName())) {
            throw new IllegalArgumentException(getMismatchTypeErroMessage(type, field));
        }
    }