List of usage examples for java.util Set remove
boolean remove(Object o);
From source file:models.NotificationEvent.java
public static NotificationEvent afterReviewed(PullRequest pullRequest, PullRequestReviewAction reviewAction) { String title = formatReplyTitle(pullRequest); Resource resource = pullRequest.asResource(); Set<User> receivers = pullRequest.getWatchers(); receivers.add(pullRequest.contributor); User reviewer = UserApp.currentUser(); receivers.remove(reviewer); NotificationEvent notiEvent = new NotificationEvent(); notiEvent.created = new Date(); notiEvent.title = title;/*from www. jav a2 s . c om*/ notiEvent.senderId = reviewer.id; notiEvent.receivers = receivers; notiEvent.resourceId = resource.getId(); notiEvent.resourceType = resource.getType(); notiEvent.eventType = EventType.PULL_REQUEST_REVIEW_STATE_CHANGED; notiEvent.oldValue = reviewAction.getOppositAction().name(); notiEvent.newValue = reviewAction.name(); add(notiEvent); return notiEvent; }
From source file:com.buaa.cfs.utils.StringUtils.java
/** * Splits a comma separated value <code>String</code>, trimming leading and trailing whitespace on each value. * Duplicate and empty values are removed. * * @param str a comma separated <String> with values * * @return a <code>Collection</code> of <code>String</code> values *//* w w w .j a v a 2 s . com*/ public static Collection<String> getTrimmedStringCollection(String str) { Set<String> set = new LinkedHashSet<String>(Arrays.asList(getTrimmedStrings(str))); set.remove(""); return set; }
From source file:com.google.enterprise.connector.importexport.ImportExport.java
/** * Imports a list of connectors. Replaces the existing connectors with the * connectors in {@code connectors}. For each connector in {@code connectors}, * update an existing connector if the connector names match or create a new * connector if it doesn't already exist. * Unless instructed otherwise, remove any existing connectors which are not * included in {@code connectors}./* w ww . j a v a 2s. c om*/ * * @param connectors a {@link ImportExportConnectorList} * @param noRemove {@code setConnectors} removes previous connectors * which are not included in {@code connectors} if and only if * {@code noremove} is {@code false}. */ static final void setConnectors(ImportExportConnectorList connectors, boolean noRemove) { Instantiator instantiator = Context.getInstance().getInstantiator(); Set<String> previousConnectorNames = new HashSet<String>(instantiator.getConnectorNames()); for (ImportExportConnector connector : connectors) { String name = connector.getName(); try { // Store the Configuration. boolean update = previousConnectorNames.contains(name); Configuration configuration = connector.getConfiguration(); ConfigureResponse configureResponse = instantiator.setConnectorConfiguration(name, configuration, Locale.ENGLISH, update); if (configureResponse != null) { LOGGER.warning( "setConnectorConfiguration(name=" + name + "\"): " + configureResponse.getMessage()); continue; } // Store the Schedule. instantiator.setConnectorSchedule(name, connector.getSchedule()); previousConnectorNames.remove(name); } catch (ConnectorNotFoundException e) { // This shouldn't happen. LOGGER.warning("Connector " + name + " not found!"); } catch (ConnectorExistsException e) { // This shouldn't happen. LOGGER.warning("Connector " + name + " already exists!"); } catch (ConnectorTypeNotFoundException e) { LOGGER.warning("Connector Type " + connector.getTypeName() + " not found!"); } catch (InstantiatorException e) { LOGGER.log(Level.WARNING, "Failed to create connector " + name + ": ", e); } } // Remove previous connectors which no longer exist. if (!noRemove) { for (String name : previousConnectorNames) { try { instantiator.removeConnector(name); } catch (InstantiatorException e) { LOGGER.log(Level.WARNING, "Failed to remove connector " + name + ": ", e); } } } }
From source file:de.tudarmstadt.ukp.experiments.argumentation.convincingness.svmlib.regression.SVMLibRegressionExperimentRunner.java
@Override public void runCrossValidation(File dataDir) throws IOException { Set<SinglePrediction> allPredictions = new HashSet<SinglePrediction>(); List<File> files = new ArrayList<File>(FileUtils.listFiles(dataDir, new String[] { "libsvm.txt" }, false)); for (File testFile : files) { // create training files from the rest Set<File> trainingFiles = new HashSet<File>(files); trainingFiles.remove(testFile); // System.out.println("Training files: " + trainingFiles); System.out.println("Training files size: " + trainingFiles.size()); System.out.println("Test file: " + testFile); Set<SinglePrediction> predictions = runSingleFold(testFile, new ArrayList<File>(trainingFiles)); allPredictions.addAll(predictions); }// w w w . j av a2 s.c o m List<SinglePrediction> predictions = new ArrayList<SinglePrediction>(allPredictions); double[][] matrix = new double[predictions.size()][]; for (int i = 0; i < predictions.size(); i++) { SinglePrediction prediction = predictions.get(i); matrix[i] = new double[2]; matrix[i][0] = Double.valueOf(prediction.getGold()); matrix[i][1] = Double.valueOf(prediction.getPrediction()); } PearsonsCorrelation pearsonsCorrelation = new PearsonsCorrelation(matrix); try { double pValue = pearsonsCorrelation.getCorrelationPValues().getEntry(0, 1); double correlation = pearsonsCorrelation.getCorrelationMatrix().getEntry(0, 1); System.out.println("Correlation: " + correlation); System.out.println("p-Value: " + pValue); System.out.println("Samples: " + predictions.size()); SpearmansCorrelation sc = new SpearmansCorrelation(new Array2DRowRealMatrix(matrix)); double pValSC = sc.getRankCorrelation().getCorrelationPValues().getEntry(0, 1); double corrSC = sc.getCorrelationMatrix().getEntry(0, 1); System.out.println("Spearman: " + corrSC + ", p-Val " + pValSC); } catch (MathException e) { throw new IOException(e); } }
From source file:org.ovirt.engine.api.common.util.DetailHelper.java
/** * Parses a string into the object that represents what to include. * * @param specs the specification of what to include or exclude * @return the set that represents what to include, which may be completely empty, but never * {@code null}//from w w w .ja va 2s . co m */ private static Set<String> parseDetails(List<String> specs) { // In most cases the user won't give any detail specification, so it is worth to avoid creating an expensive // set in that case: if (CollectionUtils.isEmpty(specs)) { return Collections.singleton(MAIN); } // If the user gave a detail specification then we need first to add the default value and then parse it: Set<String> details = new HashSet<>(2); details.add(MAIN); if (CollectionUtils.isNotEmpty(specs)) { for (String spec : specs) { if (spec != null) { String[] chunks = spec.split("(?=[+-])"); if (ArrayUtils.isNotEmpty(chunks)) { for (String chunk : chunks) { chunk = chunk.trim(); if (chunk.startsWith("+")) { chunk = chunk.substring(1).trim(); if (StringUtils.isNotEmpty(chunk)) { details.add(chunk); } } else if (chunk.startsWith("-")) { chunk = chunk.substring(1).trim(); if (StringUtils.isNotEmpty(chunk)) { details.remove(chunk); } } else { details.add(chunk); } } } } } } return details; }
From source file:org.gaixie.micrite.security.service.impl.AuthorityServiceImpl.java
public void unBindAuths(int[] authIds, int roleId) { Role role = roleDAO.get(roleId); for (int i = 0; i < authIds.length; i++) { Authority auth = authorityDAO.get(authIds[i]); Set<Role> roles = auth.getRoles(); roles.remove(role); auth.setRoles(roles);// w w w. j a v a2 s.co m } FilterSecurityInterceptor.refresh(); MethodSecurityInterceptor.refresh(); }
From source file:cc.kave.commons.pointsto.evaluation.OneMissingQueryBuilder.java
@Override public List<Query> createQueries(Usage in) { List<CallSite> receiverCallSites = new ArrayList<>(in.getReceiverCallsites()); if (receiverCallSites.isEmpty()) { return Collections.emptyList(); }//from ww w. ja v a 2 s . c o m int numQueries = Math.min(maxNumQueries, receiverCallSites.size()); Set<Set<CallSite>> queriesCallSites = new HashSet<>(numQueries); int iters = 0; while (queriesCallSites.size() < numQueries && iters < 100) { int missingIndex = rndGenerator.nextInt(receiverCallSites.size()); CallSite missingCallSite = receiverCallSites.get(missingIndex); Set<CallSite> newCallSites = new HashSet<>(in.getAllCallsites()); newCallSites.remove(missingCallSite); queriesCallSites.add(newCallSites); ++iters; } List<Query> queries = new ArrayList<>(maxNumQueries); for (Set<CallSite> callSites : queriesCallSites) { Query query = Query.createAsCopyFrom(in); query.setAllCallsites(callSites); queries.add(query); } return queries; }
From source file:it.cilea.osd.jdyna.event.GestoreEventi.java
/** * Annulla la sottoscrizione//from www.j av a 2 s . c o m **/ public <E extends IEvent> void removeSubscriber(ISubscriber subscriber, Class<E> eventClass) { // recupero l'elenco degli attuali subscribers per la tipologia di // evento Set<ISubscriber> eventSubscribers = subscribers.get(eventClass); eventSubscribers.remove(subscriber); }
From source file:de.tudarmstadt.ukp.experiments.argumentation.convincingness.svmlib.SVMLibExperimentRunner.java
public void runCrossValidation(File dataDir) throws IOException { List<File> files = new ArrayList<File>(FileUtils.listFiles(dataDir, new String[] { "libsvm.txt" }, false)); for (File testFile : files) { // create training files from the rest Set<File> trainingFiles = new HashSet<File>(files); trainingFiles.remove(testFile); // System.out.println("Training files: " + trainingFiles); System.out.println("Training files size: " + trainingFiles.size()); System.out.println("Test file: " + testFile); runSingleFold(testFile, new ArrayList<File>(trainingFiles)); }//from w w w .j ava2 s . c o m }
From source file:com.cimpoint.mes.server.repositories.EquipmentRepository.java
@Transactional public void remove(Long id, TrxInfo trxInfo) { EEquipment e = entityManager.find(entityClass, id); // detach from workcenter EWorkCenter wc = e.getWorkCenter();//from ww w . j av a 2s.co m Set<EEquipment> equipments = wc.getEquipments(); if (equipments != null) { equipments.remove(e); } e.setWorkCenter(null); super.remove(e, trxInfo); }