/** * Creates a Factory that will return a clone of the same prototype object * each time the factory is used. The prototype will be cloned using one of these * techniques (in order): * <ul> * <li>public clone method * <li>public copy constructor * <li>serialization clone * <ul> * * @see org.apache.commons.collections.functors.PrototypeFactory * * @param prototype the object to clone each time in the factory * @return the <code>prototype</code> factory * @throws IllegalArgumentException if the prototype is null * @throws IllegalArgumentException if the prototype cannot be cloned */ public static Factory prototypeFactory(Object prototype) { return PrototypeFactory.getInstance(prototype); }
/** * Creates a Factory that will return a clone of the same prototype object * each time the factory is used. The prototype will be cloned using one of these * techniques (in order): * <ul> * <li>public clone method * <li>public copy constructor * <li>serialization clone * <ul> * * @see org.apache.commons.collections.functors.PrototypeFactory * * @param prototype the object to clone each time in the factory * @return the <code>prototype</code> factory * @throws IllegalArgumentException if the prototype is null * @throws IllegalArgumentException if the prototype cannot be cloned */ public static Factory prototypeFactory(Object prototype) { return PrototypeFactory.getInstance(prototype); }
/** * Transforms the input to result by cloning it. * * @param input the input object to transform * @return the transformed result */ public Object transform(Object input) { if (input == null) { return null; } return PrototypeFactory.getInstance(input).create(); }
/** * Transforms the input to result by cloning it. * * @param input the input object to transform * @return the transformed result */ public Object transform(Object input) { if (input == null) { return null; } return PrototypeFactory.getInstance(input).create(); }
public Object makeObject() { return PrototypeFactory.getInstance(new ArrayList()); }
public void testPrototypeFactoryPublicCloneMethod() throws Exception { Date proto = new Date(); Factory factory = PrototypeFactory.getInstance(proto); assertNotNull(factory); Object created = factory.create(); assertTrue(proto != created); assertEquals(proto, created); // check serialisation works - if enabled System.setProperty(FunctorUtils.UNSAFE_SERIALIZABLE_PROPERTY, "true"); try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(buffer); out.writeObject(factory); out.close(); ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); Object dest = in.readObject(); in.close(); } finally { System.setProperty(FunctorUtils.UNSAFE_SERIALIZABLE_PROPERTY, "false"); } }
public void testPrototypeFactoryPublicCopyConstructor() throws Exception { Mock1 proto = new Mock1(6); Factory factory = PrototypeFactory.getInstance(proto); assertNotNull(factory); Object created = factory.create(); assertTrue(proto != created); assertEquals(proto, created); // check serialisation works - if enabled System.setProperty(FunctorUtils.UNSAFE_SERIALIZABLE_PROPERTY, "true"); try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(buffer); try { out.writeObject(factory); } catch (NotSerializableException ex) { out.close(); } factory = FactoryUtils.prototypeFactory(new Mock2("S")); buffer = new ByteArrayOutputStream(); out = new ObjectOutputStream(buffer); out.writeObject(factory); out.close(); ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); Object dest = in.readObject(); in.close(); } finally { System.setProperty(FunctorUtils.UNSAFE_SERIALIZABLE_PROPERTY, "false"); } }
/** * Creates a Factory that will return a clone of the same prototype object * each time the factory is used. The prototype will be cloned using one of these * techniques (in order): * <ul> * <li>public clone method * <li>public copy constructor * <li>serialization clone * <ul> * * @see org.apache.commons.collections.functors.PrototypeFactory * * @param prototype the object to clone each time in the factory * @return the <code>prototype</code> factory * @throws IllegalArgumentException if the prototype is null * @throws IllegalArgumentException if the prototype cannot be cloned */ public static Factory prototypeFactory(Object prototype) { return PrototypeFactory.getInstance(prototype); }
/** * Creates a Factory that will return a clone of the same prototype object * each time the factory is used. The prototype will be cloned using one of these * techniques (in order): * <ul> * <li>public clone method * <li>public copy constructor * <li>serialization clone * <ul> * * @see org.apache.commons.collections.functors.PrototypeFactory * * @param prototype the object to clone each time in the factory * @return the <code>prototype</code> factory * @throws IllegalArgumentException if the prototype is null * @throws IllegalArgumentException if the prototype cannot be cloned */ public static Factory prototypeFactory(Object prototype) { return PrototypeFactory.getInstance(prototype); }
/** * Creates a Factory that will return a clone of the same prototype object * each time the factory is used. The prototype will be cloned using one of these * techniques (in order): * <ul> * <li>public clone method * <li>public copy constructor * <li>serialization clone * <ul> * * @see org.apache.commons.collections.functors.PrototypeFactory * * @param prototype the object to clone each time in the factory * @return the <code>prototype</code> factory * @throws IllegalArgumentException if the prototype is null * @throws IllegalArgumentException if the prototype cannot be cloned */ public static Factory prototypeFactory(Object prototype) { return PrototypeFactory.getInstance(prototype); }
/** * Creates a Factory that will return a clone of the same prototype object * each time the factory is used. The prototype will be cloned using one of these * techniques (in order): * <ul> * <li>public clone method * <li>public copy constructor * <li>serialization clone * <ul> * * @see org.apache.commons.collections.functors.PrototypeFactory * * @param prototype the object to clone each time in the factory * @return the <code>prototype</code> factory * @throws IllegalArgumentException if the prototype is null * @throws IllegalArgumentException if the prototype cannot be cloned */ public static Factory prototypeFactory(Object prototype) { return PrototypeFactory.getInstance(prototype); }
/** * Creates a Factory that will return a clone of the same prototype object * each time the factory is used. The prototype will be cloned using one of these * techniques (in order): * <ul> * <li>public clone method * <li>public copy constructor * <li>serialization clone * <ul> * * @see org.apache.commons.collections.functors.PrototypeFactory * * @param prototype the object to clone each time in the factory * @return the <code>prototype</code> factory * @throws IllegalArgumentException if the prototype is null * @throws IllegalArgumentException if the prototype cannot be cloned */ public static Factory prototypeFactory(Object prototype) { return PrototypeFactory.getInstance(prototype); }
/** * Transforms the input to result by cloning it. * * @param input the input object to transform * @return the transformed result */ public Object transform(Object input) { if (input == null) { return null; } return PrototypeFactory.getInstance(input).create(); }
/** * Transforms the input to result by cloning it. * * @param input the input object to transform * @return the transformed result */ public Object transform(Object input) { if (input == null) { return null; } return PrototypeFactory.getInstance(input).create(); }
/** * Transforms the input to result by cloning it. * * @param input the input object to transform * @return the transformed result */ public Object transform(Object input) { if (input == null) { return null; } return PrototypeFactory.getInstance(input).create(); }
/** * Transforms the input to result by cloning it. * * @param input the input object to transform * @return the transformed result */ public Object transform(Object input) { if (input == null) { return null; } return PrototypeFactory.getInstance(input).create(); }
/** * Transforms the input to result by cloning it. * * @param input the input object to transform * @return the transformed result */ public Object transform(Object input) { if (input == null) { return null; } return PrototypeFactory.getInstance(input).create(); }