/** * Transforms the input by ignoring the input and returning the result of * calling the decorated factory. * * @param input the input object to transform * @return the transformed result */ public Object transform(Object input) { return iFactory.create(); }
/** * Transforms the input by ignoring the input and returning the result of * calling the decorated factory. * * @param input the input object to transform * @return the transformed result */ public Object transform(Object input) { return iFactory.create(); }
/** * Creates a new instance of the map value Collection container * using the factory. * <p> * This method can be overridden to perform your own processing * instead of using the factory. * * @param size the collection size that is about to be added * @return the new collection */ protected Collection createCollection(int size) { return (Collection) collectionFactory.create(); }
/** * Creates a new instance of the map value Collection container * using the factory. * <p> * This method can be overridden to perform your own processing * instead of using the factory. * * @param size the collection size that is about to be added * @return the new collection */ protected Collection createCollection(int size) { return (Collection) collectionFactory.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(); }
public void testInstantiateFactoryComplex() { TimeZone.setDefault(TimeZone.getTimeZone("GMT")); // 2nd Jan 1970 Factory factory = FactoryUtils.instantiateFactory(Date.class, new Class[] {Integer.TYPE, Integer.TYPE, Integer.TYPE}, new Object[] {new Integer(70), new Integer(0), new Integer(2)}); assertNotNull(factory); Object created = factory.create(); assertTrue(created instanceof Date); // long time of 1 day (== 2nd Jan 1970) assertEquals(new Date(1000 * 60 * 60 * 24), created); }
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 testPrototypeFactoryPublicSerialization() throws Exception { Integer proto = new Integer(9); Factory factory = FactoryUtils.prototypeFactory(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 testConstantFactoryConstant() { Integer constant = new Integer(9); Factory factory = FactoryUtils.constantFactory(constant); assertNotNull(factory); Object created = factory.create(); assertSame(constant, created); }
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"); } }
public void testConstantFactoryNull() { Factory factory = FactoryUtils.constantFactory(null); assertNotNull(factory); Object created = factory.create(); assertNull(created); }
public void testNullFactory() { Factory factory = FactoryUtils.nullFactory(); assertNotNull(factory); Object created = factory.create(); assertNull(created); }
public void testPrototypeFactoryPublicSerializationError() { Mock2 proto = new Mock2(new Object()); Factory factory = FactoryUtils.prototypeFactory(proto); assertNotNull(factory); try { Object created = factory.create(); } catch (FunctorException ex) { assertTrue(ex.getCause() instanceof IOException); return; } fail(); }
public void testExceptionFactory() { assertNotNull(FactoryUtils.exceptionFactory()); assertSame(FactoryUtils.exceptionFactory(), FactoryUtils.exceptionFactory()); try { FactoryUtils.exceptionFactory().create(); } catch (FunctorException ex) { try { FactoryUtils.exceptionFactory().create(); } catch (FunctorException ex2) { return; } } fail(); }
/** * 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 static void buildFooter(BSContainer<?> footer, WicketBuildContext ctx, Factory createAddButton) { if (canAddItems(ctx)) { final TemplatePanel template = footer.newTemplateTag(tp -> createButtonMarkup(ctx)); template.add((Component) createAddButton.create()); } else { footer.setVisible(false); } personalizeCSS(footer); }