AnalyticNodeDescriptor implements AnalyticDescriptor { public Analytic instantiateAnalytic() { Constructor<?>[] constructorArray = analyticClass.getConstructors(); for (Constructor<?> constructor : constructorArray) { Class<?>[] parameterTypes = constructor.getParameterTypes(); if(parameterTypes.length == constructorArgs.length) { Object[] parameters = new Object[parameterTypes.length]; for (int i = 0;i < parameterTypes.length;i++) { parameters[i] = new Integer(this.constructorArgs[i]); } try { Analytic a = (Analytic)constructor.newInstance(parameters); a.setName(nodeName); return a; }catch(Exception e) { } } } throw new IllegalStateException("Unable to instantiate Analytic class using constructor containing " + (constructorArgs == null ? 0:constructorArgs.length) + " arguments"); } AnalyticNodeDescriptor(String networkName, String nodeName); @Override String getSpecifier(); @Override NodeType getType(); String getNetworkName(); void setNetworkName(String name); String[] getTimeFrames(); void setTimeFrames(String[] timeFrames); @Override Class<? extends Analytic> getAnalyticClass(); @Override void setAnalyticClass(Class<? extends Analytic> clazz); @Override int[] getConstructorArgs(); @Override void setConstructorArgs(int[] args); String getOutputKey(); void setOutputKey(String key); void mapInputDescriptor(String key, AnalyticNodeDescriptor desc); void mapTimeFrame(String key, String[] timeFrames); Analytic instantiateAnalytic(); List<AnalyticNodeDescriptor> getInputNodeDescriptors(); AnalyticNodeDescriptor getInputNodeDescriptor(String sourceKey); String[] getInputTimeframes(String sourceKey); int getTimeframeIndex(String tf); void loadSearchDescriptor(SearchDescriptor desc, SeriesSubscription subscription); Map<String,SeriesSubscription> getRequiredSubscriptions(SeriesSubscription subscription);  }
@Test public void testInstantiateAnalytic() { String entry = "PivotPointOverlay;PP_S3L,Overlay,Base;com.barchart.feed.series.analytics.PivotPoint;2;Support3;Overlay,IO;Base,IO"; AnalyticNodeDescriptor desc = NetworkSchema.loadDescriptor(entry.split(";")); assertNotNull(desc); Analytic analytic = desc.instantiateAnalytic(); assertNotNull(analytic); }