Пример #1
0
  private SSLHostConfigCertificate selectCertificate(
      SSLHostConfig sslHostConfig, List<Cipher> clientCiphers) {

    Set<SSLHostConfigCertificate> certificates = sslHostConfig.getCertificates(true);
    if (certificates.size() == 1) {
      return certificates.iterator().next();
    }

    LinkedHashSet<Cipher> serverCiphers = sslHostConfig.getCipherList();

    List<Cipher> candidateCiphers = new ArrayList<>();
    if (sslHostConfig.getHonorCipherOrder()) {
      candidateCiphers.addAll(serverCiphers);
      candidateCiphers.retainAll(clientCiphers);
    } else {
      candidateCiphers.addAll(clientCiphers);
      candidateCiphers.retainAll(serverCiphers);
    }

    Iterator<Cipher> candidateIter = candidateCiphers.iterator();
    while (candidateIter.hasNext()) {
      Cipher candidate = candidateIter.next();
      for (SSLHostConfigCertificate certificate : certificates) {
        if (certificate.getType().isCompatibleWith(candidate.getAu())) {
          return certificate;
        }
      }
    }

    // No matches. Just return the first certificate. The handshake will
    // then fail due to no matching ciphers.
    return certificates.iterator().next();
  }
Пример #2
0
 @SuppressWarnings("unchecked")
 public boolean retainAll(final Collection<?> objs) {
   if (objs instanceof JaxbListWrapper) {
     return m_objects.retainAll(((JaxbListWrapper<? extends T>) objs).getObjects());
   } else {
     return m_objects.retainAll(objs);
   }
 }
 @Override
 public synchronized boolean retainAll(Collection c) {
   if (c instanceof PySequenceList) {
     return list.retainAll(c);
   } else {
     return list.retainAll(new PyList(c));
   }
 }
Пример #4
0
  /**
   * Actually rearrange the exertions in the job according to the sorting
   *
   * @param topXrt
   * @param sortedExertions
   * @throws CycleDetectedException
   * @throws ContextException
   */
  private void reorderJob(Exertion topXrt, List<Mogram> sortedExertions) {
    List<Mogram> sortedSubset = new ArrayList(sortedExertions);
    sortedSubset.retainAll(topXrt.getMograms());

    if (topXrt.getFlowType() != null && topXrt.getFlowType().equals(Strategy.Flow.AUTO)) {
      ((ServiceExertion) topXrt).setFlowType(setFlow(topXrt, sortedSubset));
      logger.info("FLOW for exertion: " + topXrt.getName() + " set to: " + topXrt.getFlowType());
    }
    List<String> exertionsBefore = new ArrayList<String>();
    for (Mogram xrt : topXrt.getMograms()) exertionsBefore.add(xrt.getName());

    List<String> exertionsAfter = new ArrayList<String>();
    for (Mogram xrt : sortedExertions) exertionsAfter.add(xrt.getName());
    if (!topXrt.getMograms().equals(sortedSubset)) {
      logger.info("Order of exertions for " + topXrt.getName() + " will be changed: ");
      logger.info("From: " + exertionsBefore);
      logger.info("To: " + exertionsAfter);
      topXrt.getMograms().removeAll(sortedSubset);
      topXrt.getMograms().addAll(sortedSubset);
    }

    for (Iterator i = topXrt.getMograms().iterator(); i.hasNext(); ) {
      Exertion xrt = (Exertion) i.next();
      if (xrt instanceof Job) {
        reorderJob(xrt, sortedExertions);
      }
    }
  }
