BarBuilderNodeDescriptor implements BarBuilderDescriptor { @Override public Analytic instantiateBuilderAnalytic() { Constructor<?>[] constructorArray = analyticsClass.getDeclaredConstructors(); for (Constructor<?> constructor : constructorArray) { constructor.setAccessible(true); Class<?>[] parameterTypes = constructor.getParameterTypes(); if(parameterTypes.length == 1 && (getConstructorArg().getClass().equals(parameterTypes[0]))) { try { return (Analytic)constructor.newInstance(new Object[] { getConstructorArg() }); }catch(Exception e) { e.printStackTrace(); } } } throw new IllegalStateException("Unable to instantiate Analytic class using constructor containing " + "1 arguments of type <S extends Subscription> using argument: [s=" + getConstructorArg().getClass().getName() + "]"); } BarBuilderNodeDescriptor(); String getNetworkName(); void setNetworkName(String name); void reloadFile(); void reloadStream(InputStream stream); static SeriesSubscription getLowerSubscription(SeriesSubscription input); String toString(); @Override Class<? extends Analytic> getAnalyticClass(); @Override void setAnalyticClass(Class<? extends Analytic> clazz); @Override int[] getConstructorArgs(); @Override void setConstructorArgs(int[] args); @Override String getOutputKey(); @Override void setOutputKey(String key); @Override Analytic instantiateAnalytic(); @Override Analytic instantiateBuilderAnalytic(); @Override String getSpecifier(); @Override NodeType getType(); @SuppressWarnings("unchecked") @Override T getConstructorArg(); @Override void setConstructorArg(T arg);  }
@Test public void testInstantiateBuilderAnalytic() { String symbol = "ESZ13"; Instrument instr = TestHarness.makeInstrument(symbol); DateTime dt1 = new DateTime(2013, 12, 10, 12, 0, 0); TimeFrameImpl tf1 = new TimeFrameImpl(new Period(PeriodType.TICK, 1), dt1, null); SeriesSubscription sub1 = new SeriesSubscription("ESZ13", instr, "IO", new TimeFrameImpl[] { tf1 }, TradingWeekImpl.DEFAULT); BarBuilderNodeDescriptor desc = new BarBuilderNodeDescriptor(); desc.setAnalyticClass(BarBuilder.class); desc.setConstructorArg(sub1); try { BarBuilder bb = (BarBuilder)desc.instantiateBuilderAnalytic(); assertNotNull(bb); }catch(Exception e) { e.printStackTrace(); fail(); } }