当前位置: 首页>>代码示例>>Java>>正文


Java ReflectionUtil.newInstance方法代码示例

本文整理汇总了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;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:DefaultStateSerializer.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:InspectionToolsRegistrarCore.java

示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:WeigherExtensionPoint.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:SkipDefaultValuesSerializationFilters.java

示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:BasePrimitiveBinding.java

示例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;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:XmlSerializerUtil.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:ShowSerializedXmlAction.java

示例8: createUi

import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
@Override
protected UI createUi() {
  return ReflectionUtil.newInstance(uiClass);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:SimpleConfigurable.java

示例9: createElement

import com.intellij.util.ReflectionUtil; //导入方法依赖的package包/类
@Override
public T createElement() {
  return ReflectionUtil.newInstance(itemEditor.getItemClass());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:CollectionModelEditor.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:BeanBinding.java


注:本文中的com.intellij.util.ReflectionUtil.newInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。