List of usage examples for java.util ArrayList addAll
public boolean addAll(Collection<? extends E> c)
From source file:Game.InteractionCase.java
public boolean process(Card c, String id) { if (reaction_only) { if (c.is_block()) { selectedSpecials.add(c);//from ww w . ja va 2 s . c om selectedIds.add(id); return true; } else return false; } String name = c.getName(); int cost = c.getCost(); if ((cost > maximum_cost) || (cost < minimum_cost)) return false; if (selectedSpecials.size() >= maximum_amount) return false; System.out.println("INCOMING INTERACTIONCASE REQUEST"); System.out.println("Cardname : " + c.getName() + " - " + "ID: " + id); System.out.println("======= ALLOWEDIDS ======"); for (String s : allowedIds) System.out.print(s + " , "); System.out.println("========================="); if (Character.isDigit(id.charAt(0))) { for (String s : selectedIds) { if (s.startsWith(id.split("_")[0])) return false; } if (c instanceof ActionCard) { if (!action_hand_enabled) return false; } else if (c instanceof TreasureCard) { if (!treasure_hand_enabled) return false; } else if (c instanceof VictoryCard) { if (!victory_hand_enabled) return false; } } else { ArrayList<String> nextallowedids = new ArrayList<>(); nextallowedids.addAll(allowedIds); boolean allowed = false; for (String s : allowedIds) { if (id.startsWith(s)) { allowed = true; nextallowedids.remove(s); break; } } if (c instanceof ActionCard) { if (!action_env_enabled) return false; } else if (c instanceof TreasureCard) { if (!treasure_env_enabled) return false; } else if (c instanceof VictoryCard) { if (!victory_env_enabled) return false; } if (!allowed) return false; else allowedIds = nextallowedids; } System.out.println("INTERACTIONCASE PROCESSING FINISHED."); System.out.println("===== LEAVING CASE WITH ALLOWED IDS: ========"); for (String s : allowedIds) System.out.println(s + " , "); System.out.println("==============================================="); // If this code is reached, all validations have passed, and nothing returned false. selectedSpecials.add(c); selectedIds.add(id); return true; }
From source file:com.magnet.mmx.server.plugin.mmxmgmt.api.tags.MMXUserTagsResourceTest.java
@Test public void testSetGetDelTags() throws Exception { String username = Helper.removeSuffix(userEntityList.get(0).getUsername(), "%"); List<String> tagList1 = Arrays.asList("tag1", "tag2", "tag3"); List<String> tagList2 = Arrays.asList("tag4", "tag5", "tag6"); //set tags 1// ww w . java 2s . c om { Response setResp = setTags(username, tagList1); assertEquals(Response.Status.CREATED.getStatusCode(), setResp.getStatus()); setResp.close(); } //set tags2 { Response setResp = setTags(username, tagList2); assertEquals(Response.Status.CREATED.getStatusCode(), setResp.getStatus()); setResp.close(); } //get the tags { Response getResp = getTags(username); assertEquals(Response.Status.OK.getStatusCode(), getResp.getStatus()); String jsonString = getResp.readEntity(String.class); ArrayList<String> newList = new ArrayList<String>(); newList.addAll(tagList1); newList.addAll(tagList2); validateContainsTags(jsonString, username, tagList1); } /** * delete one tag */ { Response delResp = deleteTag(username, "tag1"); assertEquals(delResp.getStatus(), Response.Status.OK.getStatusCode()); delResp.close(); } { Response getResp = getTags(username); assertEquals(Response.Status.OK.getStatusCode(), getResp.getStatus()); String jsonString = getResp.readEntity(String.class); ArrayList<String> newList = new ArrayList<String>(); newList.addAll(tagList1); newList.addAll(tagList2); newList.remove("tag1"); validateContainsTags(jsonString, username, newList); validateNotContainsTags(jsonString, username, Arrays.asList("tag1")); getResp.close(); } /** * delete all tags */ { Response delResp = deleteAllTags(username); assertEquals(delResp.getStatus(), Response.Status.OK.getStatusCode()); delResp.close(); } //get the tags and check { Response getResp = getTags(username); assertEquals(Response.Status.OK.getStatusCode(), getResp.getStatus()); String jsonString = getResp.readEntity(String.class); ArrayList<String> newList = new ArrayList<String>(); newList.addAll(tagList1); newList.addAll(tagList2); validateNotContainsTags(jsonString, username, newList); getResp.close(); } }
From source file:com.amazon.dtasdk.v2.signature.Signer.java
/** * Trims out any headers that were not signed from the request to allow easier calculation of the signature for * verification.//from w ww . j a v a2s . c o m * * @param request * the request to remove headers from. * @param signedHeaders * the headers that should remain. */ protected void removeUnsignedHeaders(Request request, String[] signedHeaders) { // have to copy the header name set to avoid concurrent modification exception. ArrayList<String> headersList = new ArrayList<String>(); headersList.addAll(request.getHeaderNames()); for (String header : headersList) { boolean match = false; for (String signedHeader : signedHeaders) { if (signedHeader.equalsIgnoreCase(header)) { match = true; break; } } if (match) { continue; } request.removeHeader(header); } }
From source file:com.celements.blog.plugin.NewsletterReceivers.java
List<String[]> getNewsletterReceiversList() { ArrayList<String[]> allUserMailPairs = new ArrayList<String[]>(); allUserMailPairs.addAll(groupUsers); allUserMailPairs.addAll(users);// w ww . j av a 2s .com //TODO use webUtilsServices as soon as available String defaultLanguage = getDefaultLanguage(); for (String address : addresses) { String mailUser = "XWiki.XWikiGuest"; String language = defaultLanguage; String addrUser = null; try { addrUser = userNameForUserDataCmd.getUsernameForUserData(address, "email", getContext()); } catch (XWikiException e) { LOGGER.error("Exception getting username for user email '" + address + "'.", e); } if ((addrUser != null) && (addrUser.length() > 0)) { mailUser = addrUser; language = getUserAdminLanguage(mailUser, defaultLanguage); } allUserMailPairs.add(new String[] { mailUser, address, language }); } return allUserMailPairs; }
From source file:de.adorsys.forge.gwt.GWTPlugin.java
private void executeCommand(final PipeOut out, String command, String... a) { final ArrayList<String> args = new ArrayList<String>(); args.add(command);/*from w ww . j a va 2 s . co m*/ if (a != null) { args.addAll(Arrays.asList(a)); } final MavenCoreFacet maven = project.getFacet(MavenCoreFacet.class); maven.executeMaven(out, args.toArray(new String[args.size()])); }
From source file:org.pshow.ecm.content.metadata.DefaultContetntSchemaHolder.java
private List<NamespaceDef> loadNamespacesFromDB() { ArrayList<NamespaceDef> namespaces = new ArrayList<NamespaceDef>(); namespaces.addAll(convertNamespace(namespaceDao.findAll())); return namespaces; }
From source file:com.miserablemind.api.consumer.tradeking.api.impl.response_entities.TKAllWatchListsResponse.java
@JsonSetter("watchlists") @SuppressWarnings("unchecked") public void setWatchLists(LinkedHashMap<String, Object> watchListsResponse) { ArrayList<String> resultList = new ArrayList<>(); Object list = watchListsResponse.get("watchlist"); ArrayList<LinkedHashMap<String, String>> itemList = new ArrayList<>(); if (list.getClass() == ArrayList.class) { //we know from condition this is right itemList = (ArrayList) list; } else {/*from w ww. ja v a 2 s . c om*/ itemList.add((LinkedHashMap) watchListsResponse.get("watchlist")); } resultList.addAll(itemList.stream().map(item -> item.get("id")).collect(Collectors.toList())); this.watchLists = new String[resultList.size()]; this.watchLists = resultList.toArray(this.watchLists); }
From source file:com.velonuboso.made.core.rat.RatNameHelper.java
private ArrayList<String> namesFromList(String resourceName) { ArrayList<String> ret = new ArrayList<String>(); URL url = this.getClass().getClassLoader().getResource(resourceName); String str = ""; try {/*from w w w . ja v a2s . c o m*/ str = getText(url); } catch (Exception ex) { Logger.getLogger(RatNameHelper.class.getName()).log(Level.SEVERE, null, ex); } String[] names = str.split("\n"); ret.addAll(Arrays.asList(names)); return ret; }
From source file:com.hmsinc.epicenter.webapp.remoting.AnalysisService.java
/** * @param paramsDTO//from ww w .j a v a2 s.co m * @return */ @Secured("ROLE_USER") @Transactional(readOnly = true) @RemoteMethod @SuppressWarnings("unchecked") public String getSummaryChart(final AnalysisParametersDTO paramsDTO) { final AnalysisParameters analysisParameters = convertParameters(paramsDTO); final Class<? extends Geography> aggregateType = (Class<? extends Geography>) ModelUtils .getRealClass(analysisParameters.getContainer()); final TimeSeriesCollection<? extends Geography, Classification> tsc = dataQueryService .query(analysisParameters, aggregateType); final TimeSeriesChart chart = new TimeSeriesChart(); chart.setType(ChartType.MOUNTAIN); chart.setYLabel("Number of Visits"); if (tsc.getPrimaryIndexes().contains(analysisParameters.getContainer())) { final Map<Classification, TimeSeries> tsm = tsc.getMaps().get(analysisParameters.getContainer()); // Sort the map by the max value in the timeseries. final ArrayList<Classification> keys = new ArrayList<Classification>(); keys.addAll(tsm.keySet()); Collections.sort(keys, new Comparator<Classification>() { public int compare(Classification o1, Classification o2) { return new CompareToBuilder().append(tsm.get(o2).getMaxValue(), tsm.get(o1).getMaxValue()) .toComparison(); } }); int i = 0; for (Classification c : keys) { if (!"Other".equals(c.getName())) { chart.add(c.getName(), tsm.get(c)); i++; if (i > 6) { break; } } } } return chartService.getChartURL(chart); }
From source file:info.magnolia.security.app.dialog.action.SaveRoleDialogAction.java
private Permission findBestMatchingPermissions(List<Permission> permissions, String path) { if (permissions == null) { return null; }//w ww. j a v a 2 s .co m Permission bestMatch = null; long permission = 0; int patternLength = 0; ArrayList<Permission> temp = new ArrayList<Permission>(); temp.addAll(permissions); for (Permission p : temp) { if (p.match(path)) { int l = p.getPattern().getLength(); if (patternLength == l && (permission < p.getPermissions())) { permission = p.getPermissions(); bestMatch = p; } else if (patternLength < l) { patternLength = l; permission = p.getPermissions(); bestMatch = p; } } } return bestMatch; }