当前位置: 首页>>代码示例>>Java>>正文


Java ClassUtils.isPrimitiveOrWrapper方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.ClassUtils.isPrimitiveOrWrapper方法的典型用法代码示例。如果您正苦于以下问题:Java ClassUtils.isPrimitiveOrWrapper方法的具体用法?Java ClassUtils.isPrimitiveOrWrapper怎么用?Java ClassUtils.isPrimitiveOrWrapper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.ClassUtils的用法示例。


在下文中一共展示了ClassUtils.isPrimitiveOrWrapper方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: objToString

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
public String objToString(Object value) {
    final StringBuilder buf = new StringBuilder();

    for (Field f : value.getClass().getDeclaredFields()) {
        f.setAccessible(true);

        try {
            buf.append("\"" + f.getName() + "\": ");
            if (ClassUtils.isPrimitiveOrWrapper(value.getClass()) || value instanceof String) {
                buf.append("\"" + value + "\"");
            } else {
                buf.append(valueToString(f.get(value)));
            }
            buf.append(", ");
        } catch (IllegalArgumentException | IllegalAccessException e) {
            // Silently ignore errors
            e.printStackTrace();
        }
    }
    buf.replace(buf.length() - 2, buf.length(), "");

    return buf.toString();
}
 
开发者ID:ilpianista,项目名称:ansible-inventory-java,代码行数:24,代码来源:AnsibleVariable.java

示例2: listToString

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
public String listToString(Collection<?> list) {
    final StringBuilder buf = new StringBuilder();
    buf.append("'[");

    if (!list.isEmpty()) {
        for (Object o : list) {
            if (ClassUtils.isPrimitiveOrWrapper(o.getClass()) || o instanceof String) {
                buf.append("\"" + o + "\"");
            } else {
                buf.append(valueToString(o));
            }
            buf.append(", ");
        }
        buf.replace(buf.length() - 2, buf.length(), "");
    }

    buf.append("]'");

    return buf.toString();
}
 
开发者ID:ilpianista,项目名称:ansible-inventory-java,代码行数:21,代码来源:AnsibleVariable.java

示例3: mapToString

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
public String mapToString(Map<?, ?> map) {
    final StringBuilder buf = new StringBuilder();
    buf.append("{");

    if (!map.isEmpty()) {
        for (Entry<?, ?> o : map.entrySet()) {
            final Object v = o.getValue();

            if (v != null) {
                buf.append("'" + o.getKey() + "': ");
                if (ClassUtils.isPrimitiveOrWrapper(v.getClass()) || v instanceof String) {
                    buf.append("'" + v + "'");
                } else {
                    buf.append(valueToString(v));
                }
                buf.append(", ");
            }
        }
        buf.replace(buf.length() - 2, buf.length(), "");
    }

    buf.append("}");

    return buf.toString();
}
 
开发者ID:ilpianista,项目名称:ansible-inventory-java,代码行数:26,代码来源:AnsibleVariable.java

示例4: toString

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
@Override
public String toString() {
       class BusinessObjectToStringBuilder extends ReflectionToStringBuilder {

           private BusinessObjectToStringBuilder(Object object) {
               super(object);
           }

           @Override
           public boolean accept(Field field) {
               // ignore printing out byte arrays in toString methods
               if (byte[].class.isAssignableFrom(field.getType())) {
                 return false;
               }
               return String.class.isAssignableFrom(field.getType())
                       || ClassUtils.isPrimitiveOrWrapper(field.getType());
           }

       }

       return new BusinessObjectToStringBuilder(this).toString();
   }
 
开发者ID:kuali,项目名称:kc-rice,代码行数:23,代码来源:BusinessObjectBase.java

示例5: getBeanFieldsRecursively

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
public static Set<String> getBeanFieldsRecursively(Class<?> clazz, String prefix) {
    Set<String> result = new TreeSet<>();
    prefix = prefix.length() == 0 ? prefix : prefix + ".";

    while (clazz != null) {
        Field[] fields = clazz.getDeclaredFields();
        for (Field field : fields) {
            String fieldName = prefix + field.getName();
            Class<?> fieldType = field.getType();

            result.add(fieldName);
            if (!ClassUtils.isPrimitiveOrWrapper(fieldType))
                result.addAll(getBeanFieldsRecursively(fieldType, fieldName));
        }

        clazz = clazz.getSuperclass();
    }

    return result;
}
 
开发者ID:imCodePartnerAB,项目名称:iVIS,代码行数:21,代码来源:CsvLoaderController.java

示例6: isJavaType

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
 * Check if the given class is a Java type
 *
 * @param type A class
 * @return True when the property type is a Java type, else False
 */
public static boolean isJavaType(Class<?> type) {
  return (ClassUtils.isPrimitiveOrWrapper(type)
      || Class.class.equals(type)
      || String.class.equals(type)
      || Collection.class.isAssignableFrom(type)
      || Void.class.isAssignableFrom(type));
}
 
开发者ID:Juraji,项目名称:Biliomi,代码行数:14,代码来源:ObjectGraphs.java

