List of usage examples for java.util List contains
boolean contains(Object o);
From source file:Main.java
/** * If there are an equal amount of items in both sets and every string in a is contained in b, the sets are equal. * //from ww w .j a va 2s. com * @param a First list. * @param b Second list. * @return True if sets are equal, false if not. */ protected static boolean areSetsEqual(List<String> a, List<String> b) { // If size is not equal, sets cannot be equal. if (a.size() != b.size()) return false; // If every element of a is contained in b, then sets are equal. boolean equal = true; for (String s : a) { if (!b.contains(s)) { equal = false; break; } } return equal; }
From source file:aiai.ai.launchpad.experiment.ExperimentUtils.java
private static boolean alreadyExists(List<HyperParams> allPaths, HyperParams hyper, String key, String value) { String path = hyper.path + ',' + key + ':' + value; return allPaths.contains(new HyperParams(Consts.EMPTY_UNMODIFIABLE_MAP, path)); }
From source file:nl.surfnet.coin.selfservice.filter.SpringSecurityUtil.java
protected static void assertRoleIsNotGranted(CoinAuthority.Authority... expectedAuthorities) { CoinUser user = SpringSecurity.getCurrentUser(); List<CoinAuthority.Authority> actualAuthorities = user.getAuthorityEnums(); for (CoinAuthority.Authority expectedAuthority : expectedAuthorities) { assertFalse("Role not to be expected: " + expectedAuthority, actualAuthorities.contains(expectedAuthorities)); }/* w w w. ja v a 2s .c om*/ }
From source file:eu.freme.bpt.Main.java
/** * Finds and removes the service from the arguments array. This helps * processing the rest of the parameters using the Apache Commons CLI * library (and thus needs to be called before processing the arguments). * * @param args The arguments of the program. * @param services The list of registered services. * @return The service name if found, or {@code null} if not found. */// w w w .ja v a2 s .c om private static Pair<EService, String[]> extractService(String[] args, final List<String> services) { EService foundService = null; List<String> newArgs = new ArrayList<>(args.length); for (String arg : args) { if (!services.contains(arg)) { newArgs.add(arg); } else { String serviceName = arg.toUpperCase().replace('-', '_'); foundService = EService.valueOf(serviceName); } } return new Pair<>(foundService, newArgs.toArray(new String[newArgs.size()])); }
From source file:Main.java
public static String[] filterRoom(List<String> longRoomList, String buildingNumber, String floorNumber, String prefix) {//from ww w. jav a 2 s. c o m if (longRoomList == null) { return null; } List<String> room_info = new ArrayList<String>(); for (int i = 0; i < longRoomList.size(); ++i) { String[] slice = longRoomList.get(i).split("-"); if (slice.length == 4 && slice[0].equals(buildingNumber) && slice[1].equals(floorNumber) && !room_info.contains(prefix + slice[2])) { room_info.add(prefix + slice[2]); } } return listToArray(room_info); }
From source file:com.github.fengtan.sophie.beans.Config.java
/** * Add a Solr server to favorites listed in the properties file. * /*www.j av a2 s.c o m*/ * @param favorite * The new favorite (either a Solr URL or a ZooKeeper host). */ public static void addFavorite(String favorite) { try { Configuration configuration = getConfiguration(); List<Object> favorites = configuration.getList("favorites"); // If the server is already listed in the favorites, then do // nothing. if (!favorites.contains(favorite)) { configuration.addProperty("favorites", favorite); } } catch (ConfigurationException e) { // Silently do not add the favorite and log the exception. Sophie.log.warn("Unable to add favorite to configuration file: " + favorite, e); } }
From source file:YexTool.java
private static boolean isValidImpId(OpenRtb.BidResponse.SeatBid.Bid bid, List<String> impIds) { boolean valid = impIds.contains(bid.getImpid()); if (!valid) { logger.warn("Imp id is invalid! Bid: \n" + bid); }// w ww.j a v a2 s . c o m return valid; }
From source file:com.smash.revolance.ui.comparator.page.PageMatchMaker.java
public static PageBean findPageByContentValue(Collection<PageBean> pages, List<String> contentValues) { for (PageBean page : pages) { List<String> pageContentValues = getContentValue(page.getContent()); for (String value : contentValues) { if (pageContentValues.contains(value)) { pageContentValues.remove(value); }//from w w w. j a v a 2s . co m if (pageContentValues.isEmpty()) { break; } } if (pageContentValues.isEmpty()) { return page; } } return null; }
From source file:Main.java
/** * @param context// w w w.j av a2 s.co m * @param packageName * @return */ public static boolean isAvilible(Context context, String packageName) { final PackageManager packageManager = context.getPackageManager(); List<PackageInfo> packageInfos = packageManager.getInstalledPackages(0); packageManager.getInstalledApplications(packageManager.GET_META_DATA); List<String> packageNames = new ArrayList<String>(); if (packageInfos != null) { for (int i = 0; i < packageInfos.size(); i++) { String packName = packageInfos.get(i).packageName; packageNames.add(packName); } } return packageNames.contains(packageName); }
From source file:Main.java
private static String compareFileLists(List<String> expected, List<String> gotten) { StringBuilder sb = new StringBuilder( "Expected (" + expected.size() + "): \t\t Gotten (" + gotten.size() + "):\n"); List<String> notFound = new ArrayList<String>(); for (String s : expected) { if (gotten.contains(s)) sb.append(s + "\t\t" + s + "\n"); else//from ww w .j a va2 s .c o m notFound.add(s); } sb.append("Not Found:\n"); for (String s : notFound) { sb.append(s + "\n"); } sb.append("\nExtra:\n"); for (String s : gotten) { if (!expected.contains(s)) sb.append(s + "\n"); } return sb.toString(); }