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:org.caratarse.auth.model.util.BeanUtils.java

/**
 * Copy the not-null property values of the given source bean into the given target bean.
 * <p>/*from  w  ww .ja  v  a2 s.com*/
 * 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
 * @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 copyNotNullProperties(Object source, Object target, Class<?> editable,
        String... ignoreProperties) throws BeansException {

    Assert.notNull(source, "Source must not be null");
    Assert.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 = org.springframework.beans.BeanUtils.getPropertyDescriptors(actualEditable);
    List<String> ignoreList = (ignoreProperties != null ? Arrays.asList(ignoreProperties) : null);

    for (PropertyDescriptor targetPd : targetPds) {
        Method writeMethod = targetPd.getWriteMethod();
        if (writeMethod != null && (ignoreList == null || !ignoreList.contains(targetPd.getName()))) {
            PropertyDescriptor sourcePd = org.springframework.beans.BeanUtils
                    .getPropertyDescriptor(source.getClass(), targetPd.getName());
            if (sourcePd != null) {
                Method readMethod = sourcePd.getReadMethod();
                if (readMethod != null && ClassUtils.isAssignable(writeMethod.getParameterTypes()[0],
                        readMethod.getReturnType())) {
                    try {
                        if (!Modifier.isPublic(readMethod.getDeclaringClass().getModifiers())) {
                            readMethod.setAccessible(true);
                        }
                        Object value = readMethod.invoke(source);
                        if (value == null) {
                            continue;
                        }
                        if (!Modifier.isPublic(writeMethod.getDeclaringClass().getModifiers())) {
                            writeMethod.setAccessible(true);
                        }
                        writeMethod.invoke(target, value);
                    } catch (Throwable ex) {
                        throw new FatalBeanException(
                                "Could not copy property '" + targetPd.getName() + "' from source to target",
                                ex);
                    }
                }
            }
        }
    }
}

From source file:org.fao.fenix.wds.core.utils.olap.OLAPWrapper.java

private static List<String> findAllElements(List<List<String>> t) {
    List<String> l = new ArrayList<String>();
    int idx = 0;//  w  w  w . j  av a  2s .c o m
    for (int i = 1; i < t.size(); i++)
        if (!l.contains(t.get(i).get(idx)))
            l.add(t.get(i).get(idx));
    return l;
}

From source file:com.bstek.dorado.core.pkgs.PackageManager.java

private static void pushPackageInfo(List<PackageInfo> calculatedPackages, PackageInfo packageInfo) {
    if (!calculatedPackages.contains(packageInfo)) {
        String packageName = packageInfo.getName();
        if (packageName.equals("dorado-hibernate") || packageName.equals("dorado-jdbc")) {
            calculatedPackages.add(1, packageInfo);
        } else {//  w  ww.j  a va2  s  . co  m
            calculatedPackages.add(packageInfo);
        }
    }
}

From source file:gov.nih.nci.caintegrator.common.PermissibleValueUtil.java

private static void checkObsolete(Collection<PermissibleValue> abstractPermissibleValues,
        List<String> newList) {
    List<PermissibleValue> removeList = new ArrayList<PermissibleValue>();
    for (PermissibleValue abstractPermissibleValue : abstractPermissibleValues) {
        if (newList == null || !newList.contains(abstractPermissibleValue.toString())) {
            removeList.add(abstractPermissibleValue);
        }/*from  w  ww.  j ava2s  .  c o  m*/
    }
    abstractPermissibleValues.removeAll(removeList);
}

From source file:com.zxy.commons.lang.utils.StringsUtils.java

/**
 * ?List,?// ww w .j a  v  a2  s. c om
 * 
 * @param source 
 * @param separator 
 * @return List?
 */
public static List<String> toUniqList(String source, String separator) {
    List<String> result = new ArrayList<String>();
    if (source != null) {
        List<String> tmps = toList(source, separator);
        for (String tmp : tmps) {
            if (!result.contains(tmp)) {
                result.add(tmp);
            }
        }
    }
    return result;
}

From source file:com.agiletec.plugins.jacms.aps.system.services.content.widget.ContentListHelper.java

