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

The following examples show how to use org.springframework.beans.BeanUtils#isSimpleValueType() . These examples are extracted from open source projects. 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 Project: FastBootWeixin   File: WxApiExecutor.java    License: 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 Project: FastBootWeixin   File: WxApiExecutor.java    License: 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 Project: spring-analysis-note   File: ModelFactory.java    License: 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 Project: java-technology-stack   File: ModelFactory.java    License: 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 5
@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 6
Source Project: lams   File: ModelFactory.java    License: 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 7
/**
 * 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
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 9
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
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
/**
 * 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
/**
 * 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 Project: spring-analysis-note   File: RedirectView.java    License: 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()));
}
 
Example 14
Source Project: java-technology-stack   File: RedirectView.java    License: 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 15
Source Project: lams   File: RedirectView.java    License: 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
/**
 * 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 17
Source Project: framework   File: BeanUtil.java    License: 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);
}