List of usage examples for java.util List contains
boolean contains(Object o);
From source file:com.hg.development.apps.messagenotifier_v1.Utils.Utility.java
/** * Permet de supprimer les doublons dans la liste des contacts. * @param duplicatelist Map contenant le nom de chaque contact. * @return la liste des contacts sans doublons. *///from ww w . j a v a 2s .co m public static List<LocalContact> removeContactsDuplicated(Map<String, LocalContact> duplicatelist) { try { List<LocalContact> list = new ArrayList<>(); Set set = duplicatelist.entrySet(); Iterator i = set.iterator(); while (i.hasNext()) { Map.Entry me = (Map.Entry) i.next(); LocalContact contact = (LocalContact) me.getValue(); if (!list.contains((contact))) list.add(contact); } return list; } catch (Exception ex) { throw ex; } }
From source file:com.geewhiz.pacify.utils.ArchiveUtils.java
private static LinkedHashMap<PArchive, List<PArchive>> getParentArchives(List<PFile> replacePFiles) { LinkedHashMap<PArchive, List<PArchive>> parentArchives = new LinkedHashMap<PArchive, List<PArchive>>(); // for performance get first all archives in an archive for (PFile pFile : replacePFiles) { if (!pFile.isArchiveFile()) { continue; }/*from w w w.j a v a 2 s .c o m*/ PArchive pArchive = pFile.getPArchive(); if (!pArchive.isArchiveFile()) { continue; } if (!parentArchives.containsKey(pArchive.getParentArchive())) { parentArchives.put(pArchive.getParentArchive(), new ArrayList<PArchive>()); } List<PArchive> pArchivesToReplace = parentArchives.get(pArchive.getParentArchive()); if (!pArchivesToReplace.contains(pArchive)) { pArchivesToReplace.add(pArchive); } } return parentArchives; }
From source file:com.sixsq.slipstream.factory.DeploymentFactory.java
private static void insertNewRunParameterForNode(Run run, Node node, String name, String value, String description, List<String> ignore) throws ValidationException { if (ignore.contains(name)) { return;// w ww .j ava2 s. c om } String key = constructNodeParamName(node, name); RunParameter rp = new RunParameter(key, value, description); run.setParameter(rp); }
From source file:fr.paris.lutece.plugins.search.solr.indexer.SolrIndexerService.java
/** * Find the indexer of the resource parameter * @param strResourceName the name of the resource to index * @return the indexer of the resource/*from w w w .j a v a 2 s.c o m*/ */ private static SolrIndexer findSolrIndexer(String strResourceName) { for (SolrIndexer indexer : INDEXERS) { List<String> lstResources = indexer.getResourcesName(); if ((lstResources != null) && lstResources.contains(strResourceName)) { return indexer; } } return null; }
From source file:org.codehaus.mojo.license.utils.HttpRequester.java
/** * will download a external resource and read the content of the file that will then be translated into a * new list. <br>//w w w. j a v a 2 s .c o m * Lines starting with the character '#' will be omitted from the list <br> * <br> * <b>NOTE:</b><br> * certificate checking for this request will be disabled because some resources might be present on some * local servers in the internal network that do not use a safe connection * * @param url the URL to the external resource * @return a new list with all license entries from the remote resource */ public static List<String> downloadList(String url) throws MojoExecutionException { List<String> list = new ArrayList<>(); BufferedReader bufferedReader = null; try { bufferedReader = new BufferedReader(new CharArrayReader(getFromUrl(url).toCharArray())); String line; while ((line = bufferedReader.readLine()) != null) { if (StringUtils.isNotBlank(line)) { if (!StringUtils.startsWith(line, "#") && !list.contains(line)) { list.add(line); } } } } catch (IOException e) { throw new MojoExecutionException("could not open connection to URL: " + url, e); } finally { if (bufferedReader != null) { try { bufferedReader.close(); } catch (IOException e) { throw new MojoExecutionException(e.getMessage(), e); } } } return list; }
From source file:com.opengamma.financial.analytics.model.VegaMatrixUtils.java
/** * Returns a bucketed swaption vega cube with swaption expiry / swap maturity / distance from ATM axes. * @param fittedPoints The points in the swaption volatility cube, not null * @param matrices a map from swaption expiry to vega matrix, not null * @return A labelled vega cube/*w w w . ja v a 2 s . co m*/ */ public static DoubleLabelledMatrix3D getVegaSwaptionCubeQuoteMatrix( final Map<Pair<Tenor, Tenor>, Double[]> fittedPoints, final Map<Double, DoubleMatrix2D> matrices) { ArgumentChecker.notNull(fittedPoints, "fitted points"); ArgumentChecker.notNull(matrices, "matrices"); final List<Double> xKeysList = new ArrayList<>(); final List<Double> xLabelsList = new ArrayList<>(); final List<Double> yKeysList = new ArrayList<>(); final List<Tenor> yLabelsList = new ArrayList<>(); final List<Double> zKeysList = new ArrayList<>(); final List<Tenor> zLabelsList = new ArrayList<>(); for (final Entry<Pair<Tenor, Tenor>, Double[]> entry : fittedPoints.entrySet()) { final double swapMaturity = getTime(entry.getKey().getFirst()); if (!zKeysList.contains(swapMaturity)) { zKeysList.add(swapMaturity); zLabelsList.add(entry.getKey().getFirst()); } final double swaptionExpiry = getTime(entry.getKey().getSecond()); if (!yKeysList.contains(swaptionExpiry)) { yKeysList.add(swaptionExpiry); yLabelsList.add(entry.getKey().getSecond()); } if (xKeysList.size() == 0) { final Double[] relativeStrikesArray = entry.getValue(); for (final Double relativeStrike : relativeStrikesArray) { xKeysList.add(relativeStrike); xLabelsList.add(relativeStrike); } } } final Double[] xKeys = xKeysList.toArray(ArrayUtils.EMPTY_DOUBLE_OBJECT_ARRAY); final Double[] xLabels = xLabelsList.toArray(ArrayUtils.EMPTY_DOUBLE_OBJECT_ARRAY); final Double[] yKeys = yKeysList.toArray(ArrayUtils.EMPTY_DOUBLE_OBJECT_ARRAY); final Tenor[] yLabels = yLabelsList.toArray(new Tenor[yLabelsList.size()]); final Double[] zKeys = zKeysList.toArray(ArrayUtils.EMPTY_DOUBLE_OBJECT_ARRAY); final Tenor[] zLabels = zLabelsList.toArray(new Tenor[zLabelsList.size()]); final double[][][] values = new double[zKeys.length][xKeys.length][yKeys.length]; for (int i = 0; i < zKeys.length; i++) { values[i] = matrices.get(zKeys[i]).toArray(); } return new DoubleLabelledMatrix3D(xKeys, xLabels, yKeys, yLabels, zKeys, zLabels, values); }
From source file:com.turt2live.xmail.mail.attachment.Attachment.java
/** * Gets the receive text for a mail item (Eg: "You got 4 items!") * * @param mail the mail object//from w w w .ja va 2 s .com * @param failed the attachments that did not send to the player * * @return the text to send to the player (no colors) */ public static String getReceiveText(Mail mail, List<Attachment> failed) { double cod, money = cod = 0; int items = 0, unknown = 0; Map<Material, Integer> itemCount = new HashMap<Material, Integer>(); for (Attachment a : mail.getAttachments()) { if (!failed.contains(a)) { switch (a.getType()) { case MONEY: money += ((MoneyAttachment) a).getAmount(); break; case COD: cod += ((CODAttachment) a).getAmount(); break; case ITEM: ItemStack stack = ((ItemAttachment) a).getItemStack(); int c = 1; if (itemCount.containsKey(stack.getType())) { c += itemCount.get(stack.getType()); } itemCount.put(stack.getType(), c); items += stack.getAmount(); case MESSAGE: break; default: unknown++; break; } } } if (cod == 0 && money == 0 && items == 0 && unknown == 0) { return "You got no attachments!"; } StringBuilder message = new StringBuilder(); message.append("You "); if (cod > 0) { message.append("paid $").append(MoneyFormat.format(cod)).append(" in C.O.D and got "); } else { message.append("got "); } if (money > 0) { message.append("$").append(MoneyFormat.format(money)).append(", "); } if (items > 0) { if (itemCount.keySet().size() >= 30) { message.append(items).append(" items, "); } else { for (Material item : itemCount.keySet()) { message.append(itemCount.get(item)).append("x ").append(General.convertItem(item)).append(", "); } } } if (unknown > 0) { message.append(unknown).append(" other thing").append(unknown > 1 ? "s, " : ", "); } String msg = message.toString().trim(); return msg.substring(0, msg.length() - 1); }
From source file:kelly.util.BeanUtils.java
/** * Copy the property values of the given source bean into the given target bean. * <p>Note: The source and target classes do not have to match or even be derived * from each other, as long as the properties match. Any bean properties that the * source bean exposes but the target bean does not will silently be ignored. * @param source the source bean//from w w w . j av a2 s .c o m * @param target the target bean * @param editable the class (or interface) to restrict property setting to * @param ignoreProperties array of property names to ignore * @throws BeansException if the copying failed * @see BeanWrapper */ private static void copyProperties(Object source, Object target, Class<?> editable, String... ignoreProperties) { Validate.notNull(source, "Source must not be null"); Validate.notNull(target, "Target must not be null"); Class<?> actualEditable = target.getClass(); if (editable != null) { if (!editable.isInstance(target)) { throw new IllegalArgumentException("Target class [" + target.getClass().getName() + "] not assignable to Editable class [" + editable.getName() + "]"); } actualEditable = editable; } PropertyDescriptor[] targetPds = getPropertyDescriptors(actualEditable); List<String> ignoreList = (ignoreProperties != null) ? Arrays.asList(ignoreProperties) : null; for (PropertyDescriptor targetPd : targetPds) { Method writeMethod = targetPd.getWriteMethod(); if (writeMethod != null && (ignoreProperties == null || (!ignoreList.contains(targetPd.getName())))) { PropertyDescriptor sourcePd = getPropertyDescriptor(source.getClass(), targetPd.getName()); if (sourcePd != null) { Method readMethod = sourcePd.getReadMethod(); if (readMethod != null && writeMethod.getParameterTypes()[0].isAssignableFrom(readMethod.getReturnType())) { try { if (!Modifier.isPublic(readMethod.getDeclaringClass().getModifiers())) { readMethod.setAccessible(true); } Object value = readMethod.invoke(source); if (!Modifier.isPublic(writeMethod.getDeclaringClass().getModifiers())) { writeMethod.setAccessible(true); } writeMethod.invoke(target, value); } catch (Throwable ex) { throw new BeanException( "Could not copy property '" + targetPd.getName() + "' from source to target", ex); } } } } } }
From source file:com.sapienter.jbilling.server.metafields.MetaFieldHelper.java
/** * Usefull method for updating meta fields with validation before entity saving * @param entity target entity//www .ja v a2s . com * @param dto dto with new data */ public static void updateMetaFieldsWithValidation(Integer languageId, Integer entityId, Integer accountTypeId, MetaContent entity, MetaContent dto, Boolean global) { List<EntityType> entityTypes = new LinkedList(Arrays.asList(entity.getCustomizedEntityType())); if (entityTypes.contains(EntityType.ACCOUNT_TYPE)) { entityTypes.remove(EntityType.ACCOUNT_TYPE); } Map<String, MetaField> availableMetaFields = MetaFieldBL.getAvailableFields(entityId, entityTypes.toArray(new EntityType[entityTypes.size()])); for (String fieldName : availableMetaFields.keySet()) { MetaFieldValue newValue = dto.getMetaField(fieldName, null); MetaFieldValue prevValue = entity.getMetaField(fieldName, null); if (newValue == null) { // try to search by id, may be temp fix MetaField metaFieldName = availableMetaFields.get(fieldName); newValue = dto.getMetaField(metaFieldName.getId()); } // TODO: (VCA) - we want the null values for the validation // if ( null != newValue && null != newValue.getValue() ) { if (newValue != null) { entity.setMetaField(entityId, null, fieldName, newValue.getValue()); } else if ((global != null) && global.equals(Boolean.TRUE) && (prevValue != null)) { /* * if user edits a global category and retains its global scope * then don't filter out null meta-fields and retain previous values * */ entity.setMetaField(entityId, null, fieldName, prevValue.getValue()); } else { /* * if user edits a global category and marks it as non-global only then filter out null meta-fields * */ entity.setMetaField(entityId, null, fieldName, null); } // } //else { //no point creating null/empty-value records in db //} } // Updating and validating of ait meta fields is done in a separate method for (MetaFieldValue value : entity.getMetaFields()) { MetaFieldBL.validateMetaField(languageId, value.getField(), value, entity); } removeEmptyMetaFields(entity); }
From source file:com.hpe.application.automation.bamboo.tasks.TestResultHelperAlm.java
private static List<String> findRequiredStringsFromLog(BuildLogger logger, String searchFilter) { List<LogEntry> buildLog = Lists.reverse(logger.getBuildLog()); List<String> results = new ArrayList<String>(); for (LogEntry logEntry : buildLog) { String log = logEntry.getLog(); if (log.contains(searchFilter)) { int pathBegin = log.indexOf("td:"); if (pathBegin > -1) { String result = log.substring(pathBegin); if (!results.contains(result) && !savedALMRunLogPaths.contains(result)) { results.add(result); }//from w ww .j av a 2s .c o m } } } return results; }