示例7: isTerminalType

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
private static boolean isTerminalType(Class type) {
	return ClassUtils.isPrimitiveOrWrapper(type)
			|| type.isEnum()
			|| Date.class.isAssignableFrom(type)
			|| String.class.equals(type)
			|| Object.class.equals(type);
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:8,代码来源:IndexResource.java

示例8: valueToString

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
public String valueToString(Object value) {
    if (value == null) {
        return "";
    }

    final Class<?> vClass = value.getClass();

    String str;
    if (Collection.class.isAssignableFrom(vClass)) {
        str = listToString((Collection<?>) value);
    } else if (Map.class.isAssignableFrom(vClass)) {
        str = mapToString((Map<?, ?>) value);
    } else if (ClassUtils.isPrimitiveOrWrapper(vClass) || value instanceof String || vClass.isEnum()) {
        str = value.toString();

        // Use double backslash because of YAML syntax
        str = str.replace("\\", "\\\\");

        // Escape quotes
        str = str.replace("\"", "\\\"");

        // Quote variables with spaces
        if (str.contains(" ")) {
          str = "\"" + str + "\"";
        }
    } else {
        str = objToString(value);
    }

    return str;
}
 
开发者ID:ilpianista,项目名称:ansible-inventory-java,代码行数:32,代码来源:AnsibleVariable.java

示例9: readFieldsAsMap

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
 * Read fields value as {@link Map}
 *
 * @param object
 *         object to be read
 * @return fields value as {@link Map}
 */
@Nonnull
public static Map<String, Object> readFieldsAsMap(Object object) {
    Map<String, Object> fieldsAsMap = Maps.newLinkedHashMap();
    Class<?> type = object.getClass();
    Field[] fields = type.getDeclaredFields();
    for (Field field : fields) {

        if (Modifier.isStatic(field.getModifiers())) { // To filter static fields
            continue;
        }

        field.setAccessible(true);

        try {
            String fieldName = field.getName();
            Object fieldValue = field.get(object);
            if (fieldValue != null) {
                Class<?> fieldValueType = fieldValue.getClass();
                if (ClassUtils.isPrimitiveOrWrapper(fieldValueType)) {
                } else if (fieldValueType.isArray()) {
                    fieldValue = toList(fieldValue);
                } else if ("java.lang".equals(fieldValueType.getPackage().getName())) {

                } else {
                    fieldValue = readFieldsAsMap(fieldValue);
                }
            }
            fieldsAsMap.put(fieldName, fieldValue);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
    return fieldsAsMap;
}
 
开发者ID:mercyblitz,项目名称:confucius-commons,代码行数:42,代码来源:ReflectionUtils.java

示例10: getObjectMap

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
public static Map<String, Object> getObjectMap(Object o) {

        if (ClassUtils.isPrimitiveOrWrapper(o.getClass()) || (o instanceof String)) {
            Map<String, Object> objectMap = new HashMap<String, Object>();
            objectMap.put("fake_var_" + o.getClass().getName().replace('.', '_'), o);
            return objectMap;
        } else {
            return getAllVars(o, 0, "");

        }

    }
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:13,代码来源:ObjectFields.java

示例11: printDefaultValue

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
private void printDefaultValue( StringBuilder c, Object pfield, TLine line ) {
    if( !map.ignoreDefaultValue() ) {
        c.append( "acc.accept( " );
        if( ClassUtils.isPrimitiveOrWrapper( pfield.getClass() ) ) c.append( pfield );
        else map.function( c, line.function, () -> c.append( "\"" ).append( pfield ).append( "\"" ) );
        c.append( " );\n" );
    } else c.append( "{}\n" );
}
 
开发者ID:oaplatform,项目名称:oap,代码行数:9,代码来源:JavaCTemplate.java

示例12: isPrimitive

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
private boolean isPrimitive(Class clazz) {
	return clazz == String.class || ClassUtils.isPrimitiveOrWrapper(clazz) || LocalDate.class.getPackage().equals(clazz
			.getPackage()) || clazz.isEnum();
}
 
开发者ID:crnk-project,项目名称:crnk-framework,代码行数:5,代码来源:ActivitiResourceMapper.java

示例13: isPrimitive

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
@Override
   public boolean isPrimitive() {
return ClassUtils.isPrimitiveOrWrapper(clazz) || clazz.isAssignableFrom(String.class);
   }
 
开发者ID:iaunzu,项目名称:strqlbuilder,代码行数:5,代码来源:DefaultPojoFactory.java

示例14: isSupportedType

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
private static boolean isSupportedType(Class<?> clazz) {
    return !(ClassUtils.isPrimitiveOrWrapper(clazz) || clazz == Object.class || Map.class.isAssignableFrom(clazz));
}
 
开发者ID:nfl,项目名称:glitr,代码行数:4,代码来源:ReflectionUtil.java

示例15: isSimple

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
private boolean isSimple(Class<?> type) {
  return type == String.class || type == Date.class || Enum.class.isAssignableFrom(type) || ClassUtils.isPrimitiveOrWrapper(type);
}
 
开发者ID:openknowledge,项目名称:jaxrs-versioning,代码行数:4,代码来源:FieldVersionProperty.java


注:本文中的org.apache.commons.lang3.ClassUtils.isPrimitiveOrWrapper方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。