Top Description Constructors Methods
org.postgresql.util

public Class ObjectFactory

extends Object
Class Inheritance
Known Direct Subclasses
org.postgresql.ssl.MakeSSL
Imports
org.checkerframework.checker.nullness.qual.Nullable, java.lang.reflect.Constructor, .InvocationTargetException, java.util.Properties

Helper class to instantiate objects.

Note

the class is NOT public API, so it is subject to change.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static <
type of expected class
T
>
T

Returns:

the instantiated class
instantiate
(Class<T>
expected class of type T, if the classname instantiated doesn't match the expected type of this class this method will fail
expectedClass
,
String
name of the class to instantiate
classname
,
Properties
parameter to pass as Properties
info
,
boolean
whether to look for a single String argument constructor
tryString
,
@Nullable String
parameter to pass as String
stringarg
)

Instantiates a class using the appropriate constructor.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ObjectFactoryback to summary
public ObjectFactory()

Method Detail

instantiateback to summary
public static <T> T instantiate(Class<T> expectedClass, String classname, Properties info, boolean tryString, @Nullable String stringarg) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException

Instantiates a class using the appropriate constructor. If a constructor with a single Propertiesparameter exists, it is used. Otherwise, if tryString is true a constructor with a single String argument is searched if it fails, or tryString is true a no argument constructor is tried.

Parameters
<T>
type of expected class
expectedClass:Class<T>

expected class of type T, if the classname instantiated doesn't match the expected type of this class this method will fail

classname:String

name of the class to instantiate

info:Properties

parameter to pass as Properties

tryString:boolean

whether to look for a single String argument constructor

stringarg:@Nullable String

parameter to pass as String

Returns:T

the instantiated class

Exceptions
ClassNotFoundException:
if something goes wrong
SecurityException:
if something goes wrong
NoSuchMethodException:
if something goes wrong
IllegalArgumentException:
if something goes wrong
InstantiationException:
if something goes wrong
IllegalAccessException:
if something goes wrong
InvocationTargetException:
if something goes wrong