예제 #1
0
  public void serializeInto(
      @NotNull Object o, @NotNull Element element, @NotNull SerializationFilter filter) {
    for (Binding binding : myPropertyBindings.keySet()) {
      Accessor accessor = myPropertyBindings.get(binding);
      if (!filter.accepts(accessor, o)) {
        continue;
      }

      // todo: optimize. Cache it.
      Property property = accessor.getAnnotation(Property.class);
      if (property != null && property.filter() != SerializationFilter.class) {
        try {
          if (!ReflectionUtil.newInstance(property.filter()).accepts(accessor, o)) {
            continue;
          }
        } catch (RuntimeException e) {
          throw new XmlSerializationException(e);
        }
      }

      Object node = binding.serialize(o, element, filter);
      if (node != null) {
        if (node instanceof org.jdom.Attribute) {
          element.setAttribute((org.jdom.Attribute) node);
        } else {
          JDOMUtil.addContent(element, node);
        }
      }
    }
  }
 @NotNull
 private static ConfigImportSettings getConfigImportSettings() {
   try {
     @SuppressWarnings("unchecked")
     Class<ConfigImportSettings> customProviderClass =
         (Class<ConfigImportSettings>)
             Class.forName(
                 "com.intellij.openapi.application."
                     + PlatformUtils.getPlatformPrefix()
                     + "ConfigImportSettings");
     if (ConfigImportSettings.class.isAssignableFrom(customProviderClass)) {
       return ReflectionUtil.newInstance(customProviderClass);
     }
   } catch (ClassNotFoundException ignored) {
   } catch (RuntimeException ignored) {
   }
   return new ConfigImportSettings();
 }
 @Override
 public T createElement() {
   return ReflectionUtil.newInstance(itemEditor.getItemClass());
 }