Java Code Examples for org.springframework.beans.BeanUtils#isSimpleValueType()

The following examples show how to use org.springframework.beans.BeanUtils#isSimpleValueType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WxApiExecutor.java    From FastBootWeixin with Apache License 2.0 6 votes vote down vote up
private Object getObjectBody(WxApiMethodInfo wxApiMethodInfo, Object[] args) {
    MethodParameter methodParameter = wxApiMethodInfo.getMethodParameters().stream()
            .filter(p -> !BeanUtils.isSimpleValueType(p.getParameterType()) || p.hasParameterAnnotation(WxApiBody.class))
            .findFirst().orElse(null);
    if (methodParameter == null) {
        throw new WxAppException("没有可处理的参数");
    }
    // 不是简单类型
    if (!BeanUtils.isSimpleValueType(methodParameter.getParameterType())) {
        // 暂时只支持json
        return args[methodParameter.getParameterIndex()];
    }
    if (args[methodParameter.getParameterIndex()] != null) {
        return args[methodParameter.getParameterIndex()].toString();
    } else {
        return "";
    }
}
 
Example 2
Source File: WxApiExecutor.java    From FastBootWeixin with Apache License 2.0 6 votes vote down vote up
private String getStringBody(WxApiMethodInfo wxApiMethodInfo, Object[] args) {
    MethodParameter methodParameter = wxApiMethodInfo.getMethodParameters().stream()
            .filter(p -> !BeanUtils.isSimpleValueType(p.getParameterType()) || p.hasParameterAnnotation(WxApiBody.class))
            .findFirst().orElse(null);
    if (methodParameter == null) {
        throw new WxAppException("没有可处理的参数");
    }
    // 不是简单类型
    if (!BeanUtils.isSimpleValueType(methodParameter.getParameterType())) {
        try {
            // 暂时只支持json
            return jsonConverter.writeValueAsString(args[methodParameter.getParameterIndex()]);
        } catch (JsonProcessingException e) {
            logger.error(e.getMessage(), e);
        }
    }
    if (args[methodParameter.getParameterIndex()] != null) {
        return args[methodParameter.getParameterIndex()].toString();
    } else {
        return "";
    }
}
 
Example 3
Source File: ModelFactory.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Whether the given attribute requires a {@link BindingResult} in the model.
 */
private boolean isBindingCandidate(String attributeName, Object value) {
	if (attributeName.startsWith(BindingResult.MODEL_KEY_PREFIX)) {
		return false;
	}

	if (this.sessionAttributesHandler.isHandlerSessionAttribute(attributeName, value.getClass())) {
		return true;
	}

	return (!value.getClass().isArray() && !(value instanceof Collection) &&
			!(value instanceof Map) && !BeanUtils.isSimpleValueType(value.getClass()));
}
 
Example 4
Source File: ReactiveMongoNativeJavaDriverQueryExecutor.java    From mongodb-aggregate-query-support with Apache License 2.0 5 votes vote down vote up
private <T> Mono<T> adaptPipeline(QueryProvider queryProvider, Class<T> outputClass, Mono<Document> retval) {
  String key = queryProvider.getQueryResultKey();
  if (BeanUtils.isSimpleValueType(outputClass)) {
    return retval.map(d -> d.get(key, outputClass))
                 .doOnError(e -> LOGGER.error("Exception while extracting results from document for key {}", key, e));
  }
  return retval.map(d -> (Document) getDocumentForKey(key, d, false))
               .map(d -> d.toBsonDocument(Document.class, CodecRegistries.fromCodecs(new DocumentCodec())))
               .map((d) -> deserialize(outputClass, d))
               .doOnError(e -> LOGGER.error("Exception while extracting results from document for key {}", key, e));
}
 
Example 5
Source File: ModelFactory.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Whether the given attribute requires a {@link BindingResult} in the model.
 */
private boolean isBindingCandidate(String attributeName, Object value) {
	if (attributeName.startsWith(BindingResult.MODEL_KEY_PREFIX)) {
		return false;
	}

	if (this.sessionAttributesHandler.isHandlerSessionAttribute(attributeName, value.getClass())) {
		return true;
	}

	return (!value.getClass().isArray() && !(value instanceof Collection) &&
			!(value instanceof Map) && !BeanUtils.isSimpleValueType(value.getClass()));
}
 
Example 6
Source File: RestObjectMapperWithStringMapper.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Override
public <T> T convertValue(Object fromValue, JavaType toValueType) throws IllegalArgumentException {
  if (String.class.isInstance(fromValue)
      && !BeanUtils.isSimpleValueType(toValueType.getRawClass())) {
    try {
      return super.readValue((String) fromValue, toValueType);
    } catch (IOException e) {
      LOGGER.error("Failed to convert value for {}.", e.getMessage());
    }
  }
  return super.convertValue(fromValue, toValueType);
}
 
Example 7
Source File: ModelFactory.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Whether the given attribute requires a {@link BindingResult} in the model.
 */
