org.powermock.reflect.internal.WhiteboxImpl.findField()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(1.5k)|赞(0)|评价(0)|浏览(116)

本文整理了Java中org.powermock.reflect.internal.WhiteboxImpl.findField()方法的一些代码示例,展示了WhiteboxImpl.findField()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WhiteboxImpl.findField()方法的具体详情如下:
包路径:org.powermock.reflect.internal.WhiteboxImpl
类名称:WhiteboxImpl
方法名:findField

WhiteboxImpl.findField介绍

[英]Find field.
[中]找到菲尔德。

代码示例

代码示例来源:origin: org.powermock/powermock-reflect

/**
 * Set the value of a field using reflection at at specific place in the
 * class hierarchy (<tt>where</tt>). This first field assignable to
 * <tt>object</tt> will then be set to <tt>value</tt>.
 *
 * @param object the object to modify
 * @param value  the new value of the field
 * @param where  the class in the hierarchy where the field is defined
 */
public static void setInternalState(Object object, Object value, Class<?> where) {
  setField(object, value, findField(object, new AssignableFromFieldTypeMatcherStrategy(getType(value)), where));
}

代码示例来源:origin: org.powermock.reflect/powermock-reflect

/**
 * Set the value of a field using reflection at at specific place in the
 * class hierarchy (<tt>where</tt>). This first field assignable to
 * <tt>object</tt> will then be set to <tt>value</tt>.
 * 
 * @param object
 *            the object to modify
 * @param value
 *            the new value of the field
 * @param where
 *            the class in the hierarchy where the field is defined
 */
public static void setInternalState(Object object, Object value, Class<?> where) {
  setField(object, value, findField(object, new AssignableFromFieldTypeMatcherStrategy(getType(value)), where));
}

相关文章

WhiteboxImpl类方法