Example usage for java.util List contains

List of usage examples for java.util List contains

Introduction

In this page you can find the example usage for java.util List contains.

Prototype

boolean contains(Object o);

Source Link

Document

Returns true if this list contains the specified element.

Usage

From source file:com.bluexml.side.clazz.service.alfresco.CommonServices.java

public static List<EObject> getNSL(Model node) throws Exception {
    List<EObject> l = new ArrayList<EObject>();

    List<String> prel = new ArrayList<String>();
    // add alfresco prefix that must be excluded
    List<EObject> fl = getAllExternalReference(node);

    for (EObject eObject : fl) {
        String prefix = CommonServices.getPrefix(eObject);
        if (!prel.contains(prefix)) {
            l.add(eObject);//from   w ww .j  a  v a2  s.c  om
            prel.add(prefix);
        }
    }

    return l;
}

From source file:com.none.tom.simplerssreader.feed.CurrentFeed.java

public static List<Integer> getCategoriesPositions(final List<String> categories) {
    final List<Integer> positions = new ArrayList<>();

    int i = 1;//from  www. j av a2 s . c  o m

    for (final SyndEntry entry : sCurrentFeed.getEntries()) {
        for (final SyndCategory category : entry.getCategories()) {
            if (categories.contains(category.getName()) && !positions.contains(i)) {
                positions.add(i);
            }
        }
        i++;
    }

    Collections.sort(positions);

    return positions;
}

From source file:Main.java

public static Size getMaxPreviewSize(List<Size> sizes, List<Size> vSize) {
    if (sizes == null) {
        return null;
    }//from  w w  w . j  av  a2 s.  c  o m

    Size optimalSize = null;
    int maxHeight = 0;
    int maxWidth = 0;

    for (Size size : sizes) {
        if (size.height > maxHeight) {
            if (vSize == null) {
                optimalSize = size;
                maxHeight = size.height;
                maxWidth = size.width;
                continue;
            }

            if (vSize.contains(size)) {
                optimalSize = size;
                maxHeight = size.height;
                maxWidth = size.width;
            }
        } else if (size.width > maxWidth) {
            if (vSize == null) {
                optimalSize = size;
                maxWidth = size.width;
                continue;
            }

            if (vSize.contains(size)) {
                optimalSize = size;
                maxWidth = size.width;
            }
        }
    }

    Log.e(TAG, "width:" + optimalSize.width + "height:" + optimalSize.height);
    return optimalSize;
}

From source file:com.esofthead.mycollab.common.interceptor.aspect.AuditLogUtil.java

static public String getChangeSet(Object oldObj, Object newObj, List<String> excludeFields,
        boolean isSelective) {
    Class cl = oldObj.getClass();
    List<AuditChangeItem> changeItems = new ArrayList<>();

    try {/* w  w  w .  j  a va2s .  c o m*/
        BeanInfo beanInfo = Introspector.getBeanInfo(cl, Object.class);

        for (PropertyDescriptor propertyDescriptor : beanInfo.getPropertyDescriptors()) {
            String fieldName = propertyDescriptor.getName();
            if (excludeFields.contains(fieldName)) {
                continue;
            }
            String oldProp = getValue(PropertyUtils.getProperty(oldObj, fieldName));

            Object newPropVal;
            try {
                newPropVal = PropertyUtils.getProperty(newObj, fieldName);
            } catch (Exception e) {
                continue;
            }
            String newProp = getValue(newPropVal);

            if (!oldProp.equals(newProp)) {
                if (isSelective && newProp.equals("")) {
                } else {
                    AuditChangeItem changeItem = new AuditChangeItem();
                    changeItem.setField(fieldName);
                    changeItem.setNewvalue(newProp);
                    changeItem.setOldvalue(oldProp);
                    changeItems.add(changeItem);
                }
            }
        }
    } catch (Exception e) {
        LOG.error("There is error when convert changeset", e);
        return null;
    }

    return (changeItems.size() > 0) ? JsonDeSerializer.toJson(changeItems) : null;
}

From source file:com.github.gavlyukovskiy.boot.jdbc.decorator.flexypool.FlexyPoolConfiguration.java

static <T extends DataSource> List<ConnectionAcquiringStrategyFactory<?, T>> mergeFactories(
        List<ConnectionAcquiringStrategyFactory<?, T>> factories, FlexyPoolProperties flexyPool) {
    List<ConnectionAcquiringStrategyFactory<?, T>> newFactories = new ArrayList<>();
    List<? extends Class<?>> factoryClasses;
    if (factories != null) {
        factoryClasses = factories.stream().map(Object::getClass).collect(Collectors.toList());
        newFactories.addAll(factories);//from  w w w  . ja va  2  s . c  om
    } else {
        factoryClasses = Collections.emptyList();
    }
    if (!factoryClasses.contains(IncrementPoolOnTimeoutConnectionAcquiringStrategy.Factory.class)) {
        IncrementPool incrementPool = flexyPool.getAcquiringStrategy().getIncrementPool();
        if (incrementPool.getMaxOverflowPoolSize() > 0) {
            newFactories.add(new IncrementPoolOnTimeoutConnectionAcquiringStrategy.Factory<>(
                    incrementPool.getMaxOverflowPoolSize(), incrementPool.getTimeoutMillis()));
        }
    }
    if (!factoryClasses.contains(RetryConnectionAcquiringStrategy.Factory.class)) {
        Retry retry = flexyPool.getAcquiringStrategy().getRetry();
        if (retry.getAttempts() > 0) {
            newFactories.add(new RetryConnectionAcquiringStrategy.Factory<>(retry.getAttempts()));
        }
    }
    return newFactories;
}