Пример #5
0
  @Override
  public String[] getEnableableProtocols(SSLContext context) {
    String[] requestedProtocols = endpoint.getSslEnabledProtocolsArray();
    if ((requestedProtocols == null) || (requestedProtocols.length == 0)) {
      return defaultServerProtocols;
    }

    List<String> protocols = new ArrayList<String>(Arrays.asList(requestedProtocols));
    protocols.retainAll(Arrays.asList(context.getSupportedSSLParameters().getProtocols()));

    if (protocols.isEmpty()) {
      log.warn(
          sm.getString(
              "jsse.requested_protocols_not_supported", Arrays.asList(requestedProtocols)));
    }
    if (log.isDebugEnabled()) {
      log.debug(sm.getString("jsse.enableable_protocols", protocols));
      if (protocols.size() != requestedProtocols.length) {
        List<String> skipped = new ArrayList<String>(Arrays.asList(requestedProtocols));
        skipped.removeAll(protocols);
        log.debug(sm.getString("jsse.unsupported_protocols", skipped));
      }
    }
    return protocols.toArray(new String[protocols.size()]);
  }
  @Override
  public List<ScimGroupMember> updateOrAddMembers(String groupId, List<ScimGroupMember> members)
      throws ScimResourceNotFoundException {
    List<ScimGroupMember> currentMembers = getMembers(groupId);
    logger.debug("current-members: " + currentMembers + ", in request: " + members);

    List<ScimGroupMember> currentMembersToRemove = new ArrayList<>(currentMembers);
    currentMembersToRemove.removeAll(members);
    logger.debug("removing members: " + currentMembersToRemove);
    for (ScimGroupMember member : currentMembersToRemove) {
      removeMemberById(groupId, member.getMemberId());
    }

    List<ScimGroupMember> newMembersToAdd = new ArrayList<>(members);
    newMembersToAdd.removeAll(currentMembers);
    logger.debug("adding new members: " + newMembersToAdd);
    for (ScimGroupMember member : newMembersToAdd) {
      addMember(groupId, member);
    }

    List<ScimGroupMember> membersToUpdate = new ArrayList<>(members);
    membersToUpdate.retainAll(currentMembers);
    logger.debug("updating members: " + membersToUpdate);
    for (ScimGroupMember member : membersToUpdate) {
      updateMember(groupId, member);
    }

    return getMembers(groupId);
  }
  /**
   * Get the list of authorized apps for the user based on the user's LEA.
   *
   * <p>No additional filtering is done on the results. E.g. if a user is a non-admin, the admin
   * apps will still show up in the list, or if an app is disabled it will still show up.
   *
   * @param principal
   * @return list of app IDs, or null if it couldn't be determined
   */
  @SuppressWarnings("unchecked")
  public boolean isAuthorizedForApp(Entity app, SLIPrincipal principal) {

    if (principal.isAdminRealmAuthenticated()) {
      return isAdminVisible(app);
    } else {
      if (isAutoAuthorized(app)) {
        return true;
      } else if (!isOperatorApproved(app)) {
        return false;
      } else {
        Set<String> edOrgs = helper.locateDirectEdorgs(principal.getEntity());
        NeutralQuery appAuthCollQuery = new NeutralQuery();
        appAuthCollQuery.addCriteria(new NeutralCriteria("applicationId", "=", app.getEntityId()));
        appAuthCollQuery.addCriteria(
            new NeutralCriteria("edorgs.authorizedEdorg", NeutralCriteria.CRITERIA_IN, edOrgs));
        Entity authorizedApps = repo.findOne("applicationAuthorization", appAuthCollQuery);
        if (authorizedApps != null) {
          if (isAutoApproved(app)) {
            return true;
          } else {
            // query approved edorgs
            List<String> approvedDistricts =
                new ArrayList<String>((List<String>) app.getBody().get("authorized_ed_orgs"));
            List<String> myDistricts = helper.getDistricts(edOrgs);
            approvedDistricts.retainAll(myDistricts);
            return !approvedDistricts.isEmpty();
          }
        }
      }
    }
    return false;
  }
