public class ReflectionHelper extends Object
Constructor and Description |
---|
ReflectionHelper() |
Modifier and Type | Method and Description |
---|---|
<T> T |
newInstance(Class<T> clazz)
Create a new instance of a class.
|
<T> T |
newInstance(String className)
Create a new instance of a class given the class name.
|
public <T> T newInstance(Class<T> clazz) throws IllegalAccessException, InstantiationException
Provided to allow mocking, making it possible to test the exception handling.
T
- type of object to createclazz
- class to create new instance ofIllegalAccessException
- see Class.newInstance()
InstantiationException
- see Class.newInstance()
public <T> T newInstance(String className) throws IllegalAccessException, InstantiationException, ClassNotFoundException
Provided to allow mocking, making it possible to test the exception handling.
T
- type of object to createclassName
- name of class to create new instance ofIllegalAccessException
- see Class.newInstance()
InstantiationException
- see Class.newInstance()
ClassNotFoundException
- see ClassLoader.loadClass(String)
Copyright © 2022. All rights reserved.