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; }
/** * 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)); }
void RemoveColidingBids( HashSet<Integer> regions, HashSet<Integer> companies, Double minValue, HashSet<Integer> AvailSet) { HashSet<Integer> RemoveSet = new HashSet<Integer>(); // HashSet to hold the items to remove from the AvailSet // Get an iterator to iterate over all the integers in the availble HashSet Iterator<Integer> it = AvailSet.iterator(); // While there are any left while (it.hasNext()) { // Get the next integer Integer k = it.next(); if ((_bids.get(k).value <= minValue) || // if the value is less than the target (companies.contains(_bids.get(k).company)) || // if the company is already represented !Collections.disjoint( _bids.get(k).region, regions)) { // if it contains a region already bid on // add K to the "Remove" set RemoveSet.add(k); } } // Remove every bid from the remove set from the Avail list. AvailSet.removeAll(RemoveSet); }
public void waitUntilDone(Set<String> workIDs) throws KeeperException, InterruptedException { final String condVar = new String("cond"); Watcher watcher = new Watcher() { @Override public void process(WatchedEvent event) { switch (event.getType()) { case NodeChildrenChanged: synchronized (condVar) { condVar.notify(); } break; case NodeCreated: case NodeDataChanged: case NodeDeleted: case None: log.info("Got unexpected zookeeper event: " + event.getType() + " for " + path); break; } } }; List<String> children = zoo.getChildren(path, watcher); while (!Collections.disjoint(children, workIDs)) { synchronized (condVar) { condVar.wait(10000); } children = zoo.getChildren(path, watcher); } }
public List<Computer> getComputers() { Computer[] computers = Jenkins.getInstance().getComputers(); if (!isFilterExecutors()) { return Arrays.asList(computers); } List<Computer> result = new ArrayList<Computer>(); boolean roam = false; HashSet<Label> labels = new HashSet<Label>(); for (Item item : getItems()) { if (item instanceof AbstractProject<?, ?>) { AbstractProject<?, ?> p = (AbstractProject<?, ?>) item; Label l = p.getAssignedLabel(); if (l != null) { labels.add(l); } else { roam = true; } } } for (Computer c : computers) { Node n = c.getNode(); if (n != null) { if (roam && n.getMode() == Mode.NORMAL || !Collections.disjoint(n.getAssignedLabels(), labels)) { result.add(c); } } } return result; }
/** @inheritDoc */ public FilterResult checkEligibility(Person person, FilterChain filterChain) throws Exception { if (!Collections.disjoint(person.getGroupMemberships(), eligibleGroupMemberships)) { return new FilterResult(true, "has membership in eligible group"); } else { return filterChain.checkEligibility(person); } }
/** * Adds ban to ban list and saves * * @param ban the IpBan to add * @return 0 - Success<br> * 1 - Already banned<br> * 2 - Error saving */ public synchronized byte addBan(IpBan ban) { for (IpBan ipban : ipBans) { if (!Collections.disjoint(ipban.getIps(), ban.getIps())) // Any in common { if (ipban.isOver()) { this.removeBan(ipban); break; } if (ipban.isExpired()) { this.removeBan(ipban); ipban = ipban.expire(); if (ipban == null) break; // Ban is over, continue on else { this.addBan(ipban); return 1; } } } } this.ipBans.add(ban); try { FileWriter fOut = new FileWriter(file, true); String line = "IP: "; for (int i = 0; i < ban.getIps().size() - 1; i++) { line += (ban.getIps().get(i) + ","); } line += ban.getIps().get(ban.getIps().size() - 1); // No comma for last line += " "; line += ban.getReason(); line += "\u00C4"; line += ban.getInfo(); line += "\u00C4"; line += ban.getEndTime(); line += " "; line += (ban.getUUID() == null) ? "null" : ban.getUUID().toString(); line += " "; line += (ban.getBannerUUID() == null) ? "null" : ban.getBannerUUID().toString(); line += " "; line += ban.isRequest(); if (ban.isRequest()) { line += " "; line += ban.getExpireTime(); line += " "; line += ban.isApproveOnExpire(); } line += "\n"; fOut.write(line); fOut.close(); } catch (IOException e) { pl.getLogger().severe("Could not write to " + file.getName()); pl.getLogger().throwing(this.getClass().getName(), "add", e); return 2; // TODO: } return 0; }
public PatternSetWithExplicitIRIBoundVariables( Set<Variable> explicitIRIBoundVariables, Set<Variable> explicitNotIRIBoundVariables) { super(); this.explicitIRIBoundVariables = explicitIRIBoundVariables; this.explicitNotIRIBoundVariables = explicitNotIRIBoundVariables; if (explicitIRIBoundVariables != null && explicitNotIRIBoundVariables != null) { assert Collections.disjoint(explicitIRIBoundVariables, explicitNotIRIBoundVariables); } }
@Override public boolean isAffected(Delta delta, IResourceDescription candidate) throws IllegalArgumentException { if (!hasChanges(delta, candidate)) return false; Set<QualifiedName> names = Sets.newHashSet(); addExportedNames(names, delta.getOld()); addExportedNames(names, delta.getNew()); return !Collections.disjoint(names, getImportedNames(candidate)); }
/** @generated */ public boolean canExistAssociation_4011( Package container, Association linkInstance, Type source, Type target) { try { if ((source instanceof Class) || (source instanceof Component) || (source instanceof Actor) || (source instanceof UseCase)) { if ((target instanceof Class) || (target instanceof Component) || (target instanceof Actor) || (target instanceof UseCase)) { if ((source instanceof UseCase) && (target instanceof UseCase)) { return (Collections.disjoint( ((UseCase) source).getSubjects(), ((UseCase) target).getSubjects())); } return true; } } else { return false; } if ((source instanceof Class) || (source instanceof Component) || (source instanceof Actor) || (source instanceof UseCase)) { if ((target instanceof Class) || (target instanceof Component) || (target instanceof Actor) || (target instanceof UseCase)) { if ((source instanceof UseCase) && (target instanceof UseCase)) { return (Collections.disjoint( ((UseCase) source).getSubjects(), ((UseCase) target).getSubjects())); } return true; } } else { return false; } return true; } catch (Exception e) { UMLDiagramEditorPlugin.getInstance() .logError("Link constraint evaluation error", e); // $NON-NLS-1$ return false; } }
private void mergeIntermediateStates() { Map<Adjacency, Set<FSANode>> adjToNodes = new HashMap<>(); Set<FSANode> newCurMergeLevel = new HashSet<>(); Map<FSANode, FSANode> formerNodeToMergedNode = new HashMap<>(); for (FSANode node : curMergeLevel) { boolean needToBreak = false; for (Set<FSANode> targets : node.getLabelToTargets().values()) { if (targets.size() > 1) { updateBasedOnMerges(targets, formerNodeToMergedNode); FSANode newNode = mergeNodes(targets); targets.stream().forEach(n -> formerNodeToMergedNode.put(n, newNode)); if (newNode.needsToMergeOutgoingEdges()) { newCurMergeLevel.add(newNode); } needToBreak = true; } } if (needToBreak) { break; } for (FSAEdge edge : node.getOutgoingEdges()) { Adjacency adj = new Adjacency(edge); Set<FSANode> nodesWithSameLabelToSameTarget = adjToNodes.get(adj); if (nodesWithSameLabelToSameTarget == null) { nodesWithSameLabelToSameTarget = new HashSet<>(); adjToNodes.put(adj, nodesWithSameLabelToSameTarget); } nodesWithSameLabelToSameTarget.add(node); } } for (FSANode node : curMergeLevel) { newCurMergeLevel.addAll( node.getIncomingEdges().stream().map(e -> e.getSource()).collect(Collectors.toSet())); } for (Set<FSANode> nodes : adjToNodes.values()) { updateBasedOnMerges(nodes, formerNodeToMergedNode); if (nodes.size() > 1) { FSANode newNode = mergeNodes(nodes); if (!Collections.disjoint(newCurMergeLevel, nodes)) { newCurMergeLevel.removeAll(nodes); newCurMergeLevel.add(newNode); } for (FSANode node : nodes) { formerNodeToMergedNode.put(node, newNode); } } } // remove any nodes that are now contained by other nodes curMergeLevel = newCurMergeLevel.stream().filter(n -> this.nodes.contains(n)).collect(Collectors.toSet()); }
@Override public void reportInvalidOptions(EventHandler reporter, BuildOptions buildOptions) { if (!Collections.disjoint(translationFlags, J2OBJC_BLACKLISTED_TRANSLATION_FLAGS)) { String errorMsg = String.format( INVALID_TRANSLATION_FLAGS_MSG_TEMPLATE, Joiner.on(",").join(translationFlags), Joiner.on(",").join(J2OBJC_BLACKLISTED_TRANSLATION_FLAGS)); reporter.handle(Event.error(errorMsg)); } }
private static void extendGroupRec( List<WayData> group, WayData newGroupMember, List<WayData> remaining) { group.add(newGroupMember); for (int i = 0; i < remaining.size(); ++i) { WayData candidate = remaining.get(i); if (candidate == null) continue; if (!Collections.disjoint(candidate.way.getNodes(), newGroupMember.way.getNodes())) { remaining.set(i, null); extendGroupRec(group, candidate, remaining); } } }
/** * Verifies that heap and global object sets are disjunct * * @param pLogger Logger to log the message * @param pSmg SMG to check * @return True if pSmg is consistent w.r.t. this criteria. False otherwise. */ private static boolean verifyDisjunctHeapAndGlobal(LogManager pLogger, CLangSMG pSmg) { Map<String, SMGRegion> globals = pSmg.getGlobalObjects(); Set<SMGObject> heap = pSmg.getHeapObjects(); boolean toReturn = Collections.disjoint(globals.values(), heap); if (!toReturn) { pLogger.log(Level.SEVERE, "CLangSMG inconsistent, heap and global objects are not disjoint"); } return toReturn; }
@Override public int rank( final Set<ResourceType<?>> resourceTypes, final Collection<ServiceConfiguration<?>> serviceConfigs) { if (clusteringService == null || resourceTypes.size() > 1 || Collections.disjoint(resourceTypes, CLUSTER_RESOURCES)) { // A ClusteredStore requires a ClusteringService *and* ClusteredResourcePool instances return 0; } return 1; }
public PatternSetWithExplicitIRIBoundVariables( EPatternSetType t, Collection<? extends Pattern> c, Set<Variable> explicitIRIBoundVariables, Set<Variable> explicitNotIRIBoundVariables) { super(t, c); this.explicitIRIBoundVariables = explicitIRIBoundVariables; this.explicitNotIRIBoundVariables = explicitNotIRIBoundVariables; if (explicitIRIBoundVariables != null && explicitNotIRIBoundVariables != null) { assert Collections.disjoint(explicitIRIBoundVariables, explicitNotIRIBoundVariables); } }
public static void main(String[] args) { print(list); print( "'list' disjoint (Four)?: " + Collections.disjoint(list, Collections.singletonList("Four"))); print("max: " + Collections.max(list)); print("min: " + Collections.min(list)); print("max w/ comparator: " + Collections.max(list, String.CASE_INSENSITIVE_ORDER)); print("min w/ comparator: " + Collections.min(list, String.CASE_INSENSITIVE_ORDER)); List<String> sublist = Arrays.asList("Four five six".split(" ")); print("indexOfSubList: " + Collections.indexOfSubList(list, sublist)); print("lastIndexOfSubList: " + Collections.lastIndexOfSubList(list, sublist)); Collections.replaceAll(list, "one", "Yo"); print("replaceAll: " + list); Collections.reverse(list); print("reverse: " + list); Collections.rotate(list, 3); print("rotate: " + list); List<String> source = Arrays.asList("in the matrix".split(" ")); Collections.copy(list, source); print("copy: " + list); Collections.swap(list, 0, list.size() - 1); print("swap: " + list); Collections.shuffle(list, new Random(47)); print("shuffled: " + list); Collections.fill(list, "pop"); print("fill: " + list); print("frequency of 'pop': " + Collections.frequency(list, "pop")); List<String> dups = Collections.nCopies(3, "snap"); print("dups: " + dups); print("'list' disjoint 'dups'?: " + Collections.disjoint(list, dups)); // Getting an old-style Enumeration: Enumeration<String> e = Collections.enumeration(dups); Vector<String> v = new Vector<String>(); while (e.hasMoreElements()) v.addElement(e.nextElement()); // Converting an old-style Vector // to a List via an Enumeration: ArrayList<String> arrayList = Collections.list(v.elements()); print("arrayList: " + arrayList); }
/** * Find the closest common superclass of multiple classes * * @param cs * @return */ @SuppressWarnings("rawtypes") public static Class FindCommonSuperclass(Class[] cs) { if (cs.length == 0) { return Object.class; } else if (cs.length == 1) { return cs[0]; } // if any items fail getSuperclass in the passed in array, // simply return object. boolean isSame = true; boolean hasNullSuperclass = false; for (Class c : cs) { if (c == null) throw new NullPointerException(); if (c != cs[0]) isSame = false; if (c.getSuperclass() == null) hasNullSuperclass = true; } // no need to do further calculations.. all the same if (isSame) return cs[0]; // at least one item in the list failed getSuperclass... return object if (hasNullSuperclass) return Object.class; Class c1 = cs[0]; Class c2 = null; HashSet<Class> s1 = new HashSet<>(); HashSet<Class> s2 = new HashSet<>(); for (int i = 1; i < cs.length; i++) { s1.clear(); s2.clear(); c2 = cs[i]; do { s1.add(c1); s2.add(c2); if (c1 != Object.class) { c1 = c1.getSuperclass(); } if (c2 != Object.class) { c2 = c2.getSuperclass(); } } while (Collections.disjoint(s1, s2)); s1.retainAll(s2); c1 = s1.iterator().next(); // there can only be one if (c1 == Object.class) break; // no superclass above object } return c1; }
protected Boolean isDelegationAllowed(final TaskInstance task) { if (task == null) { return false; } if ("Completed".equals(task.getStatus())) { return false; } final String actualOwner = task.getActualOwner(); if (actualOwner != null && actualOwner.equals(identityProvider.getName())) { return true; } final String initiator = task.getCreatedBy(); if (initiator != null && initiator.equals(identityProvider.getName())) { return true; } List<String> roles = identityProvider.getRoles(); // TODO Needs to check if po or ba string is a group or a user final List<String> potentialOwners = task.getPotentialOwners(); if (potentialOwners != null && Collections.disjoint(potentialOwners, roles) == false) { return true; } final List<String> businessAdministrators = task.getBusinessAdmins(); if (businessAdministrators != null && Collections.disjoint(businessAdministrators, roles) == false) { return true; } return false; }
@Override public Description matchCompilationUnit(CompilationUnitTree tree, VisitorState state) { if (tree.getTypeDecls().size() <= 1) { // package-info.java files have zero top-level declarations, everything // else should have exactly one. return Description.NO_MATCH; } if (tree.getPackageName() == null) { // Real code doesn't use the default package. return Description.NO_MATCH; } List<String> names = new ArrayList<>(); for (Tree member : tree.getTypeDecls()) { if (member instanceof ClassTree) { ClassTree classMember = (ClassTree) member; switch (classMember.getKind()) { case CLASS: case INTERFACE: case ANNOTATION_TYPE: case ENUM: SuppressWarnings suppression = ASTHelpers.getAnnotation(classMember, SuppressWarnings.class); if (suppression != null && !Collections.disjoint(Arrays.asList(suppression.value()), allNames())) { // If any top-level classes have @SuppressWarnings("TopLevel"), ignore // this compilation unit. We can't rely on the normal suppression // mechanism because the only enclosing element is the package declaration, // and @SuppressWarnings can't be applied to packages. return Description.NO_MATCH; } names.add(classMember.getSimpleName().toString()); break; default: break; } } } if (names.size() <= 1) { // this can happen with multiple type declarations if some of them are // empty (e.g. ";" at the top level counts as an empty type decl) return Description.NO_MATCH; } String message = String.format( "Expected at most one top-level class declaration, instead found: %s", Joiner.on(", ").join(names)); return buildDescription(tree.getPackageName()).setMessage(message).build(); }
TestSuite computeMultimapAsMapGetTestSuite( FeatureSpecificTestSuiteBuilder< ?, ? extends OneSizeTestContainerGenerator<M, Map.Entry<K, V>>> parentBuilder) { Set<Feature<?>> features = computeMultimapAsMapGetFeatures(parentBuilder.getFeatures()); if (Collections.disjoint(features, EnumSet.allOf(CollectionSize.class))) { return new TestSuite(); } else { return CollectionTestSuiteBuilder.using( new MultimapAsMapGetGenerator<K, V, M>(parentBuilder.getSubjectGenerator())) .withFeatures(features) .named(parentBuilder.getName() + ".asMap[].get[key]") .suppressing(parentBuilder.getSuppressedTests()) .createTestSuite(); } }
/** * Verifies that global and stack object sets are disjunct * * @param pLogger Logger to log the message * @param pSmg SMG to check * @return True if pSmg is consistent w.r.t. this criteria. False otherwise. */ private static boolean verifyDisjunctGlobalAndStack(LogManager pLogger, CLangSMG pSmg) { Deque<CLangStackFrame> stack_frames = pSmg.getStackFrames(); Set<SMGObject> stack = new HashSet<>(); for (CLangStackFrame frame : stack_frames) { stack.addAll(frame.getAllObjects()); } Map<String, SMGRegion> globals = pSmg.getGlobalObjects(); boolean toReturn = Collections.disjoint(stack, globals.values()); if (!toReturn) { pLogger.log(Level.SEVERE, "CLangSMG inconsistent, global and stack objects are not disjoint"); } return toReturn; }
public ModelCloudProxySet hasProvidedSpaces(Object value) { ObjectSet neighbors = new ObjectSet(); if (value instanceof Collection) { neighbors.addAll((Collection<?>) value); } else { neighbors.add(value); } ModelCloudProxySet answer = new ModelCloudProxySet(); for (ModelCloudProxy obj : this) { if (!Collections.disjoint(neighbors, obj.getProvidedSpaces())) { answer.add(obj); } } return answer; }
public ClassModelSet hasEnumerations(Object value) { ObjectSet neighbors = new ObjectSet(); if (value instanceof Collection) { neighbors.addAll((Collection<?>) value); } else { neighbors.add(value); } ClassModelSet answer = new ClassModelSet(); for (ClassModel obj : this) { if (!Collections.disjoint(neighbors, obj.getEnumerations())) { answer.add(obj); } } return answer; }
public GraphSet hasGcs(Object value) { ObjectSet neighbors = new ObjectSet(); if (value instanceof Collection) { neighbors.addAll((Collection<?>) value); } else { neighbors.add(value); } GraphSet answer = new GraphSet(); for (Graph obj : this) { if (!Collections.disjoint(neighbors, obj.getGcs())) { answer.add(obj); } } return answer; }
/** * Compares this section against another section for conflicts. * * @param section The section to compare this section against. * @return boolean * <ul> * true - conflict detected * <p>false - no conflict detected * <ul/> */ public boolean conflictsWith(Section section) { Log.i( "Section Conflict Check", "Comparing sections: \n" + toJSON() + " to \n" + section.toJSON().toString()); boolean returnValue; if (!Collections.disjoint( days, section .days)) { // If there is overlap between the two sets of days conflict is possible, run // checks if (endTime.equals( section.endTime)) // If this section's end time equals the other section's end time return true; if (startTime.before(section.startTime)) // If this section starts before the other section return section.startTime.before( endTime); // check to see if this section ends before other section begins // If this section starts after the other section // check to see if other section ends before this section begins returnValue = !section.startTime.before(startTime) || startTime.before(section.endTime); } else returnValue = false; // Days are disjoint, no conflict possible if (returnValue) Log.w( "Schedule Conflict Error", "Conflict between " + getSourceCourse().getCourseTitle() + " " + getSourceCourse().getCourseNumber() + "-" + getSectionNumber() + " and " + section.getSourceCourse().getCourseTitle() + " " + section.getSourceCourse().getCourseNumber() + "-" + section.getSectionNumber()); return returnValue; }