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.duracloud.duradmin.util.SpaceUtil.java

public static AclType resolveCallerAcl(String spaceId, ContentStore store, Map<String, AclType> acls,
        Authentication authentication, Boolean snapshotInProgress) throws ContentStoreException {
    //if a snapshot is in progress, read only
    // check authorities
    if (isRoot(authentication)) {
        return AclType.WRITE;
    }/*from  w w w. j a v  a  2 s . c  om*/

    if (snapshotInProgress == null) {
        snapshotInProgress = false;
        if (isSnapshotProvider(store)) {
            snapshotInProgress = isSnapshotInProgress(store, spaceId);
        }
    }

    if (spaceId.equals(Constants.SNAPSHOT_METADATA_SPACE)) {
        return AclType.READ;
    }

    if (snapshotInProgress) {
        return AclType.READ;
    }
    // check authorities
    if (isAdmin(authentication)) {
        return AclType.WRITE;
    }

    AclType callerAcl = null;

    DuracloudUserDetails details = (DuracloudUserDetails) authentication.getPrincipal();
    List<String> userGroups = details.getGroups();

    for (Map.Entry<String, AclType> e : acls.entrySet()) {
        AclType value = e.getValue();

        if (e.getKey().equals(details.getUsername()) || userGroups.contains(e.getKey())) {
            callerAcl = value;
            if (AclType.WRITE.equals(callerAcl)) {
                break;
            }
        }
    }

    return callerAcl;
}

From source file:com.breadwallet.tools.security.RequestHandler.java

public static String newNonce(Activity app, String nonceKey) {
    // load previous nonces. we save all nonces generated for each service
    // so they are not used twice from the same device
    List<Integer> existingNonces = SharedPreferencesManager.getBitIdNonces(app, nonceKey);

    String nonce = "";
    while (existingNonces.contains(Integer.valueOf(nonce))) {
        nonce = String.valueOf(System.currentTimeMillis() / 1000);
    }/* w  w w  .ja  va2s .  c o  m*/
    existingNonces.add(Integer.valueOf(nonce));
    SharedPreferencesManager.putBitIdNonces(app, existingNonces, nonceKey);

    return nonce;
}

From source file:fr.cph.chicago.util.Util.java

public static void addToBikeFavorites(final int stationId, @NonNull final View view) {
    final List<String> favorites = Preferences.getBikeFavorites(view.getContext(),
            App.PREFERENCE_FAVORITES_BIKE);
    if (!favorites.contains(Integer.toString(stationId))) {
        favorites.add(Integer.toString(stationId));
        Preferences.saveBikeFavorites(view.getContext(), App.PREFERENCE_FAVORITES_BIKE, favorites);
        showSnackBar(view, R.string.message_add_fav);
    }//from   www.j a v a 2  s.  c  o  m
}

From source file:fr.cph.chicago.util.Util.java

/**
 * Add to train favorites/*  w  ww.j  a  v a  2s.c  o  m*/
 *
 * @param stationId the station id
 * @param view      the view
 */
public static void addToTrainFavorites(@NonNull final Integer stationId, @NonNull final View view) {
    final List<Integer> favorites = Preferences.getTrainFavorites(view.getContext(),
            App.PREFERENCE_FAVORITES_TRAIN);
    if (!favorites.contains(stationId)) {
        favorites.add(stationId);
        Preferences.saveTrainFavorites(view.getContext(), App.PREFERENCE_FAVORITES_TRAIN, favorites);
        showSnackBar(view, R.string.message_add_fav);
    }
}

From source file:com.soomla.levelup.LevelUp.java

private static void findInternalLists(HashMap<String, JSONObject> objects, List<String> listClasses,
        String listName, JSONObject checkJSON) throws JSONException {
    if (listClasses.contains(checkJSON.optString("className"))) {
        JSONArray internalList = checkJSON.getJSONArray(listName);
        for (int i = 0; i < internalList.length(); i++) {
            JSONObject targetObject = internalList.getJSONObject(i);
            String itemId = targetObject.getString("itemId");
            objects.put(itemId, targetObject);
            findInternalLists(objects, listClasses, listName, targetObject);
        }//  w ww  . j a v  a  2s  . c om
    }
}

From source file:gov.va.vinci.leo.tools.LeoUtils.java

/**
 * Return a list of File Objects in a directory.  Optionally return only a list of Files
 * that match the given FileFilter. Recurse into subdirectories if indicated.  If no filter
 * is provided then return all the files in the directory.
 *
 * @param src     Source directory where the search will be performed.
 * @param filter  Optional, File filter to limit results that are returned.
 * @param recurse If true then recurse into subdirectories, only return this directory results if false
 * @return List of File objects found in this directory
 *///  w ww  .j a va2  s  . c om
public static List<File> listFiles(File src, FileFilter filter, boolean recurse) {
    List<File> files = new ArrayList<File>();
    if (src == null || !src.exists() || src.isFile()) {
        return files;
    } //if

    //Get the list of files, apply the filter if provided
    File[] fileList = (filter != null) ? src.listFiles(filter) : src.listFiles();
    for (File f : fileList) {
        if (!files.contains(f)) {
            files.add(f);
        }
    } //for

    //Recurse through the list of directories
    if (recurse) {
        FileFilter dirFilter = new FileFilter() {
            @Override
            public boolean accept(File f) {
                return f.isDirectory();
            }//accept method
        };
        File[] dirList = src.listFiles(dirFilter);
        for (File f : dirList) {
            files.addAll(listFiles(f, filter, recurse));
        } //for
    } //if

    return files;
}

