Java Code Examples for java.util.Set#retainAll()
The following examples show how to use
java.util.Set#retainAll() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RemoteUserAuthenticatorFactory.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
protected boolean isAdminConsoleWebScript(WebScript webScript) { if (webScript == null || adminConsoleScriptFamilies == null || webScript.getDescription() == null || webScript.getDescription().getFamilys() == null) { return false; } if (logger.isTraceEnabled()) { logger.trace("WebScript: " + webScript + " has these families: " + webScript.getDescription().getFamilys()); } // intersect the "family" sets defined Set<String> families = new HashSet<String>(webScript.getDescription().getFamilys()); families.retainAll(adminConsoleScriptFamilies); final boolean isAdminConsole = !families.isEmpty(); if (logger.isTraceEnabled() && isAdminConsole) { logger.trace("Detected an Admin Console webscript: " + webScript ); } return isAdminConsole; }
Example 2
Source File: StrictEvaluationStrategy.java From rdf4j with BSD 3-Clause "New" or "Revised" License | 6 votes |
public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(LeftJoin leftJoin, final BindingSet bindings) throws QueryEvaluationException { if (TupleExprs.containsSubquery(leftJoin.getRightArg())) { return new HashJoinIteration(this, leftJoin, bindings); } // Check whether optional join is "well designed" as defined in section // 4.2 of "Semantics and Complexity of SPARQL", 2006, Jorge PĂ©rez et al. VarNameCollector optionalVarCollector = new VarNameCollector(); leftJoin.getRightArg().visit(optionalVarCollector); if (leftJoin.hasCondition()) { leftJoin.getCondition().visit(optionalVarCollector); } Set<String> problemVars = optionalVarCollector.getVarNames(); problemVars.removeAll(leftJoin.getLeftArg().getBindingNames()); problemVars.retainAll(bindings.getBindingNames()); if (problemVars.isEmpty()) { // left join is "well designed" return new LeftJoinIterator(this, leftJoin, bindings); } else { return new BadlyDesignedLeftJoinIterator(this, leftJoin, bindings, problemVars); } }
Example 3
Source File: OldSimpleOwlSim.java From owltools with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @param populationClass * @param sampleSetClass * @param enrichedClass * @return enrichment * @throws MathException */ public EnrichmentResult calculatePairwiseEnrichment(OWLClass populationClass, OWLClass sampleSetClass, OWLClass enrichedClass) throws MathException { HypergeometricDistributionImpl hg = new HypergeometricDistributionImpl( getNumElementsForAttribute(populationClass), getNumElementsForAttribute(sampleSetClass), getNumElementsForAttribute(enrichedClass) ); /* LOG.info("popsize="+getNumElementsForAttribute(populationClass)); LOG.info("sampleSetSize="+getNumElementsForAttribute(sampleSetClass)); LOG.info("enrichedClass="+getNumElementsForAttribute(enrichedClass)); */ Set<OWLEntity> eiSet = getElementsForAttribute(sampleSetClass); eiSet.retainAll(this.getElementsForAttribute(enrichedClass)); //LOG.info("both="+eiSet.size()); double p = hg.cumulativeProbability(eiSet.size(), Math.min(getNumElementsForAttribute(sampleSetClass), getNumElementsForAttribute(enrichedClass))); double pCorrected = p * getCorrectionFactor(populationClass); return new EnrichmentResult(sampleSetClass, enrichedClass, p, pCorrected); }
Example 4
Source File: PDGSlice.java From JDeodorant with MIT License | 6 votes |
private boolean nonDuplicatedSliceNodeOutputDependsOnNonRemovableNode() { Set<PDGNode> duplicatedNodes = new LinkedHashSet<PDGNode>(); duplicatedNodes.addAll(sliceNodes); duplicatedNodes.retainAll(indispensableNodes); for(PDGNode sliceNode : sliceNodes) { if(!duplicatedNodes.contains(sliceNode)) { for(GraphEdge edge : sliceNode.incomingEdges) { PDGDependence dependence = (PDGDependence)edge; if(edges.contains(dependence) && dependence instanceof PDGOutputDependence) { PDGOutputDependence outputDependence = (PDGOutputDependence)dependence; PDGNode srcPDGNode = (PDGNode)outputDependence.src; if(!removableNodes.contains(srcPDGNode)) return true; } } } } return false; }
Example 5
Source File: PigRelOpVisitor.java From calcite with Apache License 2.0 | 6 votes |
@Override public void visit(LOJoin join) throws FrontendException { joinInternal(join.getExpressionPlans(), join.getInnerFlags()); LogicalJoin joinRel = (LogicalJoin) builder.peek(); Set<String> duplicateNames = new HashSet<>(joinRel.getLeft().getRowType().getFieldNames()); duplicateNames.retainAll(joinRel.getRight().getRowType().getFieldNames()); if (!duplicateNames.isEmpty()) { final List<String> fieldNames = new ArrayList<>(); final List<RexNode> fields = new ArrayList<>(); for (RelDataTypeField leftField : joinRel.getLeft().getRowType().getFieldList()) { fieldNames.add(builder.getAlias(joinRel.getLeft()) + "::" + leftField.getName()); fields.add(builder.field(leftField.getIndex())); } int leftCount = joinRel.getLeft().getRowType().getFieldList().size(); for (RelDataTypeField rightField : joinRel.getRight().getRowType().getFieldList()) { fieldNames.add(builder.getAlias(joinRel.getRight()) + "::" + rightField.getName()); fields.add(builder.field(rightField.getIndex() + leftCount)); } builder.project(fields, fieldNames); } builder.register(join); }
Example 6
Source File: FE9ItemDataLoader.java From Universal-FE-Randomizer with MIT License | 5 votes |
public List<FE9Item> possibleUpgradesToWeapon(FE9Item item, boolean isWielderPromoted) { if (item == null) { return null; } FE9Data.Item original = FE9Data.Item.withIID(iidOfItem(item)); if (original == null || !original.isWeapon() || original.isStaff()) { return null; } Set<FE9Data.Item> upgrades = new HashSet<FE9Data.Item>(); if (original.isERank()) { upgrades.addAll(FE9Data.Item.allDRankWeapons); } else if (original.isDRank()) { upgrades.addAll(FE9Data.Item.allCRankWeapons); } else if (original.isCRank()) { upgrades.addAll(FE9Data.Item.allCRankWeapons); upgrades.addAll(FE9Data.Item.allBRankWeapons); } else if (original.isBRank()) { // Unpromoted classes apparently can't go above B rank. upgrades.addAll(FE9Data.Item.allBRankWeapons); if (isWielderPromoted) { upgrades.addAll(FE9Data.Item.allARankWeapons); } } else if (original.isARank()) { upgrades.addAll(FE9Data.Item.allSRankWeapons); } if (original.isSword()) { upgrades.retainAll(FE9Data.Item.allSwords); } else if (original.isLance()) { upgrades.retainAll(FE9Data.Item.allLances); } else if (original.isAxe()) { upgrades.retainAll(FE9Data.Item.allAxes); } else if (original.isBow()) { upgrades.retainAll(FE9Data.Item.allBows); } else if (original.isFireMagic()) { upgrades.retainAll(FE9Data.Item.allFireMagic); } else if (original.isThunderMagic()) { upgrades.retainAll(FE9Data.Item.allThunderMagic); } else if (original.isWindMagic()) { upgrades.retainAll(FE9Data.Item.allWindMagic); } else if (original.isLightMagic()) { upgrades.retainAll(FE9Data.Item.allLightMagic); } else { return null; } return upgrades.stream().sorted(new Comparator<FE9Data.Item>() { @Override public int compare(Item arg0, Item arg1) { return arg0.getIID().compareTo(arg1.getIID()); } }).map(fe9DataItem -> { return itemWithIID(fe9DataItem.getIID()); }).collect(Collectors.toList()); }
Example 7
Source File: CollectionsShouldNotContainThemselves.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
@ExpectWarning("DMI") public static void main(String args[]) { Set s = new HashSet(); s.contains(s); s.remove(s); s.containsAll(s); s.retainAll(s); s.removeAll(s); }
Example 8
Source File: TermFeature.java From topic-detection with Apache License 2.0 | 5 votes |
public double similarityJaccard(TermFeature tf){ Set<String> intersection = new HashSet<String>(docs.keySet()); intersection.retainAll(tf.docs.keySet()); Set<String> union = new HashSet<String>(docs.keySet()); union.addAll(tf.docs.keySet()); return ((double) intersection.size())/((double) union.size()); }
Example 9
Source File: TcpLttngEventMatching.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@Override public boolean canMatchTrace(ITmfTrace trace) { // Get the events that this trace needs to have if (!(trace instanceof IKernelTrace)) { // Not a kernel trace, we cannot know what events to use, return // false return false; } IKernelAnalysisEventLayout layout = ((IKernelTrace) trace).getKernelEventLayout(); TRACE_LAYOUTS.put(trace, layout); Set<String> events = REQUIRED_EVENTS.computeIfAbsent(layout, eventLayout -> { Set<String> eventsSet = new HashSet<>(); eventsSet.addAll(eventLayout.eventsNetworkSend()); eventsSet.addAll(eventLayout.eventsNetworkReceive()); return eventsSet; }); if (!(trace instanceof ITmfTraceWithPreDefinedEvents)) { // No predefined events, suppose events are present return true; } ITmfTraceWithPreDefinedEvents ktrace = (ITmfTraceWithPreDefinedEvents) trace; Set<String> traceEvents = TmfEventTypeCollectionHelper.getEventNames(ktrace.getContainedEventTypes()); traceEvents.retainAll(events); return !traceEvents.isEmpty(); }
Example 10
Source File: SimEngine.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * todo rename - actually gets common named ancestors * @param a * @param b * @return set of ancestors */ public Set<OWLObject> getCommonSubsumers(OWLObject a, OWLObject b) { Set<OWLObject> s1 = getGraph().getAncestorsReflexive(a); s1.retainAll(getGraph().getAncestorsReflexive(b)); filterObjects(s1); return s1; }
Example 11
Source File: SimpleOwlSim.java From owltools with BSD 3-Clause "New" or "Revised" License | 5 votes |
public Set<Node<OWLClass>> getNamedCommonSubsumers(OWLClass a, OWLClass b) { // - assume named // classes //if (csCache.containsKey(pair)) // return new HashSet<Node<OWLClass>>(csCache.get(pair)); Set<Node<OWLClass>> nodes = getNamedReflexiveSubsumers(a); nodes.retainAll(getNamedReflexiveSubsumers(b)); //csCache.put(pair, nodes); //todo - we don't need to make a copy any more as this is not cached return new HashSet<Node<OWLClass>>(nodes); }
Example 12
Source File: EnglishPennTreebankParseEvaluator.java From berkeleyparser with GNU General Public License v2.0 | 5 votes |
public int getHammingDistance(Tree<L> guess, Tree<L> gold) { Set<Object> guessedSet = makeObjects(guess); Set<Object> goldSet = makeObjects(gold); Set<Object> correctSet = new HashSet<Object>(); correctSet.addAll(goldSet); correctSet.retainAll(guessedSet); return (guessedSet.size() - correctSet.size()) + (goldSet.size() - correctSet.size()); }
Example 13
Source File: ProvenanceIntegration.java From SPADE with GNU General Public License v3.0 | 5 votes |
private static int countCommonAnnotations(Vertex v1, Vertex v2) { Set<Map.Entry<String, String>> e1 = v1.getAnnotations().entrySet(); Set<Map.Entry<String, String>> e2 = v2.getAnnotations().entrySet(); Set<Map.Entry<String, String>> results = new HashSet<>(); results.addAll(e1); results.retainAll(e2); return results.size(); }
Example 14
Source File: IgniteSnapshotManager.java From ignite with Apache License 2.0 | 5 votes |
/** * @param grps List of cache groups which will be destroyed. */ public void onCacheGroupsStopped(List<Integer> grps) { for (SnapshotFutureTask sctx : locSnpTasks.values()) { Set<Integer> retain = new HashSet<>(grps); retain.retainAll(sctx.affectedCacheGroups()); if (!retain.isEmpty()) { sctx.acceptException(new IgniteCheckedException("Snapshot has been interrupted due to some of the required " + "cache groups stopped: " + retain)); } } }
Example 15
Source File: DeployWorkerPackage.java From pegasus with Apache License 2.0 | 4 votes |
/** * Retrieves the sites for which the deployment jobs need to be created. * * @param dag the dag on which the jobs need to execute. * @return a Set array containing a list of siteID's of the sites where the dag has to be run. * Index[0] has the sites for sharedfs deployment while Index[1] for ( nonsharedfs and * condorio). */ protected Set[] getDeploymentSites(ADag dag) { Set[] result = new Set[2]; result[0] = new HashSet(); result[1] = new HashSet(); Set sharedFSSet = result[0]; Set nonsharedFSSet = result[1]; for (Iterator<GraphNode> it = dag.jobIterator(); it.hasNext(); ) { GraphNode node = it.next(); Job job = (Job) node.getContent(); // PM-497 // we ignore any clean up jobs that may be running if (job.getJobType() == Job.CLEANUP_JOB || (job.getJobType() == Job.STAGE_IN_JOB || job.getJobType() == Job.STAGE_OUT_JOB || job.getJobType() == Job.INTER_POOL_JOB)) { // we also ignore any remote transfer jobs that maybe associated to run in the work // directory // because of the fact that staging site may have a file server URL. continue; } // add to the set only if the job is // being run in the work directory // this takes care of local site create dir String conf = job.getDataConfiguration(); if (conf != null && job.runInWorkDirectory()) { if (conf.equalsIgnoreCase(PegasusConfiguration.SHARED_FS_CONFIGURATION_VALUE)) { sharedFSSet.add(job.getSiteHandle()); } else { nonsharedFSSet.add(job.getSiteHandle()); } } } // PM-810 sanity check to make sure sites are not setup // for both modes Set<String> intersection = new HashSet<String>(sharedFSSet); intersection.retainAll(nonsharedFSSet); if (!intersection.isEmpty()) { throw new RuntimeException( "Worker package is set to be staged for both sharedfs and nonsharedfs|condorio mode for sites " + intersection); } // remove the stork pool sharedFSSet.remove("stork"); nonsharedFSSet.remove("stork"); return result; }
Example 16
Source File: InternalManagementService.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") private void handleTableCreate(Object[] data) { GemFireContainer container = (GemFireContainer) data[0]; Set<String> serverGroupsToUse = Collections.EMPTY_SET; LocalRegion region = container.getRegion(); if (region == null) { return; } RegionMBeanBridge<?, ?> regionMBeanBridge = RegionMBeanBridge.getInstance(region); TableMBeanBridge tableMBeanBridge = new TableMBeanBridge(container, this.connectionWrapperHolder, this.getTableDefinition(container.getSchemaName(), container.getTableName())); GemFireCacheImpl cache = Misc.getGemFireCache(); InternalDistributedMember thisMember = cache.getDistributedSystem().getDistributedMember(); String memberNameOrId = MBeanJMXAdapter.getMemberNameOrId(thisMember); // determine group(s) to create TableMBean SortedSet<String> tableServerGroups = ServerGroupUtils.getServerGroupsFromContainer(container); //logger.warning("InternalManagementService.handleTableCreate() 3 tableServerGroups :: "+tableServerGroups); if (tableServerGroups != null && !tableServerGroups.isEmpty()) { serverGroupsToUse = new TreeSet<String>(tableServerGroups); // 'new' not needed as ServerGroupUtils.getServerGroupsFromContainer returns new set Set<String> memberGroupsSet = getMyServerGroups(); serverGroupsToUse.retainAll(memberGroupsSet); } if (serverGroupsToUse.isEmpty()) { serverGroupsToUse = DEFAULT_SERVERGROUP_SET; } //logger.warning("InternalManagementService.handleTableCreate() 4 serverGroupsToUse :: "+serverGroupsToUse); for (String serverGroup : serverGroupsToUse) { TableMBean tableMBean = new TableMBean(tableMBeanBridge, regionMBeanBridge); // Subset of Server Groups for Region & for member needs to be used in ObjectNames //logger.warning("InternalManagementService.handleTableCreate() 5 before registering tableMBean :: "+tableMBean); // unregister if already registered due to previous unclean close ObjectName tableMBeanName = ManagementUtils.getTableMBeanName(serverGroup, memberNameOrId, container.getQualifiedTableName()); if (this.gfManagementService.isRegistered(tableMBeanName)) { unregisterMBean(tableMBeanName); } ObjectName registeredMBeanName = this.registerMBean(tableMBean, tableMBeanName); //logger.warning("InternalManagementService.handleTableCreate() 6 before federating tableMBean :: "+tableMBean); this.gfManagementService.federate(registeredMBeanName, TableMXBean.class, false /*notif emitter*/); //logger.warning("InternalManagementService.handleTableCreate() 7 after federating tableMBean :: "+tableMBean); } this.tableMBeanDataUpdater.addUpdatable(tableMBeanBridge.getFullName(), tableMBeanBridge); // start updates after creation }
Example 17
Source File: RenameTypeProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private static Set<ICompilationUnit> getIntersection(ICompilationUnit[] a1, ICompilationUnit[] a2){ Set<ICompilationUnit> set1= new HashSet<ICompilationUnit>(Arrays.asList(a1)); Set<ICompilationUnit> set2= new HashSet<ICompilationUnit>(Arrays.asList(a2)); set1.retainAll(set2); return set1; }
Example 18
Source File: NodesPruningHelper.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
private static void handleRangePartitioning(QueryInfo sqi,Object[] currentRowRoutingInfo, Set<InternalDistributedMember> allNodes, Set<DistributedMember> prunedNodes, int conditionNumIndx, LogWriter logger) { PartitionedRegion pr = (PartitionedRegion)sqi.getRegion(); //Identify the nodes which should see the query based on partition resolver GfxdPartitionResolver spr = (GfxdPartitionResolver)pr.getPartitionResolver(); Set<DistributedMember> currentCondnNodes = null; //Each row represents a condition currentCondnNodes = null; DataValueDescriptor lowerbound = (DataValueDescriptor)currentRowRoutingInfo[1]; DataValueDescriptor upperbound = (DataValueDescriptor)currentRowRoutingInfo[3]; boolean lboundinclusive = false , uboundinclusive= false ; if(lowerbound != null) { lboundinclusive = ((Boolean)currentRowRoutingInfo[2]).booleanValue(); } if(upperbound != null) { uboundinclusive = ((Boolean)currentRowRoutingInfo[4]).booleanValue(); } Object[] routingObjects = spr.getRoutingObjectsForRange(lowerbound, lboundinclusive, upperbound, uboundinclusive); routingObjects= routingObjects!=null? routingObjects: new Object[]{}; logger.info("Range ["+lowerbound+" inclusive = "+ lboundinclusive + " to "+upperbound+ " inclusive = "+uboundinclusive+ "] : routing keys = "+routingObjects.length); for(Object entry : routingObjects) { logger.info(" routing keys = [" + entry.toString() + "]"); } if(routingObjects.length > 0) { currentCondnNodes = pr.getMembersFromRoutingObjects(routingObjects); } if( currentRowRoutingInfo.length > 5 ) { //Look for the junction Op if(((Integer)currentRowRoutingInfo[5]).intValue() == ANDing) { if(currentCondnNodes != null) { prunedNodes.retainAll(currentCondnNodes); } }else { //OR junction if(currentCondnNodes != null) { prunedNodes.addAll(currentCondnNodes); }else { prunedNodes.addAll(allNodes); } } }else { //case of starting row if(currentCondnNodes != null) { prunedNodes.retainAll(currentCondnNodes); } } }
Example 19
Source File: SplitVariableReplacement.java From RefactoringMiner with MIT License | 4 votes |
public boolean commonBefore(SplitVariableReplacement other) { Set<String> interestion = new LinkedHashSet<String>(this.splitVariables); interestion.retainAll(other.splitVariables); return this.getBefore().equals(other.getBefore()) && interestion.size() == 0; }
Example 20
Source File: CubaDateField.java From cuba with Apache License 2.0 | 4 votes |
@Override protected void updateInternal(String newDateString, Map<String, Integer> resolutions) { // CAUTION: copied from AbstractDateField Set<String> resolutionNames = getResolutions().map(Enum::name) .collect(Collectors.toSet()); resolutionNames.retainAll(resolutions.keySet()); if (!isReadOnly() && (!resolutionNames.isEmpty() || newDateString != null)) { // Old and new dates final LocalDate oldDate = getValue(); LocalDate newDate; String mask = StringUtils.replaceChars(getState(false).dateMask, "#U", "__"); if ("".equals(newDateString) || mask.equals(newDateString)) { newDate = null; } else { newDate = reconstructDateFromFields(resolutions, oldDate); } boolean parseErrorWasSet = currentErrorMessage != null; boolean hasChanges = !Objects.equals(dateString, newDateString) || !Objects.equals(oldDate, newDate) || parseErrorWasSet; if (hasChanges) { dateString = newDateString; currentErrorMessage = null; if (newDateString == null || newDateString.isEmpty()) { boolean valueChanged = setValue(newDate, true); if (!valueChanged && parseErrorWasSet) { doSetValue(newDate); } } else { // invalid date string if (resolutions.isEmpty()) { Result<LocalDate> parsedDate = handleUnparsableDateString( dateString); parsedDate.ifOk(v -> setValue(v, true)); if (parsedDate.isError()) { dateString = null; currentErrorMessage = parsedDate .getMessage().orElse("Parsing error"); if (!isDifferentValue(null)) { doSetValue(null); } else { setValue(null, true); } } } else { setValue(newDate, true); } } } } }