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:com.link_intersystems.lang.reflect.SerializableConstructorTest.java
@Test public void serialize() throws SecurityException, NoSuchMethodException { Constructor<ConstructorSerializationTestClass> constructor = ConstructorSerializationTestClass.class .getDeclaredConstructor(String.class); SerializableConstructor serializableConstructor = new SerializableConstructor(constructor); SerializableConstructor deserialized = (SerializableConstructor) SerializationUtils .clone(serializableConstructor); Constructor<?> deserializedMethod = deserialized.get(); assertEquals(constructor, deserializedMethod); }
From source file:com.eldar.models.resources.Style.java
@Override public StyleVersion cloneCurrentVersion() { StyleVersion clone = SerializationUtils.clone(version); clone.setId(0); return clone; }
From source file:com.logimethods.connector.spark.to_nats.SparkToStandardNatsSerializationTest.java
@Test public void SparkToStandardNatsConnectorImplTest() throws IOException { Long duration = 111l;/* w w w . ja v a 2s . c o m*/ SparkToStandardNatsConnectorImpl source = new SparkToStandardNatsConnectorImpl(natsURL, properties, duration, connectionFactory, subjects, isStoredAsKeyValue); SparkToStandardNatsConnectorImpl target = SerializationUtils.clone(source); assertEquals(source.getNatsURL(), target.getNatsURL()); assertEquals(source.getProperties(), target.getProperties()); assertEquals(source.getSubjects(), target.getSubjects()); assertEquals(duration, target.connectionTimeout); assertEquals(isStoredAsKeyValue, target.isStoredAsKeyValue()); }
From source file:com.mirth.connect.model.datatype.DataTypeProperties.java
public DataTypeProperties clone() { return SerializationUtils.clone(this); }
From source file:com.link_intersystems.lang.ref.CopyOnAccessReference.java
/** * {@inheritDoc}. Always returns a copy of the referent. * * @since 1.2.0.0//from w ww . j a v a 2s. c o m */ public T get() { if (referentToCopyOnAccess == null) { return null; } T clone = SerializationUtils.clone(referentToCopyOnAccess); return clone; }
From source file:com.gargoylesoftware.htmlunit.DefaultCredentialsProvider3Test.java
/** * @throws Exception if an error occurs/*from ww w . ja va 2 s . c o m*/ */ @Test public void serialization() throws Exception { final String username = "foo"; final String password = "password"; final String host = "my.host"; final int port = 1234; final String realm = "blah"; final String scheme = "NTLM"; DefaultCredentialsProvider provider = new DefaultCredentialsProvider(); provider.addCredentials(username, password, host, port, realm); assertNotNull(provider.getCredentials(new AuthScope(host, port, realm, scheme))); assertNull(provider.getCredentials(new AuthScope("invalidHost", port, realm, scheme))); assertNotNull(provider.getCredentials(new AuthScope(host, port, realm, scheme))); assertNull(provider.getCredentials(new AuthScope("invalidHost", port, realm, scheme))); provider = SerializationUtils.clone(provider); assertNotNull(provider.getCredentials(new AuthScope(host, port, realm, scheme))); assertNull(provider.getCredentials(new AuthScope("invalidHost", port, realm, scheme))); assertNotNull(provider.getCredentials(new AuthScope(host, port, realm, scheme))); assertNull(provider.getCredentials(new AuthScope("invalidHost", port, realm, scheme))); }
From source file:com.link_intersystems.lang.reflect.criteria.ElementCriteriaTest.java
@Test public void elementCriteriaSerializable() { SerializationUtils.clone(getElementCriteria()); }
From source file:bancvirt.Recurso.java
public Recurso clone() { return SerializationUtils.clone(this); }
From source file:at.gridtec.lambda4j.generator.util.LambdaUtils.java
/** * Returns a deep copy of the given lambda. * * @param lambda The lambda to be copied * @return A deep copy of the given lambda. * @throws NullPointerException If given lambda is {@code null} *//*from w ww . ja v a2s. c om*/ public static LambdaEntity copy(@Nonnull final LambdaEntity lambda) { Objects.requireNonNull(lambda); return SerializationUtils.clone(lambda); }
From source file:com.ivan1pl.animations.data.MovingAnimation.java
public void updateBackground() { Selection s = SerializationUtils.clone(selection); s.expand(stepX * getFrameCount(), stepY * getFrameCount(), stepZ * getFrameCount()); background = Frame.fromSelection(s); }