Пример #8
0
 public static void basicTest(List a) {
   a.add(1, "x"); // Add at location 1
   a.add("x"); // Add at end
   // Add a collection:
   a.addAll(fill(new ArrayList()));
   // Add a collection starting at  location 3:
   a.addAll(3, fill(new ArrayList()));
   b = a.contains("1");
   // Is it in there
   // Is the entire collection in there?
   b = a.containsAll(fill(new ArrayList()));
   // Lists allow random access, which is cheap for ArrayList, expensive for LinkedList:
   o = a.get(1); // Get object at location 1
   i = a.indexOf("1");
   // Tell index of object  indexOf, starting search at location 2: i = a.indexOf("1", 2);
   b = a.isEmpty(); // Any elements inside?
   it = a.iterator(); // Ordinary Iterator
   lit = a.listIterator(); // ListIterator
   lit = a.listIterator(3); // Start at loc 3
   i = a.lastIndexOf("1"); // Last match
   // i = a.lastIndexOf("1", 2); // ...after loc 2
   a.remove(1); // Remove location 1
   a.remove("3"); // Remove this object
   a.set(1, "y"); // Set location 1 to "y" // Keep everything that's in the
   // argument // (the intersection of the two sets):
   a.retainAll(fill(new ArrayList())); // Remove elements in this range:
   // a.removeRange(0, 2); // Remove everything that's in the argument:
   a.removeAll(fill(new ArrayList()));
   i = a.size(); // How big is it?
   a.clear(); // Remove all elements
 }
Пример #9
0
  public List<Integer> getResultWithAND(String query) throws Exception {
    String[] terms = query.split(" ");
    List<Integer> results = new LinkedList<Integer>();
    for (String term : terms) {
      String searchTerm = getStemmedQuery(term);
      int termid = getTermId(searchTerm);
      List<Integer> docs = new LinkedList<Integer>();
      if (termid > 0) {
        TreeMap<Integer, List<Integer>> docpos = null;
        if (!termdocposindex.containsKey(termid)) {
          getTermDocPosIndex(termid);
          docpos = termdocposindex.get(termid);
        } else {
          docpos = termdocposindex.get(termid);
        }
        Iterator docIter = docpos.keySet().iterator();
        Object doc = null;
        while (docIter.hasNext()) {
          doc = docIter.next();
          List<Integer> lpos1 = docpos.get(doc);
          // list of docs
          docs.add((Integer) doc);
        }
      }

      if (results.isEmpty()) results.addAll(docs);
      else results.retainAll(docs);
    }
    return results;
  }
    /**
     * Method that sets the current available images.
     *
     * @param images The current images
     */
    public void setAvailableImages(File[] images) {
      synchronized (mLoadSync) {
        List<File> filtered = new ArrayList<>(Arrays.asList(images));
        mUsedImages.retainAll(filtered);
        filtered.removeAll(mUsedImages);
        mNewImages.clear();
        mNewImages.addAll(filtered);

        if (mFirstLoad) {
          reuseLastShownMedia();
        }

        // Retain used images
        int count = mUsedImages.size() - 1;
        for (int i = count; i >= 0; i--) {
          File image = mUsedImages.get(i);
          if (!mNewImages.contains(image)) {
            mUsedImages.remove(image);
          } else {
            mNewImages.remove(image);
          }
        }

        mEmpty = images.length == 0;
      }
    }
Пример #11
0
  // from
  // http://stackoverflow.com/questions/3424156/upgrade-sqlite-database-from-one-version-to-another
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    db.beginTransaction();

    // run a table creation with if not exists (we are doing an upgrade, so the table might
    // not exists yet, it will fail alter and drop)
    db.execSQL(getManualBookmarksCreationString());
    // put in a list the existing columns
    List<String> columns = GetColumns(db, "tbl_manual_bookmarks");
    // backup table
    db.execSQL("ALTER TABLE tbl_manual_bookmarks RENAME TO 'temp_tbl_manual_bookmarks'");
    // create new table (with new scheme)
    db.execSQL(getManualBookmarksCreationString());
    // get the intersection with the new columns, this time columns taken from the upgraded table
    columns.retainAll(GetColumns(db, "tbl_manual_bookmarks"));
    // restore data
    String cols = joinStrings(columns, ",");
    db.execSQL(
        String.format(
            "INSERT INTO %s (%s) SELECT %s from 'temp_%s",
            "tbl_manual_bookmarks", cols, cols, "tbl_manual_bookmarks'"));
    // remove backup table
    db.execSQL("DROP table 'temp_tbl_manual_bookmarks'");

    db.setTransactionSuccessful();
    db.endTransaction();
  }
