Java Collections.disjoint Examples

Java Collections.disjoint - 30 examples found. These are the top rated real world Java examples of java.util.Collections.disjoint extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
 private boolean isAnyFieldSetForSelectedEntry(List<String> fieldnames) {
   if (panel.getMainTable().getSelectedRowCount() == 1) {
     BibEntry entry = panel.getMainTable().getSelected().get(0);
     return !Collections.disjoint(fieldnames, entry.getFieldNames());
   }
   return false;
 }
  @Override
  public int compare(Policy p1, Policy p2) {

    // Give precedence to stanzas with inner package mappings
    if (p1.hasInnerPackages() != p2.hasInnerPackages()) {
      return p1.hasInnerPackages() ? -1 : 1;
    }

    // Check for duplicate entries
    if (p1.getSignatures().equals(p2.getSignatures())) {
      // Checks if signer w/o inner package names
      if (p1.hasGlobalSeinfo()) {
        duplicateFound = true;
        Slog.e(SELinuxMMAC.TAG, "Duplicate policy entry: " + p1.toString());
      }

      // Look for common inner package name mappings
      final Map<String, String> p1Packages = p1.getInnerPackages();
      final Map<String, String> p2Packages = p2.getInnerPackages();
      if (!Collections.disjoint(p1Packages.keySet(), p2Packages.keySet())) {
        duplicateFound = true;
        Slog.e(SELinuxMMAC.TAG, "Duplicate policy entry: " + p1.toString());
      }
    }

    return 0;
  }
  @Override
  public boolean isModuleAllowed(IModule iModule, ItemStack itemStack) {
    boolean allowed = false;
    if (itemStack.getItem() instanceof ItemBrassArmor) {
      ItemBrassArmor brassArmor = (ItemBrassArmor) itemStack.getItem();
      if (iModule instanceof IArmorModule) {
        IArmorModule iArmorModule = (IArmorModule) iModule;
        if ((iArmorModule.getApplicablePiece() == -1)
            || (iArmorModule.getApplicablePiece() == brassArmor.armorType)) {
          ArrayList<IModule> moduleIncompatibilities =
              ModuleRegistry.getModuleIncompatibilities(iModule.getModuleId());
          if ((moduleIncompatibilities == null)
              || Collections.disjoint(
                  IModuleContainer.Helper.getAllModulesEquipped(itemStack),
                  moduleIncompatibilities)) {
            if (!IModuleContainer.Helper.getAllModulesEquipped(itemStack).contains(iModule)) {
              allowed = true;
            }
          }
        }
      }
    }

    return allowed;
  }
