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:Main.java

public static void setFocusMode(Camera mCamera, Context item, int type) {
    Camera.Parameters params = mCamera.getParameters();
    List<String> FocusModes = params.getSupportedFocusModes();

    switch (type) {
    case 0:/* w  w  w  . j  a v a  2  s .  c om*/
        if (FocusModes.contains(Camera.Parameters.FOCUS_MODE_AUTO))
            params.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
        else
            Toast.makeText(item, "Auto Mode not supported", Toast.LENGTH_SHORT).show();
        break;
    case 1:
        if (FocusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO))
            params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
        else
            Toast.makeText(item, "Continuous Mode not supported", Toast.LENGTH_SHORT).show();
        break;
    case 2:
        if (FocusModes.contains(Camera.Parameters.FOCUS_MODE_EDOF))
            params.setFocusMode(Camera.Parameters.FOCUS_MODE_EDOF);
        else
            Toast.makeText(item, "EDOF Mode not supported", Toast.LENGTH_SHORT).show();
        break;
    case 3:
        if (FocusModes.contains(Camera.Parameters.FOCUS_MODE_FIXED))
            params.setFocusMode(Camera.Parameters.FOCUS_MODE_FIXED);
        else
            Toast.makeText(item, "Fixed Mode not supported", Toast.LENGTH_SHORT).show();
        break;
    case 4:
        if (FocusModes.contains(Camera.Parameters.FOCUS_MODE_INFINITY))
            params.setFocusMode(Camera.Parameters.FOCUS_MODE_INFINITY);
        else
            Toast.makeText(item, "Infinity Mode not supported", Toast.LENGTH_SHORT).show();
        break;
    case 5:
        if (FocusModes.contains(Camera.Parameters.FOCUS_MODE_MACRO))
            params.setFocusMode(Camera.Parameters.FOCUS_MODE_MACRO);
        else
            Toast.makeText(item, "Macro Mode not supported", Toast.LENGTH_SHORT).show();
        break;
    }

    mCamera.setParameters(params);
}

From source file:Main.java

public static <T extends Comparator<T>> List<T> intersection(List<T> array1, List<T> array2) {
    if (isEmpty(array1) || isEmpty(array2)) {
        return null;
    }/*from w w  w. j ava  2  s  . c o m*/
    List<T> targets = new ArrayList<T>();
    for (T item : array1) {
        if (array2.contains(item)) {
            targets.add(item);
        }
    }
    return targets;
}

From source file:ReflectionHelper.java

/**
 * Get all superclasses and interfaces recursively.
 *
 * @param clazz The class to start the search with.
 * @param classes List of classes to which to add all found super classes and interfaces.
 */// w w w  . j av a  2 s .  c  o  m
private static void computeClassHierarchy(Class<?> clazz, List<Class<?>> classes) {
    for (Class current = clazz; current != null; current = current.getSuperclass()) {
        if (classes.contains(current)) {
            return;
        }
        classes.add(current);
        for (Class currentInterface : current.getInterfaces()) {
            computeClassHierarchy(currentInterface, classes);
        }
    }
}

From source file:Main.java

/**
 * Disables component and all of its children recursively.
 *
 * @param component       component to disable
 * @param startFromChilds whether should disable only component childs or not
 * @param excludePanels   whether should exclude panels from disabling or not
 * @param excluded        components to exclude from disabling
 * @param disabled        list of actually disabled components
 *///  w  w  w . ja  va 2 s  .c  om
private static void disableRecursively(final Component component, final boolean startFromChilds,
        final boolean excludePanels, final List<Component> excluded, final List<Component> disabled) {
    final boolean b = !startFromChilds && !excluded.contains(component)
            && !(component instanceof JPanel && excludePanels);
    if (b && component.isEnabled()) {
        component.setEnabled(false);
        disabled.add(component);
    }
    if (component instanceof Container) {
        if (b && isHandlesEnableState(component)) {
            return;
        }
        final Container container = (Container) component;
        for (final Component child : container.getComponents()) {
            disableRecursively(child, false, excludePanels, excluded, disabled);
        }
    }
}

From source file:net.datenwerke.transloader.ClassWrapper.java

private static boolean classIsAssignableToType(Class rootClass, String typeName) {
    List allClasses = new ArrayList();
    allClasses.add(rootClass);//  w  w w  .  ja v  a  2s  .c om
    allClasses.addAll(ClassUtils.getAllSuperclasses(rootClass));
    allClasses.addAll(ClassUtils.getAllInterfaces(rootClass));
    List allClassNames = ClassUtils.convertClassesToClassNames(allClasses);
    return allClassNames.contains(typeName);
}

