本文整理汇总了Java中org.springframework.beans.BeanUtils类的典型用法代码示例。如果您正苦于以下问题:Java BeanUtils类的具体用法?Java BeanUtils怎么用?Java BeanUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BeanUtils类属于org.springframework.beans包,在下文中一共展示了BeanUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLinkList
import org.springframework.beans.BeanUtils; //导入依赖的package包/类
/**
* @desc 分页查询所有链路列表
*
* @author liuliang
*
* @param pageIndex 当前页
* @param pageSize 每页条数
* @return List<LinkBO> 链路BO集合
* @throws Exception
*/
@Override
public List<LinkBO> getLinkList(String linkName,int pageIndex, int pageSize) throws Exception{
//1、查询
List<Link> linkList = null;
if(StringUtils.isBlank(linkName)){
linkList = linkDao.queryLinkByPage(pageIndex, pageSize);
}else{
linkList = linkDao.queryLinkByPage(linkName,pageIndex, pageSize);
}
//2、转换
List<LinkBO> linkBOList = new ArrayList<LinkBO>();
if((null != linkList) && (0 < linkList.size())){
LinkBO linkBO = null;
for(Link link:linkList){
linkBO = new LinkBO();
BeanUtils.copyProperties(link, linkBO);
linkBOList.add(linkBO);
}
}
//3、返回
return linkBOList;
}
示例2: getUsers
import org.springframework.beans.BeanUtils; //导入依赖的package包/类
@Override
public ServerResponse<List<UserVo>> getUsers() {
List<User> userList = userMapper.selectAll();
List<UserVo> userVoList = new ArrayList<>();
for (User user : userList) {
UserVo userVo = new UserVo();
BeanUtils.copyProperties(user, userVo);
userVoList.add(userVo);
}
return ServerResponse.createBySuccess("获取用户成功", userVoList);
}
示例3: resolveModelAttribute
import org.springframework.beans.BeanUtils; //导入依赖的package包/类
private WebDataBinder resolveModelAttribute(String attrName, MethodParameter methodParam,
ExtendedModelMap implicitModel, NativeWebRequest webRequest, Object handler) throws Exception {
// Bind request parameter onto object...
String name = attrName;
if ("".equals(name)) {
name = Conventions.getVariableNameForParameter(methodParam);
}
Class<?> paramType = methodParam.getParameterType();
Object bindObject;
if (implicitModel.containsKey(name)) {
bindObject = implicitModel.get(name);
}
else if (this.methodResolver.isSessionAttribute(name, paramType)) {
bindObject = this.sessionAttributeStore.retrieveAttribute(webRequest, name);
if (bindObject == null) {
raiseSessionRequiredException("Session attribute '" + name + "' required - not found in session");
}
}
else {
bindObject = BeanUtils.instantiateClass(paramType);
}
WebDataBinder binder = createBinder(webRequest, bindObject, name);
initBinder(handler, name, binder, webRequest);
return binder;
}
示例4: createConfigBean
import org.springframework.beans.BeanUtils; //导入依赖的package包/类
/**
* 创建配置Bean
*
* @param propertyName 属性名
* @param beanType 配置Bean类型
* @param converterType 转换器类型
* @param configBeanPropertyResolver 属性解析器
* @param conversionService 转换服务
* @param <T>
* @return
*/
public static <T> T createConfigBean(String propertyName, Class<T> beanType,
Class<? extends ConfigBeanConverter> converterType,
ConfigPropertyResolver configBeanPropertyResolver,
ConfigBeanConversionService conversionService) {
PropertyResolver propertyResolver = configBeanPropertyResolver.getObject();
String propertyValue = propertyResolver.getRequiredProperty(propertyName);
if (converterType != null && !converterType.isInterface()) {
ConfigBeanConverter converter = BeanUtils.instantiate(converterType);
return (T) converter.convert(propertyName, propertyValue, TypeDescriptor.valueOf(beanType));
} else {
return (T) conversionService.convert(propertyName, propertyValue, TypeDescriptor.valueOf(beanType));
}
}
示例5: add
import org.springframework.beans.BeanUtils; //导入依赖的package包/类
/**
* Add booking with the specified information.
*
* @param bookingVO
* @return A non-null booking.
*/
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<Booking> add(@RequestBody BookingVO bookingVO) {
logger.info(String.format("booking-service add() invoked: %s for %s", bookingService.getClass().getName(), bookingVO.getName()));
System.out.println(bookingVO);
Booking booking = new Booking(null, null, null, null, null, null, null);
BeanUtils.copyProperties(bookingVO, booking);
try {
bookingService.add(booking);
} catch (Exception ex) {
logger.log(Level.WARNING, "Exception raised add Booking REST Call {0}", ex);
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
}
return new ResponseEntity<>(HttpStatus.CREATED);
}
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:21,代码来源:BookingController.java
示例6: DocumentContentVersionHalResource
import org.springframework.beans.BeanUtils; //导入依赖的package包/类
public DocumentContentVersionHalResource(DocumentContentVersion documentContentVersion) {
BeanUtils.copyProperties(documentContentVersion, this);
add(linkTo(methodOn(StoredDocumentController.class)
.getMetaData(documentContentVersion.getStoredDocument().getId())).withRel("document"));
add(linkTo(methodOn(DocumentContentVersionController.class).getDocumentContentVersionDocument(
documentContentVersion.getStoredDocument().getId(),
documentContentVersion.getId())).withRel("self"));
add(linkTo(methodOn(DocumentContentVersionController.class).getDocumentContentVersionDocumentBinary(
documentContentVersion.getStoredDocument().getId(),
documentContentVersion.getId())).withRel("binary"));
add(linkTo(methodOn(DocumentContentVersionController.class).getDocumentContentVersionDocumentPreviewThumbnail(
documentContentVersion.getStoredDocument().getId(),
documentContentVersion.getId())).withRel("thumbnail"));
}
示例7: treeSorted
import org.springframework.beans.BeanUtils; //导入依赖的package包/类
public QueryResult<T> treeSorted(String keyField, String parentKeyField, Object rootValue) {
try {
List<T> list = getData();
if (list.size() <= 0) {
return this;
}
Class<?> itemClass = list.get(0).getClass();
PropertyDescriptor keyProp = BeanUtils.getPropertyDescriptor(itemClass, keyField);
PropertyDescriptor parentKeyProp = BeanUtils.getPropertyDescriptor(itemClass, parentKeyField);
List<T> newList = new ArrayList<>(list.size());
addTreeNode(newList, list, rootValue, keyProp, parentKeyProp);
setData(newList);
} catch (Exception e) {
throw new RuntimeException(e);
}
return this;
}
示例8: loadData
import org.springframework.beans.BeanUtils; //导入依赖的package包/类
@Override
protected void loadData() {
ArticleSearchBean searchBean = new ArticleSearchBean();
BeanUtils.copyProperties(this, searchBean, new String[] { "articleno" });
searchBean.setPageType(ArticleSearchBean.PageType.adminPage);
if (StringUtils.isEmpty(pagination.getSortColumn())) {
pagination.setSortColumn("lastupdate");
pagination.setSortOrder("DESC");
}
// 总件数设置
pagination.setPreperties(articleService.getCount(searchBean));
searchBean.setPagination(pagination);
articleList = articleService.find(searchBean);
// Setting number of records in the particular page
pagination.setPageRecords(articleList.size());
}
示例9: loadData
import org.springframework.beans.BeanUtils; //导入依赖的package包/类
@Override
protected void loadData() {
logger.debug("loadData start.");
// 初始化种别下拉列表选项
initCollections(new String[] { "collectionProperties.chapter.isvip" });
if (chapterno == 0 && articleno == 0) {
addActionError(getText("errors.unknown"));
return;
}
// 编辑
if (chapterno != 0) {
TChapter chapter = chapterService.getByNo(chapterno);
BeanUtils.copyProperties(chapter, this);
content = Utils.getContext(chapter, false);
} else {
// 追加的话取小说信息
TArticle article = articleService.getByNo(articleno);
BeanUtils.copyProperties(article, this);
}
logger.debug("loadData normally end.");
}
示例10: COPY
import org.springframework.beans.BeanUtils; //导入依赖的package包/类
static IUserProfile COPY(final IUserProfile from, final IUserProfile to) {
if(from == null) {
return null;
}
if(to == null) {
return null;
}
BeanUtils.copyProperties(from, to);
if(from.isEnabled() != null) {
to.setEnabled(from.isEnabled());
}
if(from.isVerified() != null) {
to.setVerified(from.isVerified());
}
return to;
}
示例11: COPY
import org.springframework.beans.BeanUtils; //导入依赖的package包/类
static IGroupMember COPY(final IGroupMember from, final IGroupMember to) {
if (from == null) {
return null;
}
if (to == null) {
return null;
}
BeanUtils.copyProperties(from, to);
if (from.isEnabled() != null) {
to.setEnabled(from.isEnabled());
}
if (from.getStatus() != null) {
to.setStatus(from.getStatus());
}
return to;
}
示例12: add
import org.springframework.beans.BeanUtils; //导入依赖的package包/类
/**
* Add user with the specified information.
*
* @param userVO
* @return A non-null user.
*/
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<User> add(@RequestBody UserVO userVO) {
logger.info(String.format("user-service add() invoked: %s for %s", userService.getClass().getName(), userVO.getName()));
System.out.println(userVO);
User user = new User(null, null, null, null, null);
BeanUtils.copyProperties(userVO, user);
try {
userService.add(user);
} catch (Exception ex) {
logger.log(Level.WARNING, "Exception raised add User REST Call {0}", ex);
return new ResponseEntity<>(HttpStatus.UNPROCESSABLE_ENTITY);
}
return new ResponseEntity<>(HttpStatus.CREATED);
}
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:21,代码来源:UserController.java
示例13: getObjectBody
import org.springframework.beans.BeanUtils; //导入依赖的package包/类
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 "";
}
}
示例14: enforceExporterImporterDependency
import org.springframework.beans.BeanUtils; //导入依赖的package包/类
/**
* Takes care of enforcing the relationship between exporter and importers.
*
* @param beanFactory
*/
private void enforceExporterImporterDependency(ConfigurableListableBeanFactory beanFactory) {
Object instance = null;
instance = AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
// create the service manager
ClassLoader loader = AbstractOsgiBundleApplicationContext.class.getClassLoader();
try {
Class<?> managerClass = loader.loadClass(EXPORTER_IMPORTER_DEPENDENCY_MANAGER);
return BeanUtils.instantiateClass(managerClass);
} catch (ClassNotFoundException cnfe) {
throw new ApplicationContextException("Cannot load class " + EXPORTER_IMPORTER_DEPENDENCY_MANAGER,
cnfe);
}
}
});
// sanity check
Assert.isInstanceOf(BeanFactoryAware.class, instance);
Assert.isInstanceOf(BeanPostProcessor.class, instance);
((BeanFactoryAware) instance).setBeanFactory(beanFactory);
beanFactory.addBeanPostProcessor((BeanPostProcessor) instance);
}
示例15: save
import org.springframework.beans.BeanUtils; //导入依赖的package包/类
/**
*
* <p>
* 保存画面的内容
* </p>
*
* @return
*/
public String save() {
logger.debug("save start.");
// 初始化下拉列表选项
initCollections(new String[] { "collectionProperties.article.category", "collectionProperties.block.type",
"collectionProperties.block.target", "collectionProperties.block.sortCol",
"collectionProperties.boolean" });
TSystemBlock systemBlock = new TSystemBlock();
if (blockno != 0) {
systemBlock = systemBlockService.getByNo(blockno);
} else {
systemBlock.setDeleteflag(false);
}
BeanUtils.copyProperties(this, systemBlock);
systemBlock.setModifytime(new Date());
systemBlock.setModifyuserno(LoginManager.getLoginUser().getUserno());
systemBlockService.save(systemBlock);
logger.debug("save normally end.");
return REDIRECT;
}