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


Java ClassUtils.primitiveToWrapper方法代码示例

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


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

示例1: chooseStrategy

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
private JdbcAnnotatedRepositoryQuery.Strategy chooseStrategy(JdbcQueryMethod method) {
    Class<?> returnType = method.getReturnedObjectType();
    if (returnType.isPrimitive()) {
        returnType = ClassUtils.primitiveToWrapper(returnType);
    }
    // TODO think a better way of handling this by the method name
    if (Number.class.isAssignableFrom(returnType)) {
        return JdbcAnnotatedRepositoryQuery.Strategy.COUNT;
    }
    if (Boolean.class.isAssignableFrom(returnType)) {
        return JdbcAnnotatedRepositoryQuery.Strategy.EXISTS_QUERY;
    }
    if (method.isCollectionQuery()) {
        return JdbcAnnotatedRepositoryQuery.Strategy.COLLECTION_QUERY;
    }
    if (method.isQueryForEntity()) {
        return JdbcAnnotatedRepositoryQuery.Strategy.SINGLE_QUERY;
    }
    if (method.isPageQuery()) {
        return JdbcAnnotatedRepositoryQuery.Strategy.PAGE_QUERY;
    }
    if (void.class.isAssignableFrom(returnType)) {
        return JdbcAnnotatedRepositoryQuery.Strategy.UPDATE_QUERY;
    }
    throw new IllegalArgumentException("Don't know what strategy to follow!!");
}
 
开发者ID:rubasace,项目名称:spring-data-jdbc,代码行数:27,代码来源:JdbcAnnotatedRepositoryQueryCreator.java

示例2: getMethod

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
private static MethodSpec getMethod(ClassName name, Key key) {
	Class<?> type = parseTypeFormat(key.getType(), key.getFormat());
	if(type.isPrimitive()) {
		type = ClassUtils.primitiveToWrapper(type);
	}
	
	ParameterSpec parameter = ParameterSpec.builder(type, key.getId()).build();
	
	return MethodSpec.methodBuilder(key.getId())
			.addModifiers(Modifier.PUBLIC, Modifier.FINAL)
			.addParameter(parameter)
			.addStatement("this.$N = $N", key.getId(), parameter)
			.addJavadoc(key.getDescription())
			.returns(name)
			.addStatement("return this")
			.build();
}
 
开发者ID:skjolber,项目名称:json-log-domain,代码行数:18,代码来源:MarkerGenerator.java

示例3: checkCast

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
private void checkCast(Castable castable) {
	String internalNameOfCast = castable.getInternalName();
	if (castable.getType().isPrimitive()) {
		Class<?> wrapperType = ClassUtils.primitiveToWrapper(castable.getType());
		internalNameOfCast = Type.getInternalName(wrapperType);
	}
	mv.visitTypeInsn(CHECKCAST, internalNameOfCast);
	
	if (castable.getType().isPrimitive()) {
		mv.visitMethodInsn(
				INVOKEVIRTUAL,
				internalNameOfCast,
				castable.getType().getName() + "Value",
				"()" + castable.getDescriptor(),
				false);
	}
}
 
开发者ID:Javalbert,项目名称:faster-than-reflection,代码行数:18,代码来源:ClassAccessFactory.java

示例4: symmetric

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
private Number symmetric(Number value) {
	final Class<?> wrapper = ClassUtils.primitiveToWrapper(value.getClass());
	if(Integer.class.equals(wrapper)) {
		return -value.intValue();
	}
	else if(Short.class.equals(wrapper)) {
		return -value.shortValue();
	}
	else if(Float.class.equals(wrapper)) {
		return -value.floatValue();
	}
	else if(Double.class.equals(wrapper)) {
		return -value.doubleValue();
	}
	else if(Long.class.equals(wrapper)) {
		return -value.longValue();
	}
	else {
		throw new NumberFormatException(value + "is not in a valid format");
	}
}
 
开发者ID:JPDSousa,项目名称:mongo-obj-framework,代码行数:22,代码来源:SmofUpdateImpl.java

示例5: inverse

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
private Number inverse(Number value) {
	final Class<?> wrapper = ClassUtils.primitiveToWrapper(value.getClass());
	if(Integer.class.equals(wrapper)) {
		return 1.0/value.intValue();
	}
	else if(Short.class.equals(wrapper)) {
		return 1.0/value.shortValue();
	}
	else if(Float.class.equals(wrapper)) {
		return 1/value.floatValue();
	}
	else if(Double.class.equals(wrapper)) {
		return 1/value.doubleValue();
	}
	else if(Long.class.equals(wrapper)) {
		return 1.0/value.longValue();
	}
	else {
		throw new NumberFormatException(value + "is not in a valid format");
	}
}
 
