public abstract class StaticStubSupport extends Object
Modifier and Type | Method and Description |
---|---|
static Memento |
install(Class<?> containingClass,
String fieldName,
Object newValue)
This method assigns the specified value to the named field in the specified class.
|
static Class<?> |
nestedClass(Class<?> aClass,
String... nestedClassNames)
Returns the nested class specified by an outer class and a sequences of class names.
|
static Memento |
preserve(Class<?> containingClass,
String fieldName)
This method returns a
Memento object
which can be used to revert the specified field to its current value. |
public static Memento install(Class<?> containingClass, String fieldName, Object newValue) throws NoSuchFieldException
Memento
object which can be used to revert that field to
its original value.containingClass
- the class on which the static field is defined.fieldName
- the name of the static field.newValue
- the value to place into the static field.NoSuchFieldException
- if the named field does not exist.public static Memento preserve(Class<?> containingClass, String fieldName) throws NoSuchFieldException
Memento
object
which can be used to revert the specified field to its current value.containingClass
- the class on which the static field is defined.fieldName
- the name of the static field.NoSuchFieldException
- if the named field does not exist.public static Class<?> nestedClass(Class<?> aClass, String... nestedClassNames) throws ClassNotFoundException
aClass
- the outer class containing the desired nested classnestedClassNames
- one or more nested class namesClassNotFoundException
- if no such nested class exists.Copyright © 2024. All rights reserved.