From source file:com.screenslicer.core.util.StringUtil.java

public static List<String> join(List<String> list1, List<String> list2) {
    List<String> list = new ArrayList<String>();
    for (String cur : list1) {
        if (!list.contains(cur)) {
            list.add(cur);/*from  w  w w  .ja v  a2s  . c o  m*/
        }
    }
    for (String cur : list2) {
        if (!list.contains(cur)) {
            list.add(cur);
        }
    }
    return list;
}

From source file:Main.java

/**
 * @param dom/*from  w w  w  . j  a  v a 2 s  . c om*/
 *            The dom string.
 * @param pos
 *            Position where to start searching.
 * @param element
 *            The element.
 * @return the position where the close element is
 */
public static int getCloseElementLocation(String dom, int pos, String element) {
    String[] elements = { "LINK", "META", "INPUT", "BR" };
    List<String> singleElements = Arrays.asList(elements);
    if (singleElements.contains(element.toUpperCase())) {
        return dom.indexOf('>', pos) + 1;
    }
    // make sure not before the node
    int openElements = 1;
    int i = 0;
    int position = pos;
    String dom_lower = dom.toLowerCase();
    String element_lower = element.toLowerCase();
    String openElement = "<" + element_lower;
    String closeElement = "</" + element_lower;
    while (i < MAX_SEARCH_LOOPS) {
        if (dom_lower.indexOf(openElement, position) == -1 && dom_lower.indexOf(closeElement, position) == -1) {
            return -1;
        }
        if (dom_lower.indexOf(openElement, position) < dom_lower.indexOf(closeElement, position)
                && dom_lower.indexOf(openElement, position) != -1) {
            openElements++;
            position = dom_lower.indexOf(openElement, position) + 1;
        } else {

            openElements--;
            position = dom_lower.indexOf(closeElement, position) + 1;
        }
        if (openElements == 0) {
            break;
        }
        i++;
    }
    return position - 1;

}

From source file:ext.sns.auth.OAuth2Client.java

/**
 * ??URI/*from   ww w .  j  ava 2 s.c o m*/
 * 
 * @param providerName ?????
 * @param type ???nullempty
 * @param callbackParam ??null
 * @param specialParamKey ?Key?providerkey???????null
 * @return ?URI
 */
public static String getAuthRequestURI(String providerName, String type, Map<String, String> callbackParam,
        String specialParamKey) {
    if (StringUtils.isBlank(providerName)) {
        throw new IllegalArgumentException("??providerString=" + providerName);
    }

    List<String> providerList = ConfigManager.getProviderNameByTypes(type);
    if (!providerList.contains(providerName)) {
        throw new IllegalArgumentException("?providerNametypeproviderName = "
                + providerName + " ,type = " + type + ".");
    }
    callbackParam.put(ConfigManager.TYPE_KEY, type);

    ProviderConfig providerConfig = ConfigManager.getProviderConfigByName(providerName);
    String requestAuthFullURI = providerConfig.getRequestAuthFullURI(callbackParam, specialParamKey);

    LOGGER.debug("requestAuthFullURI:" + requestAuthFullURI);
    return requestAuthFullURI;
}

From source file:Main.java

/**
 * Makes an intersection betwwen both of the given lists.<br/>
 * The result contains unique values.//from  www .j ava 2  s . c o  m
 * @param list1 the first list.
 * @param list2 the second list.
 * @param <T>
 * @return the intersection between the two lists.
 */
public static <T> List<T> intersection(List<T> list1, List<T> list2) {
    List<T> list = new ArrayList<T>(new LinkedHashSet<T>(list1));
    Iterator<T> iterator = list.iterator();
    while (iterator.hasNext()) {
        if (!list2.contains(iterator.next())) {
            iterator.remove();
        }
    }
    return list;
}

From source file:jackrabbit.repository.RepositoryManager.java

public static List<String> getDestinationWorkspaces(Session src, Session dest)
        throws IOException, RepositoryException {
    List<String> wsNames = new ArrayList<String>();
    List<String> srcWorkpaces = Arrays.asList(src.getWorkspace().getAccessibleWorkspaceNames());
    List<String> destWorkpaces = Arrays.asList(dest.getWorkspace().getAccessibleWorkspaceNames());

    for (String workspace : srcWorkpaces) {
        if (!destWorkpaces.contains(workspace)) {
            dest.getWorkspace().createWorkspace(workspace);
        }//from  w ww . j  a  va2  s  .  c  om
        wsNames.add(workspace);
    }
    wsNames.remove(DEFAULT_WORKSPACE);
    wsNames.remove(SECURITY_WORKSPACE);
    return wsNames;
}