Example #4
0
 /**
  * Returns true if events in general can be sent. This method checks basic conditions common to
  * all type of event notifications (e.g. item was published, node configuration has changed, new
  * child node was added to collection node, etc.).
  *
  * @return true if events in general can be sent.
  */
 private boolean canSendEvents() {
   // Check if the subscription is active
   if (!isActive()) {
     return false;
   }
   // Check if delivery of notifications is disabled
   if (!shouldDeliverNotifications()) {
     return false;
   }
   // Check if delivery is subject to presence-based policy
   if (!getPresenceStates().isEmpty()) {
     Collection<String> shows = service.getShowPresences(jid);
     if (shows.isEmpty() || Collections.disjoint(getPresenceStates(), shows)) {
       return false;
     }
   }
   // Check if node is only sending events when user is online
   if (node.isPresenceBasedDelivery()) {
     // Check that user is online
     if (service.getShowPresences(jid).isEmpty()) {
       return false;
     }
   }
   return true;
 }
  /**
   * Recursive method to add list layers get by the WMSServer into tree list
   *
   * @param children Represents child layers of parentNode
   * @param tree Tree of layers
   * @param crs CRS that must have the layers to add these to the tree
   * @param parentNode Represents parent layer
   * @param layersMap Represents the map that contains the layers obtained
   * @param isCalledByWizard Indicate if the method is called by the wizard
   */
  private void generateWMSChildrenNodes(
      ArrayList<WMSLayer> children,
      List<TreeNode> tree,
      TreeSet<String> listCrs,
      TreeNode parentNode,
      Map<String, org.gvsig.framework.web.ogc.WMSLayer> layersMap,
      WMSInfo wmsInfo) {
    for (WMSLayer layerChild : children) {
      // get crs (srs) (belong to layer)
      Vector crsVector = layerChild.getAllSrs();
      // Only get the layers with have crs parameter or if crs is null
      if (listCrs.isEmpty() || !Collections.disjoint(crsVector, listCrs)) {

        ArrayList<WMSLayer> layerChildChildren = layerChild.getChildren();
        TreeNode layerChildNode = new TreeNode(layerChild.getName());
        layerChildNode.setTitle(layerChild.getTitle());

        // Get the children and their information
        if (layerChildChildren.isEmpty()) {
          layerChildNode.setFolder(false);

          // Add layer to layer map
          org.gvsig.framework.web.ogc.WMSLayer wmsLayer =
              new org.gvsig.framework.web.ogc.WMSLayer();
          TreeSet<String> crsSet = new TreeSet<String>();
          crsSet.addAll(layerChild.getAllSrs());
          wmsLayer.setCrs(crsSet);
          List<WMSStyle> wmsStyles = createListWMSStyles(layerChild.getStyles());
          wmsLayer.setStyles(wmsStyles);
          wmsLayer.setTitle(layerChild.getTitle());
          wmsLayer.setName(layerChild.getName());
          layersMap.put(layerChild.getName(), wmsLayer);

          // add to wmsinfo the layers supported by this layer
          TreeSet<String> crsSupported = wmsInfo.getCrsSupported();
          crsSupported.addAll(layerChild.getAllSrs());
          wmsInfo.setCrsSupported(crsSupported);

          // create one child for each crs of the layer
          if (listCrs.isEmpty() || listCrs.size() > 1) {
            for (String crs : crsSet) {
              if (StringUtils.isNotEmpty(crs) && (listCrs.isEmpty() || listCrs.contains(crs))) {
                TreeNode crsNode = new TreeNode(crs);
                crsNode.setHideCheckbox(true);
                crsNode.setUnselectable(true);
                crsNode.setIconclass(" ");
                layerChildNode.addChild(crsNode);
              }
            }
          }
        } else {
          layerChildNode.setFolder(true);
          layerChildNode.setExpanded(true);
          generateWMSChildrenNodes(
              layerChildChildren, tree, listCrs, layerChildNode, layersMap, wmsInfo);
        }
        parentNode.addChild(layerChildNode);
      }
    }
  }
  /**
   * Check that the item matches the requirements expressed in the three lists
   *
   * @param item the item to check
   * @param query query that must be fulfilled
   * @return true if the item match all requirements
   */
  protected boolean match(T item, Query<T> query) {
    Set<String> existingEvents = new HashSet<>();
    Set<String> successEvents = new HashSet<>();
    Set<String> oldEvents = new HashSet<>();
    for (Event event : filterNewestEvent(item.getEventList())) {
      existingEvents.add(event.getEventID());
      if (event.isSuccess()) {
        successEvents.add(event.getEventID());
      }
      if (item.getLastModified() != null) {
        if (!event.getDate().after(item.getLastModified())) {
          oldEvents.add(event.getEventID());
        }
      }
    }
    final boolean successEventsGood = successEvents.containsAll(query.getPastSuccessfulEvents());

    boolean oldEventsGood = true;
    for (String oldEvent : query.getOldEvents()) {
      oldEventsGood =
          oldEventsGood && (oldEvents.contains(oldEvent) || !existingEvents.contains(oldEvent));
    }
    boolean futureEventsGood = Collections.disjoint(existingEvents, query.getFutureEvents());

    // TODONT we do not check for types for now
    return successEventsGood
        && oldEventsGood
        && futureEventsGood
        && (query.getItems().isEmpty() || query.getItems().contains(item));
  }