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


Java BeanUtils.cloneBean方法代碼示例

本文整理匯總了Java中org.apache.commons.beanutils.BeanUtils.cloneBean方法的典型用法代碼示例。如果您正苦於以下問題:Java BeanUtils.cloneBean方法的具體用法?Java BeanUtils.cloneBean怎麽用?Java BeanUtils.cloneBean使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.beanutils.BeanUtils的用法示例。


在下文中一共展示了BeanUtils.cloneBean方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getProtectedOxTrustApplicationConfiguration

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
private String getProtectedOxTrustApplicationConfiguration(ApplicationConfiguration oxTrustApplicationConfiguration) {
	try {
		ApplicationConfiguration resultOxTrustApplicationConfiguration = (ApplicationConfiguration) BeanUtils.cloneBean(oxTrustApplicationConfiguration);

		resultOxTrustApplicationConfiguration.setSvnConfigurationStorePassword(HIDDEN_PASSWORD_TEXT);
		resultOxTrustApplicationConfiguration.setKeystorePassword(HIDDEN_PASSWORD_TEXT);
		resultOxTrustApplicationConfiguration.setIdpSecurityKeyPassword(HIDDEN_PASSWORD_TEXT);
		resultOxTrustApplicationConfiguration.setIdpBindPassword(HIDDEN_PASSWORD_TEXT);
		resultOxTrustApplicationConfiguration.setMysqlPassword(HIDDEN_PASSWORD_TEXT);
		resultOxTrustApplicationConfiguration.setCaCertsPassphrase(HIDDEN_PASSWORD_TEXT);
		resultOxTrustApplicationConfiguration.setOxAuthClientPassword(HIDDEN_PASSWORD_TEXT);

		return jsonService.objectToJson(resultOxTrustApplicationConfiguration);
	} catch (Exception ex) {
		log.error("Failed to prepare JSON from ApplicationConfiguration: '{0}'", ex, oxTrustApplicationConfiguration);
	}

	return null;
}
 
開發者ID:AgarwalNeha1,項目名稱:gluu,代碼行數:20,代碼來源:JsonConfigurationAction.java

示例2: edit

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
@PostMapping("/{id}/edit")
public String edit(@PathVariable String id, @RequestParam(required = false) String title,
		@RequestParam(required = false) String body, @RequestParam(required = false) String tags,
		HttpServletRequest req) {

	Post showPost = pc.read(id);
	Profile authUser = utils.getAuthUser(req);
	if (!utils.canEdit(showPost, authUser) || showPost == null) {
		return "redirect:" + req.getRequestURI();
	}
	Post beforeUpdate = null;
	try {
		beforeUpdate = (Post) BeanUtils.cloneBean(showPost);
	} catch (Exception ex) {
		logger.error(null, ex);
	}

	if (!StringUtils.isBlank(title) && title.length() > 10) {
		showPost.setTitle(title);
	}
	if (!StringUtils.isBlank(body)) {
		showPost.setBody(body);
	}
	if (!StringUtils.isBlank(tags) && showPost.isQuestion()) {
		showPost.setTags(Arrays.asList(StringUtils.split(tags, ",")));
	}

	//note: update only happens if something has changed
	if (!showPost.equals(beforeUpdate)) {
		showPost.setLasteditby(authUser.getId());
		showPost.setLastedited(System.currentTimeMillis());
		showPost.update();
		utils.addBadgeOnceAndUpdate(authUser, Badge.EDITOR, true);
	}
	return "redirect:" + showPost.getPostLink(false, false);
}
 
開發者ID:Erudika,項目名稱:scoold,代碼行數:37,代碼來源:QuestionController.java

示例3: cloneBean

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
/**
 * 複製一個對象並返回,屬於淺度克隆,對象所屬類必須符合JavaBean規範
 *
 * @param bean 被複製的對象
 * @return 返回一個被複製對象的一個副本
 */
@SuppressWarnings("unchecked")
public static <T extends Object> T cloneBean(T bean) {
    try {
        T newBean = (T) BeanUtils.cloneBean(bean);
        return newBean;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:FlyingHe,項目名稱:UtilsMaven,代碼行數:16,代碼來源:CommonUtils.java

示例4: cloneCDR

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
public CDR cloneCDR(){
    try {
        return (CDR) BeanUtils.cloneBean(this);
    } catch (IllegalAccessException | InvocationTargetException | InstantiationException | NoSuchMethodException e) {
        e.printStackTrace();
    }
    return null;
}
 
開發者ID:mapr-demos,項目名稱:telco-anomaly-detection-spark,代碼行數:9,代碼來源:CDR.java

示例5: cloneBean

import org.apache.commons.beanutils.BeanUtils; //導入方法依賴的package包/類
/**
 * Clone bean.
 *
 * @param <T>
 *            the generic type
 * @param bean
 *            the bean
 * @return the t
 */
public static <T> T cloneBean(final Object bean) {
	try {
		return (T) BeanUtils.cloneBean(bean);
	} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
		throw new RuntimeException(e);
	}
}
 
開發者ID:kiswanij,項目名稱:jk-util,代碼行數:17,代碼來源:JKObjectUtil.java


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