当前位置: 首页>>代码示例>>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;未经允许,请勿转载。