Java Code Examples for com.intellij.util.ReflectionUtil#newInstance()
The following examples show how to use
com.intellij.util.ReflectionUtil#newInstance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultStateSerializer.java From consulo with Apache License 2.0 | 6 votes |
@SuppressWarnings({"unchecked"}) @Nullable public static <T> T deserializeState(@Nullable Element stateElement, Class <T> stateClass) throws StateStorageException { if (stateElement == null) return null; if (stateClass.equals(Element.class)) { //assert mergeInto == null; return (T)stateElement; } else if (JDOMExternalizable.class.isAssignableFrom(stateClass)) { final T t = ReflectionUtil.newInstance(stateClass); try { ((JDOMExternalizable)t).readExternal(stateElement); return t; } catch (InvalidDataException e) { throw new StateStorageException(e); } } else { return XmlSerializer.deserialize(stateElement, stateClass); } }
Example 2
Source File: StateStorageManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private StateStorage createStateStorage(@Nonnull Storage storageSpec) { if (!storageSpec.stateSplitter().equals(StateSplitterEx.class)) { StateSplitterEx splitter = ReflectionUtil.newInstance(storageSpec.stateSplitter()); return myStateStorageFacade.createDirectoryBasedStorage(myPathMacroSubstitutor, expandMacros(buildFileSpec(storageSpec)), splitter, this, createStorageTopicListener()); } else { return createFileStateStorage(buildFileSpec(storageSpec), storageSpec.roamingType()); } }
Example 3
Source File: SkipDefaultValuesSerializationFilters.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull Object getDefaultBean(@Nonnull 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; }
Example 4
Source File: BasePrimitiveBinding.java From consulo with Apache License 2.0 | 5 votes |
protected BasePrimitiveBinding(@Nonnull 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); } }
Example 5
Source File: XmlSerializerUtil.java From consulo with Apache License 2.0 | 5 votes |
public static <T> T createCopy(@Nonnull T from) { try { @SuppressWarnings("unchecked") T to = (T)ReflectionUtil.newInstance(from.getClass()); copyBean(from, to); return to; } catch (Exception ignored) { return null; } }
Example 6
Source File: LafManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private LookAndFeel newInstance(LookAndFeelInfoWithClassLoader lookAndFeel) throws Exception { ClassLoader classLoader = lookAndFeel.getClassLoader(); Class<?> clazz = Class.forName(lookAndFeel.getClassName(), true, classLoader); return (LookAndFeel)ReflectionUtil.newInstance(clazz); }
Example 7
Source File: SimpleConfigurable.java From consulo with Apache License 2.0 | 4 votes |
@Override protected UI createUi() { return ReflectionUtil.newInstance(uiClass); }
Example 8
Source File: CollectionModelEditor.java From consulo with Apache License 2.0 | 4 votes |
@Override public T createElement() { return ReflectionUtil.newInstance(itemEditor.getItemClass()); }
Example 9
Source File: BeanBinding.java From consulo with Apache License 2.0 | 4 votes |
@Override public Object deserialize(Object context, @Nonnull Element element) { Object instance = ReflectionUtil.newInstance(myBeanClass); deserializeInto(instance, element, null); return instance; }
Example 10
Source File: WebContainerStartup.java From consulo with Apache License 2.0 | 4 votes |
private void registerServlets(ServletHandler handler) { Class[] classes = new Class[]{RootUIServlet.class, UIIconServlet.class}; for (Class aClass : classes) { Servlet servlet = (Servlet)ReflectionUtil.newInstance(aClass); ServletHolder servletHolder = new ServletHolder(servlet); WebServlet declaredAnnotation = (WebServlet)aClass.getDeclaredAnnotation(WebServlet.class); String[] urls = declaredAnnotation.urlPatterns(); for (String url : urls) { handler.addServletWithMapping(servletHolder, url); } System.out.println(aClass.getName() + " registered to: " + Arrays.asList(urls)); } }