public static Library findLibraryByName(Project project, String name) {
   final LibraryTablesRegistrar tablesRegistrar = LibraryTablesRegistrar.getInstance();
   Library lib = tablesRegistrar.getLibraryTable().getLibraryByName(name);
   if (lib == null) {
     lib = tablesRegistrar.getLibraryTable(project).getLibraryByName(name);
   }
   if (lib == null) {
     for (LibraryTable table : tablesRegistrar.getCustomLibraryTables()) {
       lib = table.getLibraryByName(name);
       if (lib != null) {
         break;
       }
     }
   }
   return lib;
 }
 public Library createOrGetXtendJavaLibrary(
     final ModifiableRootModel rootModel, final Module module) {
   LibraryTablesRegistrar _instance = LibraryTablesRegistrar.getInstance();
   Project _project = module.getProject();
   LibraryTable _libraryTable = _instance.getLibraryTable(_project);
   Library[] _libraries = _libraryTable.getLibraries();
   LibraryTablesRegistrar _instance_1 = LibraryTablesRegistrar.getInstance();
   LibraryTable _libraryTable_1 = _instance_1.getLibraryTable();
   Library[] _libraries_1 = _libraryTable_1.getLibraries();
   final Iterable<Library> libraryTable =
       Iterables.<Library>concat(
           ((Iterable<? extends Library>) Conversions.doWrapArray(_libraries)),
           ((Iterable<? extends Library>) Conversions.doWrapArray(_libraries_1)));
   final Function1<Library, Boolean> _function =
       new Function1<Library, Boolean>() {
         @Override
         public Boolean apply(final Library it) {
           String _name = it.getName();
           boolean _startsWith = false;
           if (_name != null) {
             _startsWith = _name.startsWith(XtendLibraryDescription.XTEND_LIBRARY_NAME);
           }
           return Boolean.valueOf(_startsWith);
         }
       };
   final Iterable<Library> xtendLibs = IterableExtensions.<Library>filter(libraryTable, _function);
   boolean _isEmpty = IterableExtensions.isEmpty(xtendLibs);
   boolean _not = (!_isEmpty);
   if (_not) {
     final Function1<Library, Boolean> _function_1 =
         new Function1<Library, Boolean>() {
           @Override
           public Boolean apply(final Library it) {
             String _name = it.getName();
             return Boolean.valueOf(
                 Objects.equal(_name, XtendLibraryDescription.XTEND_LIBRARY_NAME));
           }
         };
     boolean _exists = IterableExtensions.<Library>exists(xtendLibs, _function_1);
     if (_exists) {
       final Function1<Library, Boolean> _function_2 =
           new Function1<Library, Boolean>() {
             @Override
             public Boolean apply(final Library it) {
               String _name = it.getName();
               return Boolean.valueOf(
                   Objects.equal(_name, XtendLibraryDescription.XTEND_LIBRARY_NAME));
             }
           };
       return IterableExtensions.<Library>findFirst(xtendLibs, _function_2);
     } else {
       return IterableExtensions.<Library>head(xtendLibs);
     }
   } else {
     final NewLibraryConfiguration libDescr = this.xtendLibDescr.createLibraryDescription();
     LibraryTable _moduleLibraryTable = rootModel.getModuleLibraryTable();
     final LibraryTable.ModifiableModel model = _moduleLibraryTable.getModifiableModel();
     String _defaultLibraryName = libDescr.getDefaultLibraryName();
     final Library createdLib = model.createLibrary(_defaultLibraryName);
     final Library.ModifiableModel libModel = createdLib.getModifiableModel();
     HashMap<OrderRootType, List<String>> _libraryRoots = this.xtendLibDescr.libraryRoots();
     final Procedure2<OrderRootType, List<String>> _function_3 =
         new Procedure2<OrderRootType, List<String>>() {
           @Override
           public void apply(final OrderRootType type, final List<String> roots) {
             final Procedure1<String> _function =
                 new Procedure1<String>() {
                   @Override
                   public void apply(final String it) {
                     libModel.addRoot(it, type);
                   }
                 };
             IterableExtensions.<String>forEach(roots, _function);
           }
         };
     MapExtensions.<OrderRootType, List<String>>forEach(_libraryRoots, _function_3);
     libModel.commit();
     model.commit();
     return createdLib;
   }
 }