Пример #12
0
  /**
   * Example URL: http://localhost:8080/webstore/products/laptop/price;low=200;high=8000?
   * manufacturer=apple
   *
   * @param model
   * @param productCategory
   * @param filterParams
   * @return
   */
  @RequestMapping("/{category}/{price}")
  public String filterProductsCategoryPriceManufacturer(
      Model model,
      @PathVariable("category") String productCategory,
      @MatrixVariable(pathVar = "price") Map<String, List<String>> priceRange,
      @RequestParam("manufacturer") String manufacturer) {

    List<Product> finalResults = new ArrayList<Product>();

    finalResults = productService.getProductsByCategory(productCategory);
    finalResults.retainAll(productService.getProductsByPriceFilter(priceRange));
    finalResults.retainAll(productService.getProductsByManufacturer(manufacturer));

    model.addAttribute("products", finalResults);
    return "products";
  }
Пример #13
0
 public static void main(String[] args) {
   Random rand = new Random(47);
   // 生成新的String序列
   List<String> ls = new ArrayList<String>();
   print("0: " + ls);
   Collections.addAll(ls, "oh", "what", "a", "beautiful", "Manila", "Monday", "morning");
   print("1: " + ls);
   // 增加新元素
   String h = new String("hi");
   ls.add(h); // Automatically resizes
   print("2: " + ls);
   print("3: " + ls.contains(h));
   ls.remove(h); // Remove by object
   String n = ls.get(2);
   print("4: " + n + " " + ls.indexOf(n));
   String m = new String("cy");
   print("5: " + ls.indexOf(m));
   print("6: " + ls.remove(m));
   // Must be the exact object
   print("7: " + ls.remove(n));
   print("8: " + ls);
   ls.add(3, new String("wonderful"));
   print("9: " + ls);
   List<String> sub = ls.subList(1, 4);
   print("sublist: " + sub);
   print("10: " + ls.containsAll(sub));
   Collections.sort(sub); // In-place sort
   print("sorted subList: " + sub);
   // Order is not important in containsAll();
   print("11: " + ls.containsAll(sub));
   Collections.shuffle(sub, rand);
   print("12: " + ls.containsAll(sub));
   List<String> copy = new ArrayList<String>(ls);
   sub = Arrays.asList(ls.get(1), ls.get(4)); // 跟书上结果好像不一样
   print("sub: " + sub);
   copy.retainAll(sub);
   print("13: " + copy);
   copy = new ArrayList<String>(ls); // Get a fresh copy
   copy.remove(2);
   print("14: " + copy);
   copy.removeAll(sub); // Only remove exact objects
   print("15: " + copy);
   copy.set(1, new String("hello")); // Replace an elements
   print("16: " + copy);
   copy.addAll(2, sub); // Insert a list in the middle
   print("17: " + copy);
   print("18: " + ls.isEmpty());
   ls.clear();
   print("19: " + ls);
   print("20: " + ls.isEmpty());
   List<String> ts = new ArrayList<String>();
   Collections.addAll(ts, "one", "two", "three", "four");
   ls.addAll(ts);
   print("21: " + ls);
   Object[] o = ls.toArray();
   print("22: " + o[3]);
   String[] pa = ls.toArray(new String[0]);
   print("23: " + pa[3]);
 }