From source file:edu.nyupoly.cs6903.ag3671.FTPClientExample.java

public static boolean crypto(List<String> args) {
    Security.addProvider(new BouncyCastleProvider());
    keyStorage = new KeyStorage();
    boolean terminate = false;
    if (args.contains("--keygen")) {
        terminate = true;//from ww w. j a  v  a  2 s. co m
        try {
            System.out.println("Keys saved into:\n" + keyStorage.genKeys());
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else {
        try {
            keyChain = keyStorage.readKeys();
            cryptor = new Cryptor(keyChain);
        } catch (Exception e) {
            System.out.println("Cannot read keys. Generate new keys with --keygen option");
            terminate = true;
        }
    }

    return terminate;
}

From source file:it.geosolutions.geobatch.imagemosaic.ImageMosaicGranulesDescriptor.java

/**
 * @return the firstCvNameParts/* ww w  .  ja  va  2s  . co  m*/
 */
// public String[] getFirstCvNameParts() {
// return firstCvNameParts;
// }
//
// /**
// * @return the lastCvNameParts
// */
// public String[] getLastCvNameParts() {
// return lastCvNameParts;
// }

protected static ImageMosaicGranulesDescriptor buildDescriptor(ImageMosaicCommand cmd,
        ImageMosaicConfiguration config) {

    final File inputDir = cmd.getBaseDir();

    final List<File> fileNameList = coll.collect(inputDir);

    // add from command
    if (cmd.getAddFiles() != null) {
        for (File file : cmd.getAddFiles()) {
            if (!fileNameList.contains(file)) {
                fileNameList.add(file);
            }
        }
    }
    // remove from command
    if (cmd.getDelFiles() != null) {
        for (File file : cmd.getDelFiles()) {
            if (!fileNameList.contains(file)) {
                fileNameList.remove(file);
            }
        }
    }

    if (fileNameList == null) {
        if (LOGGER.isInfoEnabled()) {
            LOGGER.info("Unable to collect files from the dir: " + inputDir.getAbsolutePath());
        }
        return null;
    }

    return buildDescriptor(inputDir, fileNameList, config);
}

From source file:com.icesoft.faces.webapp.parser.ImplementationUtil.java

/**
 * For stock JSF components, all setting of attributes, whether by setter 
 * methods, or by puts on the the attribute map (which can delegate to 
 * setter methods), result in List UIComponent.attributesThatAreSet, aka 
 * UIComponentBase.getAttributes().get(//w  ww.  j av a  2 s . c  om
 *     "javax.faces.component.UIComponentBase.attributesThatAreSet")
 * containing that attribute name, as of JSF RI 1.2_05. This optimisation 
 * is disabled for components not in javax.faces.component.* packages, 
 * even if the component extend the stock ones. Meaning that the stock 
 * attributes become decellerated in third party components. It's possible 
 * to create the attributesThatAreSet List for 3rd party components, and 
 * have it track attribute maps puts for attributes that do not have 
 * setter methods. But setter method tracking is only enabled as of 
 * //TODO// JSF RI 1.2_xx, so we need to ascertain that separately, for ICEfaces 
 * extended and custom component rendering.
 * 
 * @param comp An arbitrary component whose attributes are known 
 * @return If the JSF implementation tracks this component's set attributes
 */
private static boolean isAttributeTracking(javax.faces.component.html.HtmlOutputText comp) {
    boolean tracked = false;
    comp.setTitle("value");
    comp.getAttributes().put("lang", "value");
    comp.getAttributes().put("no_method", "value");
    List attributesThatAreSet = (List) comp.getAttributes()
            .get("javax.faces.component.UIComponentBase.attributesThatAreSet");
    //System.out.println(comp.getClass().getName() + " :: attributesThatAreSet: " + attributesThatAreSet);
    if (attributesThatAreSet != null && attributesThatAreSet.contains("title")
            && attributesThatAreSet.contains("lang") && attributesThatAreSet.contains("no_method")) {
        //System.out.println(comp.getClass().getName() + " :: attributesThatAreSet ENABLED");
        tracked = true;
    }
    return tracked;
}

From source file:de.alpharogroup.collections.ListExtensions.java

/**
 * This Method look in the List toSearch if at least one Object exists in the List search.
 *
 * @param <T>/*from ww w  .  j  av a  2s.com*/
 *            the generic type
 * @param toSearch
 *            The List to search.
 * @param search
 *            The List to inspect.
 * @return Returns true if there is at least one Object equal from the two List otherwise false.
 */
public static <T> boolean containAtleastOneObject(final List<T> toSearch, final List<T> search) {
    boolean contains = false;
    final int size = toSearch.size();
    for (int i = 0; i < size; i++) {
        contains = search.contains(toSearch.get(i));
        if (contains) {
            break;
        }
    }
    return contains;
}