From source file:esiptestbed.mudrod.ontology.process.LocalOntology.java

protected static void renderHierarchy(PrintStream out, OntClass cls, List occurs, int depth) {
    renderClassDescription(out, cls, depth);
    out.println();//from w w  w.  j a v  a  2 s  .  c o  m

    // recurse to the next level down
    if (cls.canAs(OntClass.class) && !occurs.contains(cls)) {
        for (Iterator i = cls.listSubClasses(true); i.hasNext();) {
            OntClass sub = (OntClass) i.next();

            // we push this expression on the occurs list before we recurse
            occurs.add(cls);
            renderHierarchy(out, sub, occurs, depth + 1);
            occurs.remove(cls);
        }
        for (Iterator i = cls.listInstances(); i.hasNext();) {
            Individual individual = (Individual) i.next();
            renderURI(out, individual.getModel(), individual.getURI());
            out.print(" [");
            for (Iterator j = individual.listLabels(null); j.hasNext();) {
                out.print(((Literal) j.next()).getString() + ", ");
            }
            out.print("] ");
            out.println();
        }
    }
}

From source file:nl.minbzk.dwr.zoeken.enricher.notifier.DirectResultCache.java

/**
 * Since we don't really have a better way to quickly verify integrity, we resort to doing it this way.
 * //www .j  av  a  2  s  . co m
 * @return boolean
 */
public static boolean validateNotifierProfileModelIntegrity() {
    final List<String> notifierProfileInternalFields = Arrays.asList(new String[] { "uuid", "email",
            "emailLanguage", "query", "searchParameters", "notificationInterval", "notificationMaximum" });

    for (Field nodeField : com.seajas.search.attender.bridge.wsdl.profile.NotifierProfile.class
            .getDeclaredFields())
        if (!notifierProfileInternalFields.contains(nodeField.getName())) {
            logger.error("Unable to account for field '" + nodeField.getName() + "' in NotifierProfile");

            return false;
        }

    return true;
}

From source file:gov.nih.nci.protexpress.util.ManageProtAppInputOutputHelper.java

/**
 * Removes potential duplicate inputs from the list.
 *
 * @param lstInputs the protocol application inputs.
 * @param lstPotentialInputs the list of potential inputs.
 *///from  w  w  w  . j a va  2  s.c o  m
private static void removeDuplicateInputs(List<InputOutputObject> lstInputs,
        List<InputOutputObject> lstPotentialInputs) {
    ListIterator<InputOutputObject> iterPAInputs = lstInputs.listIterator();
    while (iterPAInputs.hasNext()) {
        InputOutputObject currentInput = iterPAInputs.next();
        if ((currentInput.getId() != null) && !StringUtils.isBlank(currentInput.getId().toString())
                && lstPotentialInputs.contains(currentInput)) {
            lstPotentialInputs.remove(currentInput);
        }
    }
}

From source file:lucee.commons.i18n.FormatUtil.java

private static boolean check(List<DateFormat> list, String p, Locale locale, String from, String to) {
    int index = p.indexOf(from);
    if (index != -1) {
        p = StringUtil.replace(p, from, to, true);
        SimpleDateFormat sdf = new SimpleDateFormat(p, locale);
        if (!list.contains(sdf))
            list.add(sdf);// www .  j  av  a 2 s .  co  m
        return true;
    }
    return false;
}

From source file:com.hg.development.apps.messagenotifier_v1.Utils.Utility.java

/**
 * Permet de supprimer les doublons dans la liste des numros d'un contact.
 * @param duplicatelist Map contenant l'id du contact et le numro correspondant.
 * @return la liste des numros d'un contact sans doublons.
 *///from w  w w  . j  av a  2 s  . c o  m
public static List<com.hg.development.apps.messagenotifier_v1.Contact.Person.Number> removeNumbersDuplicated(
        Map<String, Number> duplicatelist) {
    try {
        List<com.hg.development.apps.messagenotifier_v1.Contact.Person.Number> list = new ArrayList<>();

        Set set = duplicatelist.entrySet();
        Iterator i = set.iterator();

        while (i.hasNext()) {
            Map.Entry me = (Map.Entry) i.next();

            Number number = (Number) me.getValue();

            if (!list.contains(number))
                list.add((Number) me.getValue());
        }

        return list;
    } catch (Exception ex) {
        throw ex;
    }
}