开发者ID:JPDSousa,项目名称:mongo-obj-framework,代码行数:22,代码来源:SmofUpdateImpl.java

示例6: generateSettersAndGetters

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
 * Create getters for the key and time fields and setters for the include fields.
 */
private void generateSettersAndGetters()
{
  for (int i = 0; i < 2; i++) {
    Class inputClass = inputFieldObjects[i].inputClass;
    try {
      inputFieldObjects[i].keyGet = PojoUtils.createGetter(inputClass, keyFieldExpressions.get(i), Object.class);
      if (timeFields != null && timeFields.size() == 2) {
        Class timeField = ClassUtils.primitiveToWrapper(inputClass.getDeclaredField(timeFields.get(i)).getType());
        inputFieldObjects[i].timeFieldGet = PojoUtils.createGetter(inputClass, timeFields.get(i), timeField);
      }
      for (int j = 0; j < includeFields[i].length; j++) {
        Class inputField = ClassUtils.primitiveToWrapper(inputClass.getDeclaredField(includeFields[i][j]).getType());
        Class outputField = ClassUtils.primitiveToWrapper(outputClass.getDeclaredField(includeFields[i][j]).getType());
        if (inputField != outputField) {
          continue;
        }
        inputFieldObjects[i].fieldMap.put(PojoUtils.createGetter(inputClass, includeFields[i][j], inputField),
            PojoUtils.createSetter(outputClass, includeFields[i][j], outputField));
      }
    } catch (NoSuchFieldException e) {
      throw new RuntimeException(e);
    }
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:28,代码来源:POJOInnerJoinOperator.java

示例7: coerceParameter

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
Object coerceParameter(Type type, String stringToParse, List<Coercion> methodCoercions) {
	try {
		if (stringToParse == null) {
			return null;
		}
		if (type instanceof Class) {
			Class<?> targetType = ClassUtils.primitiveToWrapper((Class<?>) type);

			Result execution = tryToUseCoercions(targetType, stringToParse, methodCoercions);
			if (execution.succeeded()) {
				return execution.getResult();
			}

			if (targetType.isEnum()) {
				return instantiateEnum(stringToParse, targetType);
			}
		}
	} catch (RuntimeException e) {
		throw new IllegalArgumentException(coercingExceptionMessage(stringToParse, type), e);
	}
	throw new IllegalArgumentException(coercingExceptionMessage(stringToParse, type));
}
 
开发者ID:piotrturski,项目名称:zohhak,代码行数:23,代码来源:CoercingService.java

示例8: doArgTypesMatch

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
private static boolean doArgTypesMatch(Class<?>[] constructorTypes, Class<?>[] passedTypes) {

        for (int i = 0; i < constructorTypes.length; i++) {

            Class<?> constructorType = constructorTypes[i];
            Class<?> passedType = passedTypes[i];

            Class<?> wrappedConstructorType = ClassUtils.primitiveToWrapper(constructorType);

            if (passedType != null // skip if null, return the first constructor that matches the rest of the args types
                && !wrappedConstructorType.isAssignableFrom(passedType)) {
                return false;
            }
        }

        return true;
    }
 
开发者ID:williammartin,项目名称:illuminator,代码行数:18,代码来源:Illuminator.java

示例9: getField

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
private static FieldSpec getField(ClassName name, Key key) {
	Class<?> type = parseTypeFormat(key.getType(), key.getFormat());
	
	if(type.isPrimitive()) {
		type = ClassUtils.primitiveToWrapper(type);
	}
	
	return FieldSpec.builder(type, key.getId(), Modifier.PRIVATE).build();
}
 
开发者ID:skjolber,项目名称:json-log-domain,代码行数:10,代码来源:MarkerGenerator.java

示例10: getGetter

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
private static MethodSpec getGetter(ClassName name, Key key) {
	Class<?> type = parseTypeFormat(key.getType(), key.getFormat());
	if(type.isPrimitive()) {
		type = ClassUtils.primitiveToWrapper(type);
	}
	
	String id = key.getId();
	
	return getGetter(key, type, id);
}
 
开发者ID:skjolber,项目名称:json-log-domain,代码行数:11,代码来源:MarkerGenerator.java

示例11: getIndex

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
private int getIndex(Parameter[] parameters, Class<? extends Annotation> targetAnnotation, Class<?> targetType) {
	Class<?> wrappedType = ClassUtils.primitiveToWrapper(targetType);
	for (int i = 0; i < parameters.length; i++) {
		if (wrappedType.isAssignableFrom(ClassUtils.primitiveToWrapper(parameters[i].getType()))
			&& parameters[i].isAnnotationPresent(targetAnnotation)) return i;

	}
	return -1;
}
 
开发者ID:LogicalOverflow,项目名称:java-champion-gg-wrapper,代码行数:10,代码来源:ChampionGGTest.java

示例12: setPathValue

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
 * Sets given value specified by path of provided object.
 * Example:
 * Given path: "address.street"
 * means that on the given object there is a field named "address"
 * that, once referenced, contains field named "street"
 *
 * @param instance - object which contains the field.
 * @param path     - path to be used
 * @param value    - value to be set on the object.
 * @throws NoSuchMethodException     - exception
 * @throws IllegalAccessException    - exception
 * @throws InvocationTargetException - exception
 * @throws InstantiationException    - exception
 */
public static void setPathValue(Object instance, String path, Object value) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
    checkNotNull(path);
    Object ref = instance;
    Field refField = null;
    String[] split = path.split("\\.");
    for (int i = 0; i < split.length; i++) {
        String property = split[i];
        refField = getDeclaredField(ref.getClass(), property);
        if (!makeFieldAccessible(refField)) {
            throw new RandomitoException("Path cannot be accessed: " + path);
        }
        if (i < split.length - 1) {
            ref = refField.get(ref);
            if (ref == null) {
                throw new RandomitoException("Property is null: '"
                        + join(subarray(split, 0, i + 1), ".")
                        + "'. Maybe increase 'depth' parameter?");
            }
        }
    }

    if (value == null) {
        refField.set(instance, null);
        return;
    }
    Class<?> type = refField.getType();
    if (type.isPrimitive()) {
        type = ClassUtils.primitiveToWrapper(type);
    }
    if (Number.class.isAssignableFrom(type)) {
        refField.set(ref, stringToNumber(value, type));
    } else {
        refField.set(ref, value);
    }
}
 
开发者ID:randomito,项目名称:randomito-all,代码行数:51,代码来源:ReflectionUtils.java

示例13: getCodec

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private <T> Codec<T> getCodec(final Class<T> clazz) {
	final Class<T> wrapperClass = (Class<T>) ClassUtils.primitiveToWrapper(clazz);
	final Codec<T> codec = provider != null ? provider.get(wrapperClass, registry) : null;
	if(codec == null && registry != null) {
		return registry.get(wrapperClass);			
	}
	return codec;
}
 
开发者ID:JPDSousa,项目名称:mongo-obj-framework,代码行数:10,代码来源:AbstractBsonParser.java

示例14: convert

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
private Object convert(Object value) {
  if (value == null || !isSimple() || type.isAssignableFrom(value.getClass())) {
    return value;
  }
  if (Enum.class.isAssignableFrom(type)) {
    return Enum.valueOf((Class<? extends Enum>)type, value.toString());
  }
  Class<?> targetType = type.isPrimitive() ? ClassUtils.primitiveToWrapper(type) : type;
  try {
    return targetType.getConstructor(String.class).newInstance(value.toString());
  } catch (ReflectiveOperationException e) {
    throw new IllegalStateException(e);
  }
}
 
开发者ID:openknowledge,项目名称:jaxrs-versioning,代码行数:15,代码来源:FieldVersionProperty.java

示例15: generateFieldInfoInputs

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
 * Use reflection to generate field info values if the user has not provided
 * the inputs mapping
 *
 * @return String representing the POJO field to JSON field mapping
 */
private String generateFieldInfoInputs(Class<?> cls)
{
  java.lang.reflect.Field[] fields = cls.getDeclaredFields();
  StringBuilder sb = new StringBuilder();
  for (int i = 0; i < fields.length; i++) {
    java.lang.reflect.Field f = fields[i];
    Class<?> c = ClassUtils.primitiveToWrapper(f.getType());
    sb.append(f.getName()).append(FIELD_SEPARATOR).append(f.getName()).append(FIELD_SEPARATOR)
        .append(c.getSimpleName().toUpperCase()).append(RECORD_SEPARATOR);
  }
  return sb.substring(0, sb.length() - 1);
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:19,代码来源:StreamingJsonParser.java


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