本文整理汇总了Java中org.mongodb.morphia.utils.ReflectionUtils.convertToArray方法的典型用法代码示例。如果您正苦于以下问题:Java ReflectionUtils.convertToArray方法的具体用法?Java ReflectionUtils.convertToArray怎么用?Java ReflectionUtils.convertToArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mongodb.morphia.utils.ReflectionUtils
的用法示例。
在下文中一共展示了ReflectionUtils.convertToArray方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decode
import org.mongodb.morphia.utils.ReflectionUtils; //导入方法依赖的package包/类
@Override
public Object decode(final Class targetClass, final Object val, final MappedField optionalExtraInfo) {
if (val == null) {
return null;
}
if (val instanceof Integer) {
return val;
}
if (val instanceof Number) {
return ((Number) val).intValue();
}
if (val instanceof List) {
final Class<?> type = targetClass.isArray() ? targetClass.getComponentType() : targetClass;
return ReflectionUtils.convertToArray(type, (List<?>) val);
}
return Integer.parseInt(val.toString());
}
示例2: decode
import org.mongodb.morphia.utils.ReflectionUtils; //导入方法依赖的package包/类
@Override
public Object decode(final Class targetClass, final Object val, final MappedField optionalExtraInfo) {
if (val == null) {
return null;
}
if (val instanceof Double) {
return val;
}
if (val instanceof Number) {
return ((Number) val).doubleValue();
}
if (val instanceof List) {
final Class<?> type = targetClass.isArray() ? targetClass.getComponentType() : targetClass;
return ReflectionUtils.convertToArray(type, (List<?>) val);
}
return Double.parseDouble(val.toString());
}
示例3: decode
import org.mongodb.morphia.utils.ReflectionUtils; //导入方法依赖的package包/类
@Override
public Object decode(final Class targetClass, final Object fromDBObject, final MappedField optionalExtraInfo) {
if (fromDBObject == null) {
return null;
}
if (targetClass.equals(fromDBObject.getClass())) {
return fromDBObject;
}
if (fromDBObject instanceof List) {
final Class<?> type = targetClass.isArray() ? targetClass.getComponentType() : targetClass;
return ReflectionUtils.convertToArray(type, (List<?>) fromDBObject);
}
if (targetClass.equals(String[].class)) {
return new String[]{fromDBObject.toString()};
}
return fromDBObject.toString();
}
示例4: decode
import org.mongodb.morphia.utils.ReflectionUtils; //导入方法依赖的package包/类
@Override
public Object decode(final Class targetClass, final Object val, final MappedField optionalExtraInfo) {
if (val == null) {
return null;
}
if (val instanceof Boolean) {
return val;
}
//handle the case for things like the ok field
if (val instanceof Number) {
return ((Number) val).intValue() != 0;
}
if (val instanceof List) {
final Class<?> type = targetClass.isArray() ? targetClass.getComponentType() : targetClass;
return ReflectionUtils.convertToArray(type, (List<?>) val);
}
return Boolean.parseBoolean(val.toString());
}
示例5: decode
import org.mongodb.morphia.utils.ReflectionUtils; //导入方法依赖的package包/类
@Override
public Object decode(final Class targetClass, final Object val, final MappedField optionalExtraInfo) {
if (val == null) {
return null;
}
if (val instanceof Long) {
return val;
}
if (val instanceof Number) {
return ((Number) val).longValue();
}
if (val instanceof List) {
final Class<?> type = targetClass.isArray() ? targetClass.getComponentType() : targetClass;
return ReflectionUtils.convertToArray(type, (List<?>) val);
}
return Long.parseLong(val.toString());
}