當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。