QuickConstructorGenerator
@Deprecated
public class QuickConstructorGenerator
extends java.lang.Object
Constructor
which is easier to use and performs
better. In one tested situation, overall performance was improved by about
10%.
QuickConstructorGenerator is not general purpose however, as the parameters to the constructor must be known, and the constructor must be public. It is intended to be used for constructing instances of auto-generated classes. The exact parameters may be known at compile time, but the actual object type is not.
Constructor and Description |
---|
QuickConstructorGenerator()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
static <F> F |
getInstance(java.lang.Class<?> objectType,
java.lang.Class<F> factory)
Deprecated.
Returns a factory instance for one type of object.
|
public static <F> F getInstance(java.lang.Class<?> objectType, java.lang.Class<F> factory)
Here is a contrived example for constructing strings. In practice, such a string factory is is useless, since the "new" operator can be invoked directly.
public interface StringFactory { String newEmptyString(); String newStringFromChars(char[] chars); String newStringFromBytes(byte[] bytes, String charsetName) throws UnsupportedEncodingException; }Here's an example of it being used:
StringFactory sf = QuickConstructorGenerator.getInstance(String.class, StringFactory.class); ... String str = sf.newStringFromChars(new char[] {'h', 'e', 'l', 'l', 'o'});
objectType
- type of object to constructfactory
- interface defining which objects can be constructedjava.lang.IllegalArgumentException
- if factory type is not an interface or
if it is malformedCopyright © 2006-2013 Amazon Technologies, Inc.. All Rights Reserved.