/** * This will create an <code>Instance</code> that can be used * to instantiate objects of the specified class. This leverages * an internal constructor cache to ensure creation is quicker. * * @param type this is the type that is to be instantiated * * @return this will return an object for instantiating objects */ public Instance getInstance(Class type) { return instances.getInstance(type); }
/** * This method is used to acquire an instance of the type that * is defined by this object. If for some reason the type can * not be instantiated an exception is thrown from this. * * @return an instance of the type this object represents */ public Object getInstance() throws Exception { if(value == null) { value = getObject(type); } return value; }
InstanceFactory instanceFactory = new InstanceFactory(); ExecutorService executor = Executors.newSingleThreadExecutor(); try (Instance instance = instanceFactory.create()) { instance.init(); instance.doStuff(); while ((input = reader.readNext()) != null) { executor.execute(new Runnable() { @Override public void run() { instance.put(input); } }); } executor.shutdown(); executor.awaitTermination(1, TimeUnit.MINUTES); }
/** * Constructor for the <code>Support</code> object. This will * create a support object with the matcher and filter provided. * This allows the user to override the transformations that * are used to convert types to strings and back again. * * @param filter this is the filter to use with this support * @param matcher this is the matcher used for transformations * @param format this contains all the formatting for the XML */ public Support(Filter filter, Matcher matcher, Format format) { this.defaults = new DetailExtractor(this, FIELD); this.transform = new Transformer(matcher); this.scanners = new ScannerFactory(this); this.details = new DetailExtractor(this); this.labels = new LabelExtractor(format); this.instances = new InstanceFactory(); this.matcher = matcher; this.filter = filter; this.format = format; }
InstanceFactory instanceFactory = new InstanceFactory(); ExecutorService executor = Executors.newCachedThreadPool(); try (Instance instance = instanceFactory.create()) { instance.init(); instance.doStuff(); while ((input = reader.readNext()) != null) { executor.execute(new Runnable() { @Override public void run() { instance.put(input); } }); } } finally { executor.shutdown(); }
/** * Constructor for the <code>Support</code> object. This will * create a support object with the matcher and filter provided. * This allows the user to override the transformations that * are used to convert types to strings and back again. * * @param filter this is the filter to use with this support * @param matcher this is the matcher used for transformations * @param format this contains all the formatting for the XML */ public Support(Filter filter, Matcher matcher, Format format) { this.defaults = new DetailExtractor(this, FIELD); this.transform = new Transformer(matcher); this.scanners = new ScannerFactory(this); this.details = new DetailExtractor(this); this.labels = new LabelExtractor(format); this.instances = new InstanceFactory(); this.matcher = matcher; this.filter = filter; this.format = format; }
/** * Constructor for the <code>Support</code> object. This will * create a support object with the matcher and filter provided. * This allows the user to override the transformations that * are used to convert types to strings and back again. * * @param filter this is the filter to use with this support * @param matcher this is the matcher used for transformations * @param format this contains all the formatting for the XML */ public Support(Filter filter, Matcher matcher, Format format) { this.defaults = new DetailExtractor(this, FIELD); this.transform = new Transformer(matcher); this.scanners = new ScannerFactory(this); this.details = new DetailExtractor(this); this.labels = new LabelExtractor(format); this.instances = new InstanceFactory(); this.matcher = matcher; this.filter = filter; this.format = format; }
/** * This will create an <code>Instance</code> that can be used * to instantiate objects of the specified class. This leverages * an internal constructor cache to ensure creation is quicker. * * @param value this contains information on the object instance * * @return this will return an object for instantiating objects */ public Instance getInstance(Value value) { return instances.getInstance(value); }
/** * This method is used to acquire an instance of the type that * is defined by this object. If for some reason the type can * not be instantiated an exception is thrown from this. * * @return an instance of the type this object represents */ public Object getInstance() throws Exception { if(value == null) { value = getObject(type); } return value; }
/** * This will create an <code>Instance</code> that can be used * to instantiate objects of the specified class. This leverages * an internal constructor cache to ensure creation is quicker. * * @param type this is the type that is to be instantiated * * @return this will return an object for instantiating objects */ public Instance getInstance(Class type) { return instances.getInstance(type); }
/** * This method is used to acquire an instance of the type that * is defined by this object. If for some reason the type can * not be instantiated an exception is thrown from this. * * @return an instance of the type this object represents */ public Object getInstance() throws Exception { if(value == null) { value = getObject(type); } return value; }
/** * This will create an <code>Instance</code> that can be used * to instantiate objects of the specified class. This leverages * an internal constructor cache to ensure creation is quicker. * * @param value this contains information on the object instance * * @return this will return an object for instantiating objects */ public Instance getInstance(Value value) { return instances.getInstance(value); }
/** * This method is used to acquire an instance of the type that * is defined by this object. If for some reason the type can * not be instantiated an exception is thrown from this. * * @return an instance of the type this object represents */ public Object getInstance() throws Exception { if(value.isReference()) { return value.getValue(); } Object object = getObject(type); if(value != null) { value.setValue(object); } return object; }
/** * This will create an <code>Instance</code> that can be used * to instantiate objects of the specified class. This leverages * an internal constructor cache to ensure creation is quicker. * * @param value this contains information on the object instance * * @return this will return an object for instantiating objects */ public Instance getInstance(Value value) { return instances.getInstance(value); }
/** * This method is used to acquire an instance of the type that * is defined by this object. If for some reason the type can * not be instantiated an exception is thrown from this. * * @return an instance of the type this object represents */ public Object getInstance() throws Exception { if(value.isReference()) { return value.getValue(); } Object object = getObject(type); if(value != null) { value.setValue(object); } return object; }
/** * This will create an <code>Instance</code> that can be used * to instantiate objects of the specified class. This leverages * an internal constructor cache to ensure creation is quicker. * * @param type this is the type that is to be instantiated * * @return this will return an object for instantiating objects */ public Instance getInstance(Class type) { return instances.getInstance(type); }
/** * This method is used to acquire an instance of the type that * is defined by this object. If for some reason the type can * not be instantiated an exception is thrown from this. * * @return an instance of the type this object represents */ public Object getInstance() throws Exception { if(value.isReference()) { return value.getValue(); } Object object = getObject(type); if(value != null) { value.setValue(object); } return object; }