本文整理汇总了Java中com.intellij.util.ReflectionUtil.newInstance方法的典型用法代码示例。如果您正苦于以下问题:Java ReflectionUtil.newInstance方法的具体用法?Java ReflectionUtil.newInstance怎么用?Java ReflectionUtil.newInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.ReflectionUtil
的用法示例。
在下文中一共展示了ReflectionUtil.newInstance方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deserializeState
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked"})
@Nullable
public static <T> T deserializeState(@Nullable Element stateElement, Class <T> stateClass, @Nullable T mergeInto) {
if (stateElement == null) {
return mergeInto;
}
else if (stateClass == Element.class) {
return (T)stateElement;
}
else if (JDOMExternalizable.class.isAssignableFrom(stateClass)) {
if (mergeInto != null) {
String elementText = JDOMUtil.writeElement(stateElement, "\n");
LOG.error("State is " + stateClass.getName() + ", merge into is " + mergeInto.toString() + ", state element text is " + elementText);
}
T t = ReflectionUtil.newInstance(stateClass);
try {
((JDOMExternalizable)t).readExternal(stateElement);
return t;
}
catch (InvalidDataException e) {
throw new RuntimeException(e);
}
}
else if (mergeInto == null) {
return XmlSerializer.deserialize(stateElement, stateClass);
}
else {
XmlSerializer.deserializeInto(mergeInto, stateElement);
return mergeInto;
}
}
示例2: instantiateTool
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
static Object instantiateTool(@NotNull Class<?> toolClass) {
try {
return ReflectionUtil.newInstance(toolClass);
}
catch (RuntimeException e) {
LOG.error(e.getCause());
}
return null;
}
示例3: compute
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
@Override
@NotNull
protected final Weigher compute() {
try {
Class<Weigher> tClass = findClass(implementationClass);
final Weigher weigher = ReflectionUtil.newInstance(tClass);
weigher.setDebugName(id);
return weigher;
}
catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
示例4: getDefaultBean
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
@NotNull
Object getDefaultBean(@NotNull Object bean) {
Class<?> c = bean.getClass();
Object o = myDefaultBeans.get(c);
if (o == null) {
o = ReflectionUtil.newInstance(c);
configure(o);
myDefaultBeans.put(c, o);
}
return o;
}
示例5: BasePrimitiveBinding
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
protected BasePrimitiveBinding(@NotNull MutableAccessor accessor, @Nullable String suggestedName, @Nullable Class<? extends Converter> converterClass) {
super(accessor);
myName = StringUtil.isEmpty(suggestedName) ? myAccessor.getName() : suggestedName;
if (converterClass == null || converterClass == Converter.class) {
myConverter = null;
if (!(this instanceof AttributeBinding)) {
myBinding = XmlSerializerImpl.getBinding(myAccessor);
}
}
else {
//noinspection unchecked
myConverter = ReflectionUtil.newInstance(converterClass);
}
}
示例6: createCopy
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
public static <T> T createCopy(@NotNull T from) {
try {
@SuppressWarnings("unchecked")
T to = (T)ReflectionUtil.newInstance(from.getClass());
copyBean(from, to);
return to;
}
catch (Exception ignored) {
return null;
}
}
示例7: createObject
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
@NotNull
public Object createObject(@NotNull Class<?> aClass, FList<Type> processedTypes) throws Exception {
Object o = ReflectionUtil.newInstance(aClass);
for (MutableAccessor accessor : XmlSerializerUtil.getAccessors(aClass)) {
AbstractCollection abstractCollection = accessor.getAnnotation(AbstractCollection.class);
List<Type> elementTypes = abstractCollection != null ? Arrays.<Type>asList(abstractCollection.elementTypes()) : Collections.<Type>emptyList();
Object value = createValue(accessor.getGenericType(), processedTypes, elementTypes);
if (value != null) {
accessor.set(o, value);
}
}
return o;
}
示例8: createUi
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
@Override
protected UI createUi() {
return ReflectionUtil.newInstance(uiClass);
}
示例9: createElement
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
@Override
public T createElement() {
return ReflectionUtil.newInstance(itemEditor.getItemClass());
}
示例10: deserialize
import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
@Override
public Object deserialize(Object context, @NotNull Element element) {
Object instance = ReflectionUtil.newInstance(myBeanClass);
deserializeInto(instance, element, null);
return instance;
}