本文整理匯總了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;
}
示例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);
}
示例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);
}
}
示例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;
}
示例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);
}
}