List of usage examples for java.util List contains
boolean contains(Object o);
From source file:net.sf.jabref.logic.util.io.FileUtil.java
/** * Converts a relative filename to an absolute one, if necessary. Returns * null if the file does not exist.<br/> * <p>/*from w ww. ja v a 2s . c om*/ * Uses <ul> * <li>the default directory associated with the extension of the file</li> * <li>the standard file directory</li> * <li>the directory of the bib file</li> * </ul> * * @param databaseContext The database this file belongs to. * @param name The filename, may also be a relative path to the file */ public static Optional<File> expandFilename(final BibDatabaseContext databaseContext, String name) { Optional<String> extension = getFileExtension(name); // Find the default directory for this field type, if any: List<String> directories = databaseContext.getFileDirectory(extension.orElse(null)); // Include the standard "file" directory: List<String> fileDir = databaseContext.getFileDirectory(); // Include the directory of the bib file: List<String> al = new ArrayList<>(); for (String dir : directories) { if (!al.contains(dir)) { al.add(dir); } } for (String aFileDir : fileDir) { if (!al.contains(aFileDir)) { al.add(aFileDir); } } return expandFilename(name, al); }
From source file:eu.europa.esig.dss.DSSRevocationUtils.java
/** * This method indicates if the given revocation token is present in the CRL * or OCSP response list./*from www. ja v a2 s .c o m*/ * * @param revocationToken * revocation token to be checked * @param basicOCSPResponses * list of basic OCSP responses * @return true if revocation token is present in one of the lists */ public static boolean isTokenIn(final RevocationToken revocationToken, final List<BasicOCSPResp> basicOCSPResponses) { if ((revocationToken instanceof OCSPToken) && (basicOCSPResponses != null)) { final BasicOCSPResp basicOCSPResp = ((OCSPToken) revocationToken).getBasicOCSPResp(); final boolean contains = basicOCSPResponses.contains(basicOCSPResp); return contains; } return false; }
From source file:forge.card.BoosterGenerator.java
public static List<PaperCard> getBoosterPack(SealedProduct.Template template) { List<PaperCard> result = new ArrayList<>(); List<PrintSheet> sheetsUsed = new ArrayList<>(); CardEdition edition = StaticData.instance().getEditions().get(template.getEdition()); boolean hasFoil = edition != null && !template.getSlots().isEmpty() && MyRandom.getRandom().nextDouble() < edition.getFoilChanceInBooster() && edition.getFoilType() != FoilType.NOT_SUPPORTED; boolean foilAtEndOfPack = hasFoil && edition.getFoilAlwaysInCommonSlot(); String foilSlot = !hasFoil ? null : foilAtEndOfPack ? BoosterSlots.COMMON : Aggregates.random(template.getSlots()).getKey(); String extraFoilSheetKey = edition != null ? edition.getAdditionalSheetForFoils() : ""; for (Pair<String, Integer> slot : template.getSlots()) { String slotType = slot.getLeft(); // add expansion symbol here? int numCards = slot.getRight(); String[] sType = TextUtil.splitWithParenthesis(slotType, ' '); String setCode = sType.length == 1 && template.getEdition() != null ? template.getEdition() : null; String sheetKey = StaticData.instance().getEditions().contains(setCode) ? slotType.trim() + " " + setCode : slotType.trim();// ww w . ja v a2s.co m boolean foilInThisSlot = hasFoil && slotType.startsWith(foilSlot); if (foilInThisSlot) numCards--; PrintSheet ps = getPrintSheet(sheetKey); result.addAll(ps.random(numCards, true)); sheetsUsed.add(ps); if (foilInThisSlot && !foilAtEndOfPack) { if (!extraFoilSheetKey.isEmpty()) { // TODO: extra foil sheets are currently reliably supported only for boosters with FoilAlwaysInCommonSlot=True. // If FoilAlwaysInCommonSlot is false, a card from the extra sheet may still replace a card in any slot. List<PaperCard> foilCards = new ArrayList<>(); for (PaperCard card : ps.toFlatList()) { if (!foilCards.contains(card)) { foilCards.add(card); } } addCardsFromExtraSheet(foilCards, sheetKey); result.add(generateFoilCard(foilCards)); } else { result.add(generateFoilCard(ps)); } } } if (hasFoil && foilAtEndOfPack) { List<PaperCard> foilCards = new ArrayList<>(); for (PrintSheet printSheet : sheetsUsed) { for (PaperCard card : printSheet.toFlatList()) { if (!foilCards.contains(card)) { foilCards.add(card); } } } if (!extraFoilSheetKey.isEmpty()) { addCardsFromExtraSheet(foilCards, extraFoilSheetKey); } result.add(generateFoilCard(foilCards)); } return result; }
From source file:com.github.dactiv.fear.service.commons.Configs.java
/** * {@link ValueEnum} ?? class ???//from w w w . j a v a2 s . c o m * * @param enumClass class * @param ignore ? * * @return key value ? Map ? */ public static List<Map<String, Object>> find(Class<? extends Enum<? extends ValueEnum<?>>> enumClass, List ignore) { List<Map<String, Object>> result = Lists.newArrayList(); Enum<? extends ValueEnum<?>>[] values = enumClass.getEnumConstants(); for (Enum<? extends ValueEnum<?>> o : values) { ValueEnum<?> ve = (ValueEnum<?>) o; Object value = ve.getValue(); if (ignore != null && !ignore.contains(value)) { Map<String, Object> dictionary = Maps.newHashMap(); dictionary.put(DEFAULT_VALUE_NAME, value); dictionary.put(DEFAULT_KEY_NAME, ve.getName()); result.add(dictionary); } } return result; }
From source file:org.fao.fenix.wds.core.utils.olap.OLAPWrapper.java
private static List<String> findAllAreas(List<List<String>> t, String element) { List<String> l = new ArrayList<String>(); int idx = 1;//from w w w .j ava 2 s . co m for (int i = 1; i < t.size(); i++) if (t.get(i).get(0).equalsIgnoreCase(element) && !l.contains(t.get(i).get(idx))) l.add(t.get(i).get(idx)); return l; }
From source file:com.stephenduncanjr.easymock.EasyMockPropertyUtils.java
/** * Gets the properties and values from the object as a map, ignoring the * properties specified.//from www . j a v a 2 s .co m * * @param bean * @param ignoredProperties * @return map of properties names to values. */ private static Map<String, Object> retrieveAndFilterProperties(final Object bean, final List<String> ignoredProperties) { final Map<String, Object> map = new HashMap<String, Object>(); try { for (final PropertyDescriptor p : PropertyUtils.getPropertyDescriptors(bean)) { if (!ignoredProperties.contains(p.getName()) && !"class".equals(p.getName())) { final Method readMethod = p.getReadMethod(); if (readMethod != null) { map.put(p.getName(), readMethod.invoke(bean)); } } } } catch (final IllegalAccessException e) { throw new IllegalArgumentException(e); } catch (final InvocationTargetException e) { throw new IllegalArgumentException(e); } return map; }
From source file:monasca.api.app.validation.NotificationMethodValidation.java
public static void validate(String type, String address, int period, List<Integer> validPeriods) { if (type.equals("EMAIL")) { if (!EmailValidator.getInstance(true).isValid(address)) throw Exceptions.unprocessableEntity("Address %s is not of correct format", address); }/*from w w w .j a v a2 s . c o m*/ if (type.equals("WEBHOOK")) { if (!URL_VALIDATOR.isValid(address)) throw Exceptions.unprocessableEntity("Address %s is not of correct format", address); if (period != 0 && !validPeriods.contains(period)) { throw Exceptions.unprocessableEntity("%d is not a valid period", period); } } if (period != 0 && !type.equals("WEBHOOK")) { throw Exceptions.unprocessableEntity("Period can not be non zero for %s", type); } }
From source file:org.fao.fenix.wds.core.utils.olap.OLAPWrapper.java
private static List<String> extractCodes(List<List<String>> table, int idx) throws WDSException { try {/*www. j a va 2 s . c o m*/ List<String> l = new ArrayList<String>(); for (int i = 1; i < table.size(); i++) { List<String> row = table.get(i); if (!l.contains(row.get(idx))) { l.add(row.get(idx)); } } return l; } catch (Exception e) { throw new WDSException(e.getMessage()); } }
From source file:com.manpowergroup.cn.core.utils.Struts2Utils.java
/** * JSON????listmapset//from w w w . j a v a 2s . co m * * @param object Java,json. * @see #render(String, String, String...) */ public static void renderJsonFilter(final Object object, final List<String> ignoreList, final String... headers) { JsonConfig config = new JsonConfig(); PropertyFilter filter = new PropertyFilter() { public boolean apply(Object source, String name, Object value) { if (ignoreList != null && ignoreList.contains(name)) { return true; } return false; } }; config.setJsonPropertyFilter(filter); String jsonString = JSONObject.fromObject(object, config).toString(); renderJson(jsonString, headers); }
From source file:com.github.stagirs.lingvo.build.Xml2Plain.java
private static List<Attr> fillAttributes(List<Attr> list, Matcher attrMatcher) { while (attrMatcher.find()) { String attr = attrMatcher.group(1).replace("-", "_"); if (Character.isDigit(attr.charAt(0))) { attr = "N" + attr; }//from ww w . j a va 2s . co m if (attr.toLowerCase().equals("ms_f")) { if (list.contains(Attr.femn)) { list.remove(Attr.femn); } if (list.contains(Attr.masc)) { list.remove(Attr.masc); } if (list.contains(Attr.neut)) { list.remove(Attr.neut); } if (list.contains(Attr.GNdr)) { list.remove(Attr.GNdr); } list.add(ms_f); continue; } Attr attrVal = Attr.valueOf(attr); if (attrVal == Attr.inan && list.contains(Attr.anim)) { continue; } if (attrVal == Attr.anim && list.contains(Attr.inan)) { list.remove(Attr.inan); } if (attrVal == Attr.femn || attrVal == Attr.masc || attrVal == Attr.neut || attrVal == Attr.GNdr) { if (list.contains(ms_f)) { continue; } } if (attrVal == Attr.loc1 || attrVal == Attr.loc2) { attrVal = Attr.loct; } if (attrVal == Attr.gent || attrVal == Attr.gen1 || attrVal == Attr.gen2) { if (list.get(0) == Attr.ADJS) { continue; } attrVal = Attr.gent; } if (attrVal == Attr.acc2) { attrVal = Attr.accs; } if (attrVal.getType() == Type.Other) { continue; } list.add(attrVal); } if (list.contains(Attr.Name) || list.contains(Attr.Surn) || list.contains(Attr.Patr)) { list.remove(Attr.inan); if (!list.contains(Attr.anim)) { list.add(Attr.anim); } } if (list.contains(Attr.VERB) && list.contains(Attr.Impe) && list.contains(Attr.neut)) { list.remove(Attr.neut); } return list; }