List of usage examples for org.apache.commons.lang3 SerializationUtils clone
public static <T extends Serializable> T clone(final T object)
Deep clone an Object using serialization.
This is many times slower than writing clone methods by hand on all objects in your object graph.
From source file:ste.xtest.net.StubURLConnection.java
@Override public Object clone() { try {/*from www . j a v a 2 s . c o m*/ URL clonedURL = new URL(getURL().toString()); StubURLConnection C = new StubURLConnection(clonedURL); if (message != null) { C.message(new String(message)); } C.status(status); // // we need to preserve the content type if changed (setting content // sets also the type) // String originalType = getContentType(); if (content != null) { if (content instanceof byte[]) { byte[] original = (byte[]) content; byte[] clonedContent = new byte[original.length]; System.arraycopy(original, 0, clonedContent, 0, original.length); C.content(clonedContent); } else if (content instanceof String) { C.text(new String((String) content)); } else if (content instanceof Path) { C.file(new String(((Path) content).toString())); } } C.type(originalType); C.headers(SerializationUtils.clone(headers)); C.exec(exec); return C; } catch (MalformedURLException x) { // // This should never happen because the URL is sanitized when given // to the constructor // throw new IllegalStateException("unexpected malformed url " + getURL()); } catch (Throwable x) { x.printStackTrace(); throw x; } }
From source file:utils.CloneUtils.java
public static <T extends Model> T cloneModel(T source) { T model = SerializationUtils.clone(source); model._ebean_getIntercept().setLoaded(); model._ebean_getIntercept().setReference(); model._ebean_getIntercept().setIntercepting(false); return model; }
From source file:utils.CloneUtils.java
public static <T extends BaseModel> T cloneBaseModel(T source) { T model = SerializationUtils.clone(source); model.workspace = CacheUtils.getWorkspaceId(); model.id = null;/* w w w . j a v a2s. c om*/ model._ebean_getIntercept().setLoaded(); model._ebean_getIntercept().setReference(); model._ebean_getIntercept().setIntercepting(false); model.insertBy = null; model.insertAt = null; model.updateBy = null; model.updateAt = null; return model; }
From source file:utils.CloneUtils.java
public static <T extends AbstractBaseTrans> T cloneTransaction(T source) { T model = SerializationUtils.clone(source); model.workspace = CacheUtils.getWorkspaceId(); model.id = null;//from w ww .ja va2 s. com model._ebean_getIntercept().setLoaded(); model._ebean_getIntercept().setReference(); model._ebean_getIntercept().setIntercepting(false); model.insertBy = null; model.insertAt = null; model.updateBy = null; model.updateAt = null; if (Profiles.chosen().gnel_docNoIncType.equals(DocNoIncType.Full_Automatic)) model.transNo = DocNoUtils.findLastTransNo(model.right); model.receiptNo = DocNoUtils.findLastReceiptNo(model.right); RefModuleUtil.setTransientFields(model); return model; }
From source file:wsattacker.sso.openid.attacker.evaluation.attack.DiscoverySpoofingAttack.java
@Override protected void beforeAttack() { super.beforeAttack(); // copy of HTML and XRDS Discovery information by serialization htmlConfigCopy = SerializationUtils.clone(serverController.getConfig().getHtmlConfiguration()); xrdsConfigCopy = SerializationUtils.clone(serverController.getConfig().getXrdsConfiguration()); }
From source file:wsattacker.sso.openid.attacker.evaluation.attack.DtdAttack.java
@Override protected void beforeAttack() { super.beforeAttack(); // save XRDS document xrdsDocument = serverController.getConfig().getXrdsConfiguration().getXml(); // save HTML discovery by serialization HtmlDiscoveryConfiguration htmlConfig = serverController.getConfig().getHtmlConfiguration(); htmlConfigCopy = SerializationUtils.clone(htmlConfig); // disable HTML discovery htmlConfig.setIncludeIdentity(false); htmlConfig.setOpenidServer(false);//w w w . j a v a 2s . c o m htmlConfig.setOpenId2Provider(false); }
From source file:yoyo.framework.standard.shared.CommonUtils.java
/** * //from w ww .j av a2 s . c o m * @param object * @return ?? */ public static <T extends Serializable> T deepCopy(final T object) { return SerializationUtils.clone(object); }