Пример #14
0
 public static List<String> Intersection(List<List<String>> param) {
   List<String> toReturn = new ArrayList<String>();
   toReturn.addAll(param.get(0)); // adds initial values to the result set
   for (List<String> set : param) {
     toReturn.retainAll(set);
   }
   return toReturn;
 }
 /**
  * Gets tasks selected in the actual GUI widget (rather than from the checked state provider,
  * because the checked state provider may actually contain task paths strings that don't even
  * exist in the task tree (anymore). Moreover, when we call this we are about to save the task
  * tree state, and it would be best to weed out non-existent tasks here. Only the tasks that are
  * actually selected in the GUI tree (these should be real tasks since they are populated from the
  * model) will be returned.
  */
 private List<String> getSelectedTasks() {
   List<String> result = tasksChecked.getChecked();
   Set<String> validTasks = getValidTasks();
   if (validTasks != null) {
     result.retainAll(validTasks);
   }
   return result;
 }
 private List<XEventClassifier> fetchClassifiers(XLogArray array) {
   List<XEventClassifier> classifiers = new ArrayList<>();
   classifiers.addAll(array.get(0).getClassifiers());
   for (int i = 1; i < array.size(); i++) {
     classifiers.retainAll(array.get(i).getClassifiers());
   }
   return classifiers;
 }
 /**
  * Checks that given function has any decorators from {@code abc} module.
  *
  * @param element Python function to check
  * @param context type evaluation context. If it doesn't allow switch to AST, decorators will be
  *     compared by the text of the last component of theirs qualified names.
  * @see PyKnownDecoratorUtil.KnownDecorator
  */
 public static boolean hasAbstractDecorator(
     @NotNull PyDecoratable element, @NotNull TypeEvalContext context) {
   final List<KnownDecorator> knownDecorators = getKnownDecorators(element, context);
   if (knownDecorators.isEmpty()) {
     return false;
   }
   knownDecorators.retainAll(ABSTRACT_DECORATORS);
   return !knownDecorators.isEmpty();
 }
Пример #18
0
  private List<TemplatesList> getTemplatesParameter(
      Class<?> testClass,
      Class<?> parameterType,
      Templates templatesAnnotation,
      Map<Field, List<? extends Object>> parameters) {
    if (parameterType != TemplatesList.class) {
      throw new IllegalStateException(
          "only " + Template.class.getName() + " fields can be annotated with @Inject @Templates");
    }

    List<TemplatesList> templates = null;

    // if templates was already set, load them
    if (templatesField != null) {
      templates = (List<TemplatesList>) parameters.get(templatesField);
    }

    // get user defined templates
    List<TemplatesList> userTemplates = MetamerProperties.getTemplates();

    // if "value" is defined, takes precedens
    if (templatesAnnotation.value().length > 0) {
      templates = MetamerProperties.parseTemplates(templatesAnnotation.value());
    }

    // include all "include" to current list
    if (templatesAnnotation.include().length > 0) {
      List<TemplatesList> includeTemplates =
          MetamerProperties.parseTemplates(templatesAnnotation.include());
      if (templates == null) {
        templates = includeTemplates;
      } else {
        includeTemplates.removeAll(templates);
        templates.addAll(includeTemplates);
      }
    }

    // exclude all "exclude" from current list
    if (templatesAnnotation.exclude().length > 0) {
      List<TemplatesList> excludeTemplates =
          MetamerProperties.parseTemplates(templatesAnnotation.exclude());
      if (templates != null) {
        templates.removeAll(excludeTemplates);
      }
    }

    // remove all templates which wasn't in user defined set
    if (userTemplates != null) {
      if (templates == null) {
        templates = userTemplates;
      } else {
        templates.retainAll(userTemplates);
      }
    }

    return templates;
  }
  private List<Option> getOnlyAllowedValues(Object value) {
    List<Option> result = new ArrayList<Option>();

    List<Option> possible = Arrays.asList(getOptions());

    if (value instanceof Option[]) {
      List<Option> valueAsList = new ArrayList<Option>(Arrays.asList((Option[]) value));
      valueAsList.retainAll(possible);
      result = valueAsList;
    } else if (value instanceof String[]) {
      List<String> valueAsList = new ArrayList<String>(Arrays.asList((String[]) value));
      List<String> possibleStrings = new ArrayList<String>();
      for (Iterator<Option> i = possible.iterator(); i.hasNext(); ) {
        possibleStrings.add(i.next().getValue());
      }
      valueAsList.retainAll(possibleStrings);
      for (Iterator<Option> i = possible.iterator(); i.hasNext(); ) {
        Option vtp = i.next();
        if (valueAsList.contains(vtp.getValue())) {
          result.add(vtp);
        }
      }
    } else if (value instanceof Option) {
      int counter = 0;
      for (Iterator<Option> i = possible.iterator(); i.hasNext(); counter++) {
        Option vtp = i.next();
        if (vtp.equals(value)) {
          result.add(vtp);
          break;
        }
      }
    } else if (value instanceof String) {
      int counter = 0;
      for (Iterator<Option> i = possible.iterator(); i.hasNext(); counter++) {
        Option vtp = i.next();
        if (vtp.getValue().equals(value)) {
          result.add(vtp);
          break;
        }
      }
    }

    return result;
  }