protected static String buildCacheKey(String listName, Collection<String> userGroupCodes,
        RequestContext reqCtx) {/*from w ww.  j a v  a 2s .  c  o m*/
    IPage page = (IPage) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE);
    StringBuilder cacheKey = new StringBuilder(page.getCode());
    Widget currentWidget = (Widget) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_WIDGET);
    if (null != currentWidget) {
        cacheKey.append("_").append(currentWidget.getType().getCode());
    }
    Integer frame = (Integer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_FRAME);
    cacheKey.append("_").append(frame.intValue());
    Lang currentLang = (Lang) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_LANG);
    cacheKey.append("_LANG").append(currentLang.getCode()).append("_");
    List<String> groupCodes = new ArrayList<String>(userGroupCodes);
    if (!groupCodes.contains(Group.FREE_GROUP_NAME)) {
        groupCodes.add(Group.FREE_GROUP_NAME);
    }
    Collections.sort(groupCodes);
    for (int i = 0; i < groupCodes.size(); i++) {
        String code = (String) groupCodes.get(i);
        cacheKey.append("_").append(code);
    }
    if (null != currentWidget && null != currentWidget.getConfig()) {
        List<String> paramKeys = new ArrayList(currentWidget.getConfig().keySet());
        Collections.sort(paramKeys);
        for (int i = 0; i < paramKeys.size(); i++) {
            if (i == 0) {
                cacheKey.append("_WIDGETPARAM");
            } else {
                cacheKey.append(",");
            }
            String paramkey = (String) paramKeys.get(i);
            cacheKey.append(paramkey).append("=").append(currentWidget.getConfig().getProperty(paramkey));
        }
    }
    if (null != listName) {
        cacheKey.append("_LISTNAME").append(listName);
    }
    return cacheKey.toString();
}

From source file:Main.java

/**
 * <p>Obtains the list of locales to search through when performing
 * a locale search.</p>//from  w  w w  .  j  a va2 s .c o m
 *
 * <pre>
 * localeLookupList(Locale("fr", "CA", "xxx"), Locale("en"))
 *   = [Locale("fr","CA","xxx"), Locale("fr","CA"), Locale("fr"), Locale("en"]
 * </pre>
 *
 * <p>The result list begins with the most specific locale, then the
 * next more general and so on, finishing with the default locale.
 * The list will never contain the same locale twice.</p>
 *
 * @param locale  the locale to start from, null returns empty list
 * @param defaultLocale  the default locale to use if no other is found
 * @return the unmodifiable list of Locale objects, 0 being locale, not null
 */
public static List<Locale> localeLookupList(Locale locale, Locale defaultLocale) {
    List<Locale> list = new ArrayList<Locale>(4);
    if (locale != null) {
        list.add(locale);
        if (locale.getVariant().length() > 0) {
            list.add(new Locale(locale.getLanguage(), locale.getCountry()));
        }
        if (locale.getCountry().length() > 0) {
            list.add(new Locale(locale.getLanguage(), ""));
        }
        if (!list.contains(defaultLocale)) {
            list.add(defaultLocale);
        }
    }
    return Collections.unmodifiableList(list);
}

From source file:Main.java

public static void markItemsAsPro(ListPreference listPref, String[] labels, String[] values,
        List<String> proItems, String proWord) {

    List<String> labelsList = new ArrayList<String>(Arrays.asList(labels));
    List<String> valuesList = new ArrayList<String>(Arrays.asList(values));

    Iterator<String> it = valuesList.iterator();
    for (int i = 0; i < valuesList.size(); i++) {
        String value = valuesList.get(i);
        String label = labelsList.get(i);
        if (proItems.contains(value)) {
            labelsList.set(i, label + " " + proWord);
        }// w w w  .  j a  va 2  s. c  o  m
    }

    listPref.setEntries(labelsList.toArray(new String[1]));
    listPref.setEntryValues(valuesList.toArray(new String[1]));

}

From source file:it.cilea.osd.jdyna.web.tag.JDynATagLibraryFunctions.java

public static boolean isContainedList(Object object, List list) {
    return list == null ? false : list.contains(object);
}

From source file:com.opengamma.financial.analytics.model.VegaMatrixHelper.java

public static DoubleLabelledMatrix3D getVegaSwaptionCubeQuoteMatrixInStandardForm(
        final Map<Pair<Tenor, Tenor>, Double[]> fittedPoints, final Map<Double, DoubleMatrix2D> matrices) {
    final List<Double> xKeysList = new ArrayList<Double>();
    final List<Double> xLabelsList = new ArrayList<Double>();
    final List<Double> yKeysList = new ArrayList<Double>();
    final List<Tenor> yLabelsList = new ArrayList<Tenor>();
    final List<Double> zKeysList = new ArrayList<Double>();
    final List<Tenor> zLabelsList = new ArrayList<Tenor>();
    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());
        }/* ww w .ja v  a2  s . co  m*/
        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(EMPTY_TENOR_ARRAY);
    final Double[] zKeys = zKeysList.toArray(ArrayUtils.EMPTY_DOUBLE_OBJECT_ARRAY);
    final Tenor[] zLabels = zLabelsList.toArray(EMPTY_TENOR_ARRAY);
    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);
}