T - public class UnsafeFieldGetter<T> extends Object implements FieldGetter<T>
Unsafe.UnsafeFieldGetter with a class with 3 boolean
fields will lead a IllegalArgumentException.| 构造器和说明 |
|---|
UnsafeFieldGetter(Class<T> clz) |
| 限定符和类型 | 方法和说明 |
|---|---|
Field |
get(java.util.function.Function<T,?> invoke) |
Field |
get(Object o)
Get Field by a property value
|
T |
getMockObject()
Get the mocked object.
|
String |
getName(Object o)
Get Field name by a property value
|
Class<?> |
getType(Object o)
Get Field type by a property value
|
String |
nameOf(Object o)
More readable version of
getName(Object) |
boolean |
supportFieldInvoke()
Whether the direct field invoke is supported.
|
Class<?> |
typeOf(Object o)
More readable version of
getType(Object) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetName, getTypenameOf, typeOfpublic UnsafeFieldGetter(Class<T> clz) throws IllegalStateException, IllegalArgumentException
clz - IllegalStateException - If construct the mock object failed.IllegalArgumentException - If the class is not suitable. See the class doc.public T getMockObject()
UnsafeFieldGetter getter = new UnsafeFieldGetter(SomeClass.class);
getter.getName(o -> o.prop);
// is same as
SomeClass sc = getter.getMockObject();
getter.getName(sc.prop);
public boolean supportFieldInvoke()
PropertyGetter
PropertyGetter pg = ...;
pg.getName(b -> b.beanProp);
supportFieldInvoke 在接口中 PropertyGetter<T>public Field get(java.util.function.Function<T,?> invoke)
get 在接口中 InvokeGetter<T,Field>public Field get(Object o)
o - a property value of the mock objectgetMockObject()public String getName(Object o)
o - a property value of the mock objectgetMockObject()public Class<?> getType(Object o)
o - a property value of the mock objectgetMockObject()public String nameOf(Object o)
getName(Object)o - a property value of the mock objectgetMockObject()public Class<?> typeOf(Object o)
getType(Object)o - a property value of the mock objectgetMockObject()Copyright © 2017. All rights reserved.