Пример #20
0
  private void resetListenersExceptResetResistant() {
    List<LoggerContextListener> toRetain = new ArrayList<LoggerContextListener>();

    for (LoggerContextListener lcl : loggerContextListenerList) {
      if (lcl.isResetResistant()) {
        toRetain.add(lcl);
      }
    }
    loggerContextListenerList.retainAll(toRetain);
  }
  /**
   * Return a new List with elements both in first and second passed collection.
   *
   * @param first First list
   * @param second Second list
   * @return a new set (depending on input type) with elements in first and second
   */
  private <T> List<T> intersection(List<T> first, List<T> second) {
    List<T> result = new ArrayList<T>();

    if ((first != null) && (second != null)) {
      result.addAll(first);
      result.retainAll(second);
    }

    return result;
  }
  @Override
  public boolean retainAll(@NonNull Collection<?> collection) {
    boolean result = meanings.retainAll(collection);

    if (meanings.isEmpty()) {
      throw new RuntimeException("Cannot remove the last meaning.");
    } else {
      return result;
    }
  }
Пример #23
0
  private static void processContentExtensions(
      final CommonViewer commonViewer, boolean activeFilter, boolean activedPerspectiveFilter) {
    final INavigatorContentService contentService = commonViewer.getNavigatorContentService();

    String[] visibleExtensionIds = contentService.getVisibleExtensionIds();

    List<String> visibleIDsForPecpective = new ArrayList<String>();
    List<String> visibleIdsForActiveFilter = new ArrayList<String>();

    if (visibleExtensionIds != null) {
      visibleIdsForActiveFilter.addAll(Arrays.asList(visibleExtensionIds));
    }

    if (activedPerspectiveFilter) {
      String perspectiveId =
          PlatformUI.getWorkbench()
              .getActiveWorkbenchWindow()
              .getActivePage()
              .getPerspective()
              .getId();
      PerspectiveFilterHelper helper = new PerspectiveFilterHelper();
      helper.setTreeViewer(commonViewer);
      helper.setNavigatorContentService(contentService);
      helper.setActionProviderId(PerspectiveFilterActionProvider.ID);
      String[] pvExtensions = helper.getExtensionIdsToActivate(perspectiveId);

      if (pvExtensions != null && pvExtensions.length > 0) {
        visibleIDsForPecpective = Arrays.asList(pvExtensions);
      }
      visibleIdsForActiveFilter.retainAll(visibleIDsForPecpective);
    }

    String[] filteredContents = RepositoryNodeFilterHelper.getFilterByNodeValues();
    List<String> filteredContentsList = new ArrayList<String>();
    if (filteredContents != null) {
      filteredContentsList = Arrays.asList(filteredContents);
    }

    List<String> checkedExtensions = new ArrayList<String>();
    if (activeFilter) {
      for (String id : visibleIdsForActiveFilter) {
        if (!filteredContentsList.contains(id)) {
          checkedExtensions.add(id);
        }
      }
    } else {
      checkedExtensions.addAll(visibleIdsForActiveFilter);
    }
    String[] contentExtensionIdsToActivate =
        (String[]) checkedExtensions.toArray(new String[checkedExtensions.size()]);
    UpdateActiveExtensionsOperation updateExtensions =
        new UpdateActiveExtensionsOperation(commonViewer, contentExtensionIdsToActivate);
    updateExtensions.execute(null, null);
  }
