Java Code Examples for java.util.List#remove()
The following examples show how to use
java.util.List#remove() .
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: BaseSpringRestTestCase.java From flowable-engine with Apache License 2.0 | 8 votes |
/** * Checks if the returned "data" array (child-node of root-json node returned by invoking a GET on the given url) contains entries with the given ID's. */ protected void assertResultsPresentInDataResponse(String url, String... expectedResourceIds) throws JsonProcessingException, IOException { int numberOfResultsExpected = expectedResourceIds.length; // Do the actual call CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + url), HttpStatus.SC_OK); // Check status and size JsonNode dataNode = objectMapper.readTree(response.getEntity().getContent()).get("data"); closeResponse(response); assertThat(dataNode).hasSize(numberOfResultsExpected); // Check presence of ID's List<String> toBeFound = new ArrayList<>(Arrays.asList(expectedResourceIds)); Iterator<JsonNode> it = dataNode.iterator(); while (it.hasNext()) { String id = it.next().get("id").textValue(); toBeFound.remove(id); } assertThat(toBeFound).as("Not all expected ids have been found in result, missing: " + StringUtils.join(toBeFound, ", ")).isEmpty(); }
Example 2
Source File: AutoBalaurMarchingRouteInstance.java From aion-germany with GNU General Public License v3.0 | 6 votes |
@Override public void onEnterInstance(Player player) { super.onEnterInstance(player); List<Player> playersByRace = getPlayersByRace(player.getRace()); playersByRace.remove(player); if (playersByRace.size() == 1 && !playersByRace.get(0).isInGroup2()) { PlayerGroup newGroup = PlayerGroupService.createGroup(playersByRace.get(0), player, TeamType.AUTO_GROUP); int groupId = newGroup.getObjectId(); if (!instance.isRegistered(groupId)) { instance.register(groupId); } } else if (!playersByRace.isEmpty() && playersByRace.get(0).isInGroup2()) { PlayerGroupService.addPlayer(playersByRace.get(0).getPlayerGroup2(), player); } Integer object = player.getObjectId(); if (!instance.isRegistered(object)) { instance.register(object); } }
Example 3
Source File: ComWorkflowValidationService.java From openemm with GNU Affero General Public License v3.0 | 6 votes |
private boolean searchLoops(List<Integer> sawingNodes, WorkflowNode node) { boolean hasLoops; List<WorkflowNode> nextNodes = node.getNextNodes(); int nextNodesSize = nextNodes.size(); for (int i = 0; i < nextNodesSize; i++) { WorkflowNode nextNode = nextNodes.get(i); WorkflowIcon nextNodeIcon = nextNode.getNodeIcon(); if (sawingNodes.contains(nextNodeIcon.getId())) { return true; } sawingNodes.add(nextNodeIcon.getId()); node.deleteNextNode(nextNode); nextNode.deletePrevNode(node); i--; hasLoops = searchLoops(sawingNodes, nextNode); sawingNodes.remove(new Integer(nextNodeIcon.getId())); if (hasLoops) { return true; } nextNodesSize = nextNodes.size(); } return false; }
Example 4
Source File: Drain.java From qpid-proton-j with Apache License 2.0 | 6 votes |
public static void main(String[] argv) throws Exception { List<String> switches = new ArrayList<String>(); List<String> args = new ArrayList<String>(); for (String s : argv) { if (s.startsWith("-")) { switches.add(s); } else { args.add(s); } } boolean quiet = switches.contains("-q"); String address = args.isEmpty() || !args.get(0).startsWith("/") ? "//localhost" : args.remove(0); int count = args.isEmpty() ? 1 : Integer.parseInt(args.remove(0)); boolean block = switches.contains("-b"); Collector collector = Collector.Factory.create(); Drain drain = new Drain(count, block, quiet); Driver driver = new Driver(collector, drain); Pool pool = new Pool(collector); pool.incoming(address, null); driver.run(); }
Example 5
Source File: TraversalStrategies.java From tinkerpop with Apache License 2.0 | 6 votes |
static void visit(final Map<Class<? extends TraversalStrategy>, Set<Class<? extends TraversalStrategy>>> dependencyMap, final List<Class<? extends TraversalStrategy>> sortedStrategyClasses, final Set<Class<? extends TraversalStrategy>> seenStrategyClases, final List<Class<? extends TraversalStrategy>> unprocessedStrategyClasses, Class<? extends TraversalStrategy> strategyClass) { if (seenStrategyClases.contains(strategyClass)) { throw new IllegalStateException("Cyclic dependency between traversal strategies: [" + seenStrategyClases + ']'); } if (unprocessedStrategyClasses.contains(strategyClass)) { seenStrategyClases.add(strategyClass); for (Class<? extends TraversalStrategy> dependency : MultiMap.get(dependencyMap, strategyClass)) { visit(dependencyMap, sortedStrategyClasses, seenStrategyClases, unprocessedStrategyClasses, dependency); } seenStrategyClases.remove(strategyClass); unprocessedStrategyClasses.remove(strategyClass); sortedStrategyClasses.add(strategyClass); } }
Example 6
Source File: ComSupervisorServiceImpl.java From openemm with GNU Affero General Public License v3.0 | 6 votes |
@Override public List<Integer> getAllowedCompanyIds(int supervisorId) { try { final Supervisor supervisor = supervisorDao.getSupervisor(supervisorId); List<Integer> ids = supervisorDao.getAllowedCompanyIDs(supervisorId); if(supervisor.getDepartment() != null && !supervisor.getDepartment().isSupervisorBindingToCompany0Allowed()) { ids.remove(Integer.valueOf(ALL_COMPANIES_ID)); // Boxing to Integer needed, otherwise we will remove item at index } if (ids.contains(ALL_COMPANIES_ID)) { return Collections.singletonList(ALL_COMPANIES_ID); } return ids; } catch(final SupervisorException e) { return Collections.emptyList(); } }
Example 7
Source File: ConfigManageService.java From wind-im with Apache License 2.0 | 6 votes |
@Override public boolean deleteUserDefaultFriends(String siteUserId) { boolean result = false; String defaultFriends = SiteConfigDao.getInstance().getDefaultUserFriends(); if (StringUtils.isNotEmpty(defaultFriends)) { String[] friends = defaultFriends.split(","); List<String> friendList = ArraysUtils.asList(friends); if (friendList.contains(siteUserId)) { friendList.remove(siteUserId); String newFriends = listToString(friendList, ","); result = SiteConfigDao.getInstance().updateDefaultUserFriends(newFriends); SiteConfig.updateConfig(); } } return result; }
Example 8
Source File: ProposerSelectorTest.java From besu with Apache License 2.0 | 6 votes |
@Test public void whenProposerSelfRemovesSelectsNextProposerInLineEvenWhenSticky() { final long PREV_BLOCK_NUMBER = 2; final ConsensusRoundIdentifier roundId = new ConsensusRoundIdentifier(PREV_BLOCK_NUMBER + 1, 0); final Address localAddr = AddressHelpers.ofValue(10); // arbitrarily selected // LocalAddr will be in index 2 - the next proposer will also be in 2 (as prev proposer is // removed) final List<Address> validatorList = createValidatorList(localAddr, 2, 2); validatorList.remove(localAddr); // Note the signer of the Previous block was not included. final Blockchain blockchain = createMockedBlockChainWithHeadOf(PREV_BLOCK_NUMBER, localAddr, validatorList); final ProposerSelector uut = new ProposerSelector(blockchain, blockInterface, false, voteTallyCache); assertThat(uut.selectProposerForRound(roundId)).isEqualTo(validatorList.get(2)); }
Example 9
Source File: LatestDeriver.java From envelope with Apache License 2.0 | 6 votes |
@Override public Dataset<Row> derive(Map<String, Dataset<Row>> dependencies) { String rowNumberFieldName = "_row_number"; Dataset<Row> dependency = getStepDataFrame(dependencies); WindowSpec windowSpec; if (keyFieldNames.size() > 1) { List<String> keyFieldNamesTail = Lists.newArrayList(keyFieldNames); keyFieldNamesTail.remove(keyFieldNames.get(0)); windowSpec = Window.partitionBy(keyFieldNames.get(0), keyFieldNamesTail.toArray(new String[0])); } else { windowSpec = Window.partitionBy(keyFieldNames.get(0)); } windowSpec = windowSpec.orderBy(functions.desc(timestampFieldName)); return dependency .withColumn(rowNumberFieldName, functions.row_number().over(windowSpec)) .filter(functions.col(rowNumberFieldName).equalTo(1)) .drop(rowNumberFieldName); }
Example 10
Source File: SubscriptionMgr.java From cloudstack with Apache License 2.0 | 5 votes |
public <T> void unsubscribe(String subject, T subscriber, String listenerMethod) { synchronized (this) { List<SubscriberInfo> l = getSubscriberList(subject); if (l != null) { for (SubscriberInfo info : l) { if (info.isMe(subscriber.getClass(), subscriber, listenerMethod)) { l.remove(info); return; } } } } }
Example 11
Source File: ProductFilterUtils.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
private boolean filterPreparationWithoutPrescription(String cnk, List<MaxSetProductType> products, MaxSetProductType product, PropertyHandler property) throws IntegrationModuleException { LOG.debug("Incoming into filter: " + cnk); boolean removed = false; ProductFilterSingleton pfs = ProductFilterSingleton.getInstance(); if (StringUtils.isEmpty(pfs.getPrecedence())) { pfs.setPrecedence("black"); } if (pfs.getPrecedence().toLowerCase().equals("black")) { if (pfs.isBlacklistedPreparation(cnk)) { if (!pfs.isWhitelistedPreparation(cnk)) { LOG.debug("Incoming into filter: " + cnk + " is blacklisted"); removed = products.remove(product); LOG.info("Product with dguid " + product.getDispensationGUID() + " removed from SMC, ProductFilter"); } } } else if (pfs.getPrecedence().toLowerCase().equals("white")) { if (!pfs.isWhitelistedPreparation(cnk) || pfs.isBlacklistedPreparation(cnk)) { LOG.debug("Incoming into filter: " + cnk + " is blacklisted or not whitelisted"); removed = products.remove(product); LOG.info("Product with dguid " + product.getDispensationGUID() + " removed from SMC, ProductFilter"); } } else { throw new IntegrationModuleException(I18nHelper.getLabel("prescencetype.unknown")); } LOG.debug("Outgoing filter: " + cnk); return removed; }
Example 12
Source File: BusSupport.java From Tangram-Android with MIT License | 5 votes |
/** * Unregister an event subscriber * @param eventHandler event subscriber wrapper */ public synchronized void unregister(@NonNull EventHandlerWrapper eventHandler) { String type = eventHandler.type; List<EventHandlerWrapper> handlers = subscribers.get(type); if (handlers != null) { handlers.remove(eventHandler); } }
Example 13
Source File: PreviewAdd.java From data-prep with Apache License 2.0 | 5 votes |
/** * @see PreviewAbstract#run() */ @Override protected InputStream run() throws Exception { final Map<String, Action> originalActionsByStep = new LinkedHashMap<>(); String dataSetId = addParameters.getDatasetId(); // get preparation details to initialize actions list if (StringUtils.isNotBlank(addParameters.getPreparationId())) { dataSetId = preparation.getDataSetId(); // Get steps from first transformation final List<String> steps = preparation.getSteps(); steps.remove(0); // extract actions by steps in chronological order, until defined last active step (from input) final Iterator<Action> iterator = actions.iterator(); steps.stream().filter(step -> iterator.hasNext()).forEach( step -> originalActionsByStep.put(step, iterator.next())); } final Collection<Action> originalActions = originalActionsByStep.values(); // modify actions to include the update final List<Action> modifiedActions = new ArrayList<>(originalActions); modifiedActions.addAll(addParameters.getActions()); // execute transformation preview with content and the 2 transformations setContext(originalActions, modifiedActions, dataSetId, addParameters.getPreparationId(), addParameters.getTdpIds(), addParameters.getSourceType()); return super.run(); }
Example 14
Source File: ActionHandler.java From ankush with GNU Lesser General Public License v3.0 | 5 votes |
/** * The main method. * * @param args the arguments */ public static void main(String... args) { // Get action id String actionId = args[0]; // Create action by id Actionable obj = ActionFactory.getInstanceById(actionId); // remove first element(action id) from array List<String> argsList = new ArrayList<String>(Arrays.asList(args)); argsList.remove(0); // Call execute on Actionable object obj.execute(argsList); }
Example 15
Source File: HSSFWorkbook.java From lams with GNU General Public License v2.0 | 5 votes |
/** * This is basically a kludge to deal with the now obsolete Label records. If * you have to read in a sheet that contains Label records, be aware that the rest * of the API doesn't deal with them, the low level structure only provides read-only * semi-immutable structures (the sets are there for interface conformance with NO * Implementation). In short, you need to call this function passing it a reference * to the Workbook object. All labels will be converted to LabelSST records and their * contained strings will be written to the Shared String table (SSTRecord) within * the Workbook. * * @param records a collection of sheet's records. * @param offset the offset to search at * @see org.apache.poi.hssf.record.LabelRecord * @see org.apache.poi.hssf.record.LabelSSTRecord * @see org.apache.poi.hssf.record.SSTRecord */ private void convertLabelRecords(List<Record> records, int offset) { if (log.check( POILogger.DEBUG )) { log.log(POILogger.DEBUG, "convertLabelRecords called"); } for (int k = offset; k < records.size(); k++) { Record rec = records.get(k); if (rec.getSid() == LabelRecord.sid) { LabelRecord oldrec = ( LabelRecord ) rec; records.remove(k); LabelSSTRecord newrec = new LabelSSTRecord(); int stringid = workbook.addSSTString(new UnicodeString(oldrec.getValue())); newrec.setRow(oldrec.getRow()); newrec.setColumn(oldrec.getColumn()); newrec.setXFIndex(oldrec.getXFIndex()); newrec.setSSTIndex(stringid); records.add(k, newrec); } } if (log.check( POILogger.DEBUG )) { log.log(POILogger.DEBUG, "convertLabelRecords exit"); } }
Example 16
Source File: LayoutPosition.java From netbeans with Apache License 2.0 | 4 votes |
private static InSequence getSequentialPosition(LayoutInterval interval, int dimension, int alignment) { LayoutInterval neighbor = null; boolean snapped = false; PaddingType paddingType = null; LayoutInterval gap = LayoutInterval.getNeighbor(interval, alignment, false, true, false); if (gap != null && LayoutInterval.isFixedDefaultPadding(gap)) { LayoutInterval prev = LayoutInterval.getDirectNeighbor(gap, alignment^1, true); if (prev == interval || LayoutInterval.isPlacedAtBorder(interval, prev, dimension, alignment)) { LayoutInterval next = LayoutInterval.getNeighbor(gap, alignment, true, true, false); if (next != null) { if (next.getParent() == gap.getParent() || next.getCurrentSpace().positions[dimension][alignment^1] == gap.getParent().getCurrentSpace().positions[dimension][alignment]) { // the next interval is really at preferred distance neighbor = next; paddingType = gap.getPaddingType(); } } else { // likely next to the root group border next = LayoutInterval.getRoot(interval); if (LayoutInterval.isPlacedAtBorder(gap.getParent(), next, dimension, alignment)) { neighbor = next; } } } } if (neighbor != null) { snapped = true; } else { neighbor = LayoutInterval.getNeighbor(interval, alignment, true, true, false); } List<LayoutInterval> neighbors; if (neighbor != null && !neighbor.isParentOf(interval)) { LayoutInterval first = LayoutUtils.getOutermostComponent(neighbor, dimension, alignment^1); neighbors = LayoutUtils.getSideComponents(neighbor, alignment^1, false, false); if (first != null) { neighbors.remove(first); neighbors.add(0, first); } if (neighbors.isEmpty()) { neighbors = null; } } else { neighbors = null; } InSequence seqPos = new InSequence(); seqPos.componentNeighbors = neighbors; seqPos.snapped = snapped; seqPos.paddingType = paddingType; seqPos.fixedRelativePosition = isFixedRelativePosition(interval, alignment); return seqPos; }
Example 17
Source File: RandomSubsetTaxaParser.java From beast-mcmc with GNU Lesser General Public License v2.1 | 4 votes |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { Taxa originalTaxa = new Taxa(); for (int i = 0; i < xo.getChildCount(); i++) { Object child = xo.getChild(i); if (child instanceof Taxon) { Taxon taxon = (Taxon)child; originalTaxa.addTaxon(taxon); } else if (child instanceof TaxonList) { TaxonList taxonList1 = (TaxonList)child; for (int j = 0; j < taxonList1.getTaxonCount(); j++) { originalTaxa.addTaxon(taxonList1.getTaxon(j)); } } else { throwUnrecognizedElement(xo); } } List<Taxon> originalTaxonList = originalTaxa.asList(); int sampleTotal = xo.getAttribute(COUNT, originalTaxonList.size()); if (sampleTotal < 2) { throw new XMLParseException("Must sample atleast two taxa"); } boolean withReplacement = xo.getAttribute(WITH_REPLACEMENT, false); Taxa sampledTaxa = new Taxa(); for (int i = 0; i < sampleTotal; i++) { int choice = MathUtils.nextInt(originalTaxonList.size()); Taxon taxonToAdd = originalTaxonList.get(choice); sampledTaxa.addTaxon(taxonToAdd); if (!withReplacement) { originalTaxonList.remove(choice); } } return sampledTaxa; }
Example 18
Source File: TxFunctionImpl.java From fabric-chaincode-java with Apache License 2.0 | 4 votes |
/** * New TxFunction Definition Impl. * * @param m Reflect method object * @param contract ContractDefinition this is part of */ public TxFunctionImpl(final Method m, final ContractDefinition contract) { this.method = m; if (m.getAnnotation(Transaction.class) != null) { logger.debug("Found Transaction method: " + m.getName()); if (m.getAnnotation(Transaction.class).submit()) { this.type = TransactionType.INVOKE; } else { this.type = TransactionType.QUERY; } final String txnName = m.getAnnotation(Transaction.class).name(); if (!txnName.isEmpty()) { this.name = txnName; } } if (name == null) { this.name = m.getName(); } // create the routing object that defines how to get the data to the transaction // function. this.routing = new RoutingImpl(m, contract); // set the return schema this.returnSchema = TypeSchema.typeConvert(m.getReturnType()); // parameter processing final List<java.lang.reflect.Parameter> params = new ArrayList<java.lang.reflect.Parameter>( Arrays.asList(method.getParameters())); // validate the first one is a context object if (!Context.class.isAssignableFrom(params.get(0).getType())) { throw new ContractRuntimeException( "First argument should be of type Context " + method.getName() + " " + params.get(0).getType()); } else { params.remove(0); } // FUTURE: if ever the method of creating the instance where to change, // the routing could be changed here, a different implementation could be made // here encapsulating the change. eg use an annotation to define where the // context goes for (final java.lang.reflect.Parameter parameter : params) { final TypeSchema paramMap = new TypeSchema(); final TypeSchema schema = TypeSchema.typeConvert(parameter.getType()); final Property annotation = parameter.getAnnotation(org.hyperledger.fabric.contract.annotation.Property.class); if (annotation != null) { final String[] userSupplied = annotation.schema(); for (int i = 0; i < userSupplied.length; i += 2) { schema.put(userSupplied[i], userSupplied[i + 1]); } } paramMap.put("name", parameter.getName()); paramMap.put("schema", schema); final ParameterDefinition pd = new ParameterDefinitionImpl(parameter.getName(), parameter.getClass(), paramMap, parameter); paramsList.add(pd); } }
Example 19
Source File: CCacheInputStream.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public PrincipalName readPrincipal(int version) throws IOException, RealmException { int type, length, namelength, kret; String[] pname = null; String realm; /* Read principal type */ if (version == KRB5_FCC_FVNO_1) { type = KRB5_NT_UNKNOWN; } else { type = read(4); } length = readLength4(); List<String> result = new ArrayList<String>(); /* * DCE includes the principal's realm in the count; the new format * does not. */ if (version == KRB5_FCC_FVNO_1) length--; for (int i = 0; i <= length; i++) { namelength = readLength4(); byte[] bytes = IOUtils.readFully(this, namelength, true); result.add(new String(bytes)); } if (result.isEmpty()) { throw new IOException("No realm or principal"); } if (isRealm(result.get(0))) { realm = result.remove(0); if (result.isEmpty()) { throw new IOException("No principal name components"); } return new PrincipalName( type, result.toArray(new String[result.size()]), new Realm(realm)); } try { return new PrincipalName( type, result.toArray(new String[result.size()]), Realm.getDefault()); } catch (RealmException re) { return null; } }
Example 20
Source File: Dpl1000ServiceImpl.java From oslits with GNU General Public License v3.0 | 4 votes |
/** * Dpl1000 배포 계획 삭제 * @param param - Map * @return * @exception Exception */ @SuppressWarnings({ "rawtypes", "unchecked" }) public void deleteDpl1000DeployVerInfo(Map paramMap) throws Exception{ List<Map<String,String>> list = (List<Map<String,String>>) paramMap.get("list"); //prjId String prjId = (String)paramMap.get("prjId"); int listSize = list.size(); List<AutoBuildVO> autoList = GlobalDplListVO.getDplList(); for (int i = 0; i < listSize; i++) { Map<String,String> dplMap = list.get(i); dplMap.put("prjId", prjId); //배포 Id String dplId = dplMap.get("dplId"); //배포 계획 삭제 dpl1000DAO.deleteDpl1000DeployVerInfo(dplMap); //해당 배포에 스케줄러 있는지 체크 for(int j=0;j<autoList.size();j++){ AutoBuildVO autoInfo = autoList.get(j); //자동 배포 prjId,dplId String targetPrjId = autoInfo.getPrjId(); String targetDplId = autoInfo.getDplAutoAfterCd(); //prjId, dplId check if(prjId.equals(targetPrjId) && dplId.equals(targetDplId)){ //timer 종료 Timer timer = autoInfo.getAutoDplTimer(); timer.cancel(); //해당 자동배포 info 제거 autoList.remove(j); break; } } } }