private boolean isBindingCandidate(String attributeName, Object value) {
	if (attributeName.startsWith(BindingResult.MODEL_KEY_PREFIX)) {
		return false;
	}

	Class<?> attrType = (value != null ? value.getClass() : null);
	if (this.sessionAttributesHandler.isHandlerSessionAttribute(attributeName, attrType)) {
		return true;
	}

	return (value != null && !value.getClass().isArray() && !(value instanceof Collection) &&
			!(value instanceof Map) && !BeanUtils.isSimpleValueType(value.getClass()));
}
 
Example 8
Source File: ModelFactory.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Whether the given attribute requires a {@link BindingResult} in the model.
 */
private boolean isBindingCandidate(String attributeName, Object value) {
	if (attributeName.startsWith(BindingResult.MODEL_KEY_PREFIX)) {
		return false;
	}

	Class<?> attrType = (value != null) ? value.getClass() : null;
	if (this.sessionAttributesHandler.isHandlerSessionAttribute(attributeName, attrType)) {
		return true;
	}

	return (value != null && !value.getClass().isArray() && !(value instanceof Collection) &&
			!(value instanceof Map) && !BeanUtils.isSimpleValueType(value.getClass()));
}
 
Example 9
Source File: ViewResolutionResultHandler.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private boolean isBindingCandidate(String name, @Nullable Object value) {
	return (!name.startsWith(BindingResult.MODEL_KEY_PREFIX) && value != null &&
			!value.getClass().isArray() && !(value instanceof Collection) &&
			!(value instanceof Map) && !BeanUtils.isSimpleValueType(value.getClass()));
}
 
Example 10
Source File: ViewResolutionResultHandler.java    From java-technology-stack with MIT License 4 votes vote down vote up
private boolean isBindingCandidate(String name, @Nullable Object value) {
	return (!name.startsWith(BindingResult.MODEL_KEY_PREFIX) && value != null &&
			!value.getClass().isArray() && !(value instanceof Collection) &&
			!(value instanceof Map) && !BeanUtils.isSimpleValueType(value.getClass()));
}
 
Example 11
Source File: HandlerMethodInvoker.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
/**
 * Determine whether the given value qualifies as a "binding candidate", i.e. might potentially be subject to
 * bean-style data binding later on.
 */
protected boolean isBindingCandidate(Object value) {
	return (value != null && !value.getClass().isArray() && !(value instanceof Collection) &&
			!(value instanceof Map) && !BeanUtils.isSimpleValueType(value.getClass()));
}
 
Example 12
Source File: HandlerMethodInvoker.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determine whether the given value qualifies as a "binding candidate", i.e. might potentially be subject to
 * bean-style data binding later on.
 */
protected boolean isBindingCandidate(Object value) {
	return (value != null && !value.getClass().isArray() && !(value instanceof Collection) &&
			!(value instanceof Map) && !BeanUtils.isSimpleValueType(value.getClass()));
}
 
Example 13
Source File: BeanUtil.java    From framework with Apache License 2.0 2 votes vote down vote up
/**
 * Description: <br>
 * 
 * @author yang.zhipeng <br>
 * @taskId <br>
 * @param clazz <br>
 * @return <br>
 */
public static boolean isSimpleValueType(final Class<?> clazz) {
    return BeanUtils.isSimpleValueType(clazz);
}
 
Example 14
Source File: RedirectView.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Determine whether the given model element value is eligible for exposure.
 * <p>The default implementation considers primitives, Strings, Numbers, Dates,
 * URIs, URLs and Locale objects as eligible. This can be overridden in subclasses.
 * @param value the model element value
 * @return whether the element value is eligible
 * @see BeanUtils#isSimpleValueType
 */
protected boolean isEligibleValue(Object value) {
	return (value != null && BeanUtils.isSimpleValueType(value.getClass()));
}
 
Example 15
Source File: RedirectView.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Determine whether the given model element value is eligible for exposure.
 * <p>The default implementation considers primitives, Strings, Numbers, Dates,
 * URIs, URLs and Locale objects as eligible. This can be overridden in subclasses.
 * @param value the model element value
 * @return whether the element value is eligible
 * @see BeanUtils#isSimpleValueType
 */
protected boolean isEligibleValue(Object value) {
	return (value != null && BeanUtils.isSimpleValueType(value.getClass()));
}
 
Example 16
Source File: RedirectView.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Determine whether the given model element value is eligible for exposure.
 * <p>The default implementation considers primitives, Strings, Numbers, Dates,
 * URIs, URLs and Locale objects as eligible. This can be overridden in subclasses.
 * @param value the model element value
 * @return whether the element value is eligible
 * @see BeanUtils#isSimpleValueType
 */
protected boolean isEligibleValue(@Nullable Object value) {
	return (value != null && BeanUtils.isSimpleValueType(value.getClass()));
}
 
Example 17
Source File: RedirectView.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Determine whether the given model element value is eligible for exposure.
 * <p>The default implementation considers primitives, strings, numbers, dates,
 * URIs, URLs etc as eligible, according to {@link BeanUtils#isSimpleValueType}.
 * This can be overridden in subclasses.
 * @param value the model element value
 * @return whether the element value is eligible
 * @see BeanUtils#isSimpleValueType
 */
protected boolean isEligibleValue(@Nullable Object value) {
	return (value != null && BeanUtils.isSimpleValueType(value.getClass()));
}