Пример #24
0
  /**
   * Removes from this record all the field metadata and all the fields with names included in the
   * supplied collection.
   *
   * @param fieldNames the names of the field metadata and fields to remove.
   * @throws NullPointerException if the specified collection is <code>null</code>.
   */
  public void remove(Collection<String> fieldNames) {
    List<String> fieldsToRemove = new LinkedList<String>(this.metadata.getFieldNames());
    fieldsToRemove.retainAll(fieldNames);

    ListIterator<String> fieldIndexIterator = fieldsToRemove.listIterator(fieldsToRemove.size());
    while (fieldIndexIterator.hasPrevious()) {
      this.data.remove(fieldIndexIterator.previous());
    }

    this.metadata.remove(fieldNames);
  }
 @Override
 public boolean retainAll(final Collection<?> arg0) {
   List<String> names = new ArrayList<String>();
   for (Object o : arg0) {
     if (o instanceof Item) {
       names.add(((Item) o).getName());
     } else if (o instanceof String) {
       names.add((String) o);
     }
   }
   return itemNames_.retainAll(names);
 }
Пример #26
0
 public static <T> List<T> intersection(
     Collection<? extends Collection<T>> availableValuesByDescriptor) {
   List<T> result = new ArrayList<T>();
   Iterator<? extends Collection<T>> iterator = availableValuesByDescriptor.iterator();
   if (iterator.hasNext()) {
     Collection<T> firstSet = iterator.next();
     result.addAll(firstSet);
     while (iterator.hasNext()) {
       Collection<T> next = iterator.next();
       result.retainAll(next);
     }
   }
   return result;
 }
 @NotNull
 @Override
 public GlobalSearchScope intersectWith(@NotNull GlobalSearchScope scope) {
   if (scope instanceof FileTypeRestrictionScope) {
     FileTypeRestrictionScope restrict = (FileTypeRestrictionScope) scope;
     if (restrict.myBaseScope == myBaseScope) {
       List<FileType> intersection =
           new ArrayList<FileType>(Arrays.asList(restrict.myFileTypes));
       intersection.retainAll(Arrays.asList(myFileTypes));
       return new FileTypeRestrictionScope(
           myBaseScope, intersection.toArray(new FileType[intersection.size()]));
     }
   }
   return super.intersectWith(scope);
 }
Пример #28
0
 private void removeDuplicates(List<TimelineListViewItem> timelines) {
   Map<String, TimelineListViewItem> unique = new HashMap<>();
   boolean removeSomething = false;
   for (TimelineListViewItem viewItem : timelines) {
     String key = viewItem.timelineTitle.toString();
     if (unique.containsKey(key)) {
       removeSomething = true;
     } else {
       unique.put(key, viewItem);
     }
   }
   if (removeSomething) {
     timelines.retainAll(unique.values());
   }
 }
Пример #29
0
 private void writeQuestList(
     JsonWriter out, List<Quest> quests, List<Quest> setQuests, String name)
     throws IOException {
   List<Quest> inSetQuests = new ArrayList<>(setQuests);
   inSetQuests.retainAll(quests);
   if (!inSetQuests.isEmpty()) {
     out.name(name).beginArray();
     for (Quest quest : inSetQuests) {
       int index = setQuests.indexOf(quest);
       if (index != -1) {
         out.value(index);
       }
     }
     out.endArray();
   }
 }
  private String getRibbonEnv() {
    String[] activeProfiles = env.getActiveProfiles();
    String[] displayOnActiveProfiles = jHipsterProperties.getRibbon().getDisplayOnActiveProfiles();

    if (displayOnActiveProfiles == null) {
      return null;
    }

    List<String> ribbonProfiles = new ArrayList<>(Arrays.asList(displayOnActiveProfiles));
    List<String> springBootProfiles = Arrays.asList(activeProfiles);
    ribbonProfiles.retainAll(springBootProfiles);

    if (ribbonProfiles.size() > 0) {
      return ribbonProfiles.get(0);
    }
    return null;
  }