當前位置: 首頁>>代碼示例>>Java>>正文


Java BeanUtils類代碼示例

本文整理匯總了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;
}
 
開發者ID:yunjiweidian,項目名稱:TITAN,代碼行數:33,代碼來源:LinkServiceImpl.java

示例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);
}
 
開發者ID:jeikerxiao,項目名稱:X-mall,代碼行數:12,代碼來源:UserServiceImpl.java

示例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;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:27,代碼來源:HandlerMethodInvoker.java

示例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));
    }
}
 
開發者ID:zouzhirong,項目名稱:configx,代碼行數:28,代碼來源:ConfigBeanFactory.java

示例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"));
}
 
開發者ID:hmcts,項目名稱:document-management-store-app,代碼行數:19,代碼來源:DocumentContentVersionHalResource.java

示例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;
}
 
開發者ID:szsucok,項目名稱:sucok-framework,代碼行數:18,代碼來源:QueryResult.java

示例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());
}
 
開發者ID:Chihpin,項目名稱:Yidu,代碼行數:17,代碼來源:ArticleListAction.java

示例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.");
}
 
開發者ID:Chihpin,項目名稱:Yidu,代碼行數:23,代碼來源:ChapterEditAction.java

示例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;
}
 
開發者ID:howma03,項目名稱:sporticus,代碼行數:18,代碼來源:IUserProfile.java

示例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;
}
 
開發者ID:howma03,項目名稱:sporticus,代碼行數:17,代碼來源:IGroupMember.java

示例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 "";
    }
}
 
開發者ID:FastBootWeixin,項目名稱:FastBootWeixin,代碼行數:19,代碼來源:WxApiExecutor.java

示例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);
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:30,代碼來源:AbstractOsgiBundleApplicationContext.java

示例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;
}
 
開發者ID:luckyyeah,項目名稱:YiDu-Novel,代碼行數:28,代碼來源:BlockEditAction.java


注:本文中的org.springframework.beans.BeanUtils類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。