Example usage for org.apache.commons.lang3 StringUtils strip

List of usage examples for org.apache.commons.lang3 StringUtils strip

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils strip.

Prototype

public static String strip(String str, final String stripChars) 

Source Link

Document

Strips any of a set of characters from the start and end of a String.

Usage

From source file:com.vmware.photon.controller.deployer.dcp.task.DeployAgentTaskService.java

private void processDeployAgent(State currentState, DeploymentService.State deploymentState,
        HostService.State hostState) {

    List<String> command = new ArrayList<>();
    command.add("./" + SCRIPT_NAME);
    command.add(hostState.hostAddress);//  w w w .ja v  a2s .c  o  m
    command.add(hostState.userName);
    command.add(hostState.password);

    String vibPath = VMFS_VOLUMES + "/"
            + StringUtils.strip(deploymentState.imageDataStoreNames.iterator().next(), "/") + "/"
            + StringUtils.strip(currentState.vibPath, "/");

    command.add(vibPath);

    if (null != deploymentState.syslogEndpoint) {
        command.add("-l");
        command.add(deploymentState.syslogEndpoint);
    }

    DeployerContext deployerContext = HostUtils.getDeployerContext(this);

    File scriptLogFile = new File(deployerContext.getScriptLogDirectory(),
            SCRIPT_NAME + "-" + currentState.uniqueId + ".log");

    ScriptRunner scriptRunner = new ScriptRunner.Builder(command, deployerContext.getScriptTimeoutSec())
            .directory(deployerContext.getScriptDirectory())
            .redirectOutput(ProcessBuilder.Redirect.to(scriptLogFile)).build();

    ListenableFutureTask<Integer> futureTask = ListenableFutureTask.create(scriptRunner);
    HostUtils.getListeningExecutorService(this).submit(futureTask);

    FutureCallback<Integer> futureCallback = new FutureCallback<Integer>() {
        @Override
        public void onSuccess(@Nullable Integer result) {
            if (null == result) {
                failTask(new IllegalStateException(SCRIPT_NAME + " returned null"));
            } else if (0 != result) {
                logScriptErrorAndFail(hostState, result, scriptLogFile);
            } else {
                sendStageProgressPatch(TaskState.TaskStage.FINISHED);
            }
        }

        @Override
        public void onFailure(Throwable t) {
            failTask(t);
        }
    };

    Futures.addCallback(futureTask, futureCallback);
}

From source file:annis.visualizers.component.grid.EventExtractor.java

/**
* Returns the annotations to display according to the mappings configuration.
*
* This will check the "annos" and "annos_regex" paramters for determining.
* the annotations to display. It also iterates over all nodes of the graph
* matching the type./* ww  w .  ja va  2  s.  c  o m*/
*
* @param input The input for the visualizer.
* @param type Which type of nodes to include
* @return
*/
public static List<String> computeDisplayAnnotations(VisualizerInput input, Class<? extends SNode> type) {
    if (input == null) {
        return new LinkedList<String>();
    }

    SDocumentGraph graph = input.getDocument().getSDocumentGraph();

    Set<String> annoPool = getAnnotationLevelSet(graph, input.getNamespace(), type);
    List<String> annos = new LinkedList<String>(annoPool);

    String annosConfiguration = input.getMappings().getProperty(MAPPING_ANNOS_KEY);
    if (annosConfiguration != null && annosConfiguration.trim().length() > 0) {
        String[] split = annosConfiguration.split(",");
        annos.clear();
        for (String s : split) {
            s = s.trim();
            // is regular expression?
            if (s.startsWith("/") && s.endsWith("/")) {
                // go over all remaining items in our pool of all annotations and
                // check if they match
                Pattern regex = Pattern.compile(StringUtils.strip(s, "/"));

                LinkedList<String> matchingAnnos = new LinkedList<String>();
                for (String a : annoPool) {
                    if (regex.matcher(a).matches()) {
                        matchingAnnos.add(a);
                    }
                }

                annos.addAll(matchingAnnos);
                annoPool.removeAll(matchingAnnos);

            } else {
                annos.add(s);
                annoPool.remove(s);
            }
        }
    }

    // filter already found annotation names by regular expression
    // if this was given as mapping
    String regexFilterRaw = input.getMappings().getProperty(MAPPING_ANNO_REGEX_KEY);
    if (regexFilterRaw != null) {
        try {
            Pattern regexFilter = Pattern.compile(regexFilterRaw);
            ListIterator<String> itAnnos = annos.listIterator();
            while (itAnnos.hasNext()) {
                String a = itAnnos.next();
                // remove entry if not matching
                if (!regexFilter.matcher(a).matches()) {
                    itAnnos.remove();
                }
            }
        } catch (PatternSyntaxException ex) {
            log.warn("invalid regular expression in mapping for grid visualizer", ex);
        }
    }
    return annos;
}

From source file:io.stallion.settings.Settings.java

public void assignDefaults() {
    if (getLocalMode() == null) {
        if (empty(System.getenv().getOrDefault("STALLION_DEPLOY_TIME", ""))) {
            setLocalMode(true);/* w ww . java2 s .  c om*/
        } else {
            setLocalMode(false);
        }
    }

    if (bundleDebug == null) {
        bundleDebug = getLocalMode();
    }

    if (getDebug() == null) {
        if (getEnv().equals("prod") && !getLocalMode()) {
            setDebug(false);
        } else {
            setDebug(true);
        }
    }

    if (timeZone == null) {
        timeZone = ZoneId.systemDefault().toString();
    }
    if (timeZoneId == null) {
        timeZoneId = ZoneId.of(timeZone);
    }

    if (logFile == null) {
        String nowString = DateUtils.formatNow("yyyy-MM-dd-HHmmss");
        String base = "";
        try {
            if (!empty(siteUrl)) {
                base = new URL(siteUrl.replace(":{port}", "")).getHost();
            }
        } catch (IOException e) {
            Log.exception(e, "Error parsing siteUrl " + siteUrl);
        }
        logFile = "/tmp/log/stallion/" + base + "-" + nowString + "-"
                + StringUtils.strip(GeneralUtils.slugify(targetFolder), "-") + ".log";
    }
    if (logToConsole == null) {
        logToConsole = getLocalMode();
    }
    if (logToFile == null) {
        logToFile = !logToConsole;
    }

    if (getEmailErrors() == null) {
        if ((getEnv().equals("prod") || getEnv().equals("qa")) && !getLocalMode()) {
            setEmailErrors(true);
        } else {
            setEmailErrors(false);
        }
    }

    if (getStrictnessLevel() == null) {
        if (getEnv().equals("prod") && !getLocalMode()) {
            setStrictnessLevel(StrictnessLevel.LAX);
        } else {
            setStrictnessLevel(StrictnessLevel.STRICT);
        }
    }

    if (!empty(secondaryDomains)) {
        secondaryDomainByDomain = map();
        for (SecondaryDomain d : secondaryDomains) {
            secondaryDomainByDomain.put(d.getDomain(), d);
        }
    }

    if (!StringUtils.isEmpty(getDataDirectory())) {
        if (!getDataDirectory().startsWith("/")) {
            setDataDirectory(targetFolder + "/" + getDataDirectory());
        }
    } else {
        setDataDirectory(targetFolder + "/app-data");
    }
    if (getDataDirectory().endsWith("/")) {
        setDataDirectory(getDataDirectory().substring(0, getDataDirectory().length() - 1));
    }

    if (getRewrites() != null) {
        // THe Toml library has a bug whereby if a map key is quoted, it keeps the
        // quotes as part of the key, rather than using the String inside the quotes
        Set<String> keys = new HashSet<>(getRewrites().keySet());
        for (String key : keys) {
            if (key.startsWith("\"") && key.endsWith("\"")) {
                getRewrites().put(key.substring(1, key.length() - 1), getRewrites().get(key));
            }
        }
    }

    if (getRedirects() != null) {
        // THe Toml library has a bug whereby if a map key is quoted, it keeps the
        // quotes as part of the key, rather than using the String inside the quotes
        Set<String> keys = new HashSet<>(getRedirects().keySet());
        for (String key : keys) {
            if (key.startsWith("\"") && key.endsWith("\"")) {
                getRedirects().put(key.substring(1, key.length() - 1), getRedirects().get(key));
            }
        }
    }

    if (getRewritePatterns() != null && getRewritePatterns().size() > 0) {
        if (rewriteCompiledPatterns == null) {
            rewriteCompiledPatterns = new ArrayList();
        }
        for (String[] entry : getRewritePatterns()) {
            if (entry.length != 2) {
                Log.warn("Invalid rewritePatterns entry, size should be 2 but is {0} {1}", entry.length, entry);
            }
            Pattern pattern = Pattern.compile(entry[0]);
            Map.Entry<Pattern, String> kv = new AbstractMap.SimpleEntry<Pattern, String>(pattern, entry[1]);
            getRewriteCompiledPatterns().add(kv);
        }
    }

    if (getEmail() != null) {
        // By default, in debug mode, we do not want to send real emails to people
        if (getEmail().getRestrictOutboundEmails() == null) {
            getEmail().setRestrictOutboundEmails(getDebug());
        }
        if (getEmail().getOutboundEmailTestAddress() == null) {
            if (getEmail().getAdminEmails() != null && getEmail().getAdminEmails().size() > 0) {
                getEmail().setOutboundEmailTestAddress(getEmail().getAdminEmails().get(0));
            }
        }
        if (!empty(getEmail().getAllowedTestingOutboundEmailPatterns())) {
            if (getEmail().getAllowedTestingOutboundEmailCompiledPatterns() == null) {
                getEmail().setAllowedTestingOutboundEmailCompiledPatterns(new ArrayList<>());
            }
            for (String emailPattern : getEmail().getAllowedTestingOutboundEmailPatterns()) {
                getEmail().getAllowedTestingOutboundEmailCompiledPatterns().add(Pattern.compile(emailPattern));
            }
        }
    }

    if (getSecrets() == null) {
        setSecrets(new SecretsSettings());
    }

    if (new File(targetFolder + "/pages").isDirectory()) {
        if (folders == null) {
            folders = new ArrayList<>();
        }
        folders.add(new ContentFolder().setPath(targetFolder + "/pages").setType("markdown")
                .setItemTemplate(getPageTemplate()));
    }

    if (userUploads != null && empty(userUploads.getUploadsDirectory())) {
        userUploads.setUploadsDirectory(getDataDirectory() + "/st-user-file-uploads");
    }

}

From source file:ch.ivyteam.ivy.maven.engine.EngineControl.java

private EngineState parseState(String engineOut) {
    for (String line : StringUtils.split(engineOut, '\n')) {
        try {// w  w  w .  j a  v  a2 s  .c  o m
            line = StringUtils.strip(line, "\r");
            return EngineState.valueOf(line);
        } catch (Exception ex) { // output can contain log4j configuration outputs -> ignore them!
        }
    }
    context.log.error("Failed to evaluate engine state of engine in directory " + context.engineDirectory);
    return null;
}

From source file:com.mapr.data.sputnik.RandomJsonGenerator.java

private javax.json.stream.JsonGenerator processProperties(javax.json.stream.JsonGenerator gen,
        Map<String, Object> props, String currentContext) {
    //        Map<String, Object> outputValues = new LinkedHashMap<>();
    for (String propName : props.keySet()) {
        Object value = props.get(propName);
        if (value == null) {
            //                outputValues.put(propName, null);
            generatedValues.put(currentContext + propName, null);
            addValue(gen, propName, null);
        } else if (String.class.isAssignableFrom(value.getClass())) {
            String type = (String) value;

            if (type.startsWith("this.") || type.startsWith("cur.")) {
                String refPropName = null;
                if (type.startsWith("this.")) {
                    refPropName = type.substring("this.".length(), type.length());
                } else if (type.startsWith("cur.")) {
                    refPropName = currentContext + type.substring("cur.".length(), type.length());
                }/*  w  w w . ja v  a  2s  . c  o  m*/
                Object refPropValue = generatedValues.get(refPropName);
                if (refPropValue != null) {
                    addValue(gen, propName, refPropValue);
                } else {
                    log.warn("Sorry, unable to reference property [ " + refPropName
                            + " ]. Maybe it hasn't been generated yet?");
                }
            } else {
                try {
                    TypeHandler th = TypeHandlerFactory.getInstance().getTypeHandler(type, generatedValues,
                            currentContext);

                    if (th != null) {
                        Object val = th.getNextRandomValue();
                        //                            outputValues.put(propName, val);
                        generatedValues.put(currentContext + propName, val);
                        addValue(gen, propName, val);
                    } else {
                        //                            log.debug("Unknown Type: [ " + type + " ] for prop [ " + propName + " ]. Attempting to echo literal value.");
                        //                            outputValues.put(propName, type);
                        generatedValues.put(currentContext + propName, type);
                        addValue(gen, propName, type);
                    }
                } catch (IllegalArgumentException iae) {
                    log.warn("Error creating type [ " + type + " ]. Prop [ " + propName
                            + " ] being ignored in output.  Reason: " + iae.getMessage());
                    log.debug("Error creating type [ " + type + " ]. Prop [ " + propName
                            + " ] being ignored in output.", iae);
                }
            }
        } else if (Map.class.isAssignableFrom(value.getClass())) {
            //nested object
            Map<String, Object> nestedProps = (Map<String, Object>) value;
            if (propName == null) {
                gen.writeStartObject();
            } else {
                gen.writeStartObject(propName);
            }
            String newContext = "";
            if (propName != null) {
                if (currentContext.isEmpty()) {
                    newContext = propName + ".";
                } else {
                    newContext = currentContext + propName + ".";
                }
            }
            processProperties(gen, nestedProps, newContext);
            gen.writeEnd();
        } else if (List.class.isAssignableFrom(value.getClass())) {
            //array
            List<Object> listOfItems = (List<Object>) value;
            String newContext = "";
            if (propName != null) {
                gen.writeStartArray(propName);

                if (currentContext.isEmpty()) {
                    newContext = propName;
                } else {
                    newContext = currentContext + propName;
                }
            } else {
                gen.writeStartArray();
            }

            if (!listOfItems.isEmpty()) {
                //Check if this is a special function at the start of the array
                if (String.class.isAssignableFrom(listOfItems.get(0).getClass())
                        && ((String) listOfItems.get(0)).contains("(")) {
                    //special function in array
                    String name = (String) listOfItems.get(0);
                    String specialFunc = null;
                    String[] specialFuncArgs = {};

                    specialFunc = name.substring(0, name.indexOf("("));
                    String args = name.substring(name.indexOf("(") + 1, name.indexOf(")"));

                    if (!args.isEmpty()) {
                        specialFuncArgs = args.split(",");
                    }

                    switch (specialFunc) {
                    case "repeat": {
                        int timesToRepeat = 1;
                        if (specialFuncArgs.length == 1) {
                            timesToRepeat = Integer.parseInt(specialFuncArgs[0]);
                        } else if (specialFuncArgs.length == 2) {
                            int low = Integer.parseInt(specialFuncArgs[0]);
                            int high = Integer.parseInt(specialFuncArgs[1]);
                            timesToRepeat = rdg.randInt(low, high);
                        } else {
                            timesToRepeat = rdg.randInt(0, 10);
                        }
                        List<Object> subList = listOfItems.subList(1, listOfItems.size());
                        for (int i = 0; i < timesToRepeat; i++) {
                            processList(subList, gen, newContext);
                        }
                        break;
                    }
                    case "random": { //choose one of the items in the list at random
                        List<Object> subList = listOfItems.subList(1, listOfItems.size());
                        Object item = subList.get(rdg.randInt(0, subList.size() - 1));
                        processItem(item, gen, newContext + "[0]");
                        break;
                    }
                    case "array": {
                        String largs = name.substring(name.indexOf("(") + 1, name.lastIndexOf(")"));
                        String dtype = largs.substring(0, largs.indexOf(")") + 1);
                        String[] arrayArgs = StringUtils
                                .strip(largs.substring(largs.indexOf(")") + 1).trim(), ",").split(",");
                        int min = Integer.parseInt(arrayArgs[0]);
                        int max = Integer.parseInt(arrayArgs[1]);
                        min = min > max || min == max ? 0 : min;
                        try {
                            Map<String, Object> vals = new LinkedHashMap<String, Object>();
                            for (int i = min; i < max; i++) {
                                TypeHandler th = TypeHandlerFactory.getInstance().getTypeHandler(dtype, vals,
                                        currentContext);
                                if (th != null) {
                                    Object val = th.getNextRandomValue();
                                    addValue(gen, null, val);
                                } else {
                                    addValue(gen, null, dtype);
                                }
                            }
                        } catch (IllegalArgumentException iae) {
                            log.warn("Error creating type [ " + dtype + " ]. Prop [ " + propName
                                    + " ] being ignored in output.  Reason: " + iae.getMessage());
                            log.debug("Error creating type [ " + dtype + " ]. Prop [ " + propName
                                    + " ] being ignored in output.", iae);
                        }
                        break;
                    }
                    }
                } else { //it's not a special function, so just add it
                    processList(listOfItems, gen, newContext);
                }
            }
            gen.writeEnd();
        } else {
            //literals
            generatedValues.put(currentContext + propName, value);
            addValue(gen, propName, value);
        }
    }

    return gen;
}

From source file:com.vaadin.tests.tb3.AbstractTB3Test.java

/**
 * Returns the full URL to be used for the test
 *
 * @return the full URL for the test//from w  w w  .  j a va  2  s  .co  m
 */
protected String getTestUrl() {
    return StringUtils.strip(getBaseURL(), "/") + getDeploymentPath();
}

From source file:com.vaadin.tests.tb3.AbstractTB3Test.java

/**
 * Returns the full URL to be used for the test for the provided UI class.
 *
 * @return the full URL for the test/*from ww  w. ja va  2  s  .com*/
 */
protected String getTestURL(Class<?> uiClass) {
    return StringUtils.strip(getBaseURL(), "/") + getDeploymentPath(uiClass);
}

From source file:io.stallion.dataAccess.db.SqlGenerationAction.java

public GenerateResult createTableSqlForSchema(Schema schema) {
    StringBuilder sql = new StringBuilder();
    sql.append("CREATE TABLE IF NOT EXISTS `" + schema.getName() + "` (\n");
    sql.append("`id` bigint(20) unsigned NOT NULL,\n");
    for (Col col : schema.getColumns()) {
        sql.append("    `" + col.getName() + "` ");
        sql.append(" " + dbTypeForColumn(col) + " ");
        if (col.getNullable()) {
            sql.append(" NULL ");
        } else {/*  w ww. ja  v a  2s.  co  m*/
            sql.append(" NOT NULL ");
        }
        if (col.getDefaultValue() != null) {
            Object defaultVal = col.getDefaultValue();
            if (defaultVal instanceof Boolean) {
                if ((Boolean) defaultVal == true) {
                    defaultVal = 1;
                } else {
                    defaultVal = 0;
                }
            } else {
                defaultVal = "'" + defaultVal.toString().replace("'", "\'") + "'";
            }
            sql.append(" DEFAULT " + defaultVal + " ");
        }
        sql.append(",\n");
    }
    sql.append(
            "  `row_updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n");
    sql.append("  PRIMARY KEY (`id`),\n");
    sql.append("  KEY `row_updated_at_key` (`row_updated_at`),\n");

    for (Col col : schema.getColumns()) {
        if (col.getUniqueKey()) {
            sql.append("  UNIQUE KEY `" + col.getName() + "_key` (`" + col.getName() + "`),\n");

        }
        if (col.getAlternativeKey()) {
            sql.append("  KEY `" + col.getName() + "_key` (`" + col.getName() + "`),\n");
        }
    }
    for (String def : schema.getExtraKeyDefinitions()) {
        sql.append("    " + def + ",\n");
    }
    String sqlString = sql.toString();
    sqlString = StringUtils.strip(StringUtils.strip(sqlString, "\n"), ",") + "\n";
    sqlString += ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;";

    return new GenerateResult().setChangePrefix("create-table-" + schema.getName()).setSql(sqlString)
            .setSqlJs("db.execute('''\n" + sqlString + " \n''');").setTableName(schema.getName());
}

From source file:ca.phon.ipadictionary.impl.ImmutablePlainTextDictionary.java

@Override
public String[] lookup(String orthography) throws IPADictionaryExecption {
    orthography = StringUtils.strip(orthography, "?!\"'.\\/@&$()^%#*");
    TernaryTree<List<String>> db;
    try {//  w  ww  . j av a  2s .com
        db = lazyLoadDb();
    } catch (IOException e) {
        throw new BackingStoreException(e);
    }

    List<String> ipaEntries = db.get(orthography.toLowerCase());
    if (ipaEntries != null && ipaEntries.size() > 0) {
        return ipaEntries.toArray(new String[0]);
    } else {
        return new String[0];
    }
}

From source file:forge.card.BoosterGenerator.java

/**
 * This method also modifies passed parameter
 *//* w  w w.java  2 s  .  c  o m*/
private static Predicate<PaperCard> buildExtraPredicate(List<String> operators) {

    List<Predicate<PaperCard>> conditions = new ArrayList<>();

    Iterator<String> itOp = operators.iterator();
    while (itOp.hasNext()) {

        String operator = itOp.next();
        if (StringUtils.isEmpty(operator)) {
            itOp.remove();
            continue;
        }

        if (operator.endsWith("s")) {
            operator = operator.substring(0, operator.length() - 1);
        }

        boolean invert = operator.charAt(0) == '!';
        if (invert) {
            operator = operator.substring(1);
        }

        Predicate<PaperCard> toAdd = null;
        if (operator.equalsIgnoreCase(BoosterSlots.DUAL_FACED_CARD)) {
            toAdd = Predicates.compose(CardRulesPredicates.splitType(CardSplitType.Transform),
                    PaperCard.FN_GET_RULES);
        } else if (operator.equalsIgnoreCase(BoosterSlots.LAND)) {
            toAdd = Predicates.compose(CardRulesPredicates.Presets.IS_LAND, PaperCard.FN_GET_RULES);
        } else if (operator.equalsIgnoreCase(BoosterSlots.BASIC_LAND)) {
            toAdd = IPaperCard.Predicates.Presets.IS_BASIC_LAND;
        } else if (operator.equalsIgnoreCase(BoosterSlots.TIME_SHIFTED)) {
            toAdd = IPaperCard.Predicates.Presets.IS_SPECIAL;
        } else if (operator.equalsIgnoreCase(BoosterSlots.SPECIAL)) {
            toAdd = IPaperCard.Predicates.Presets.IS_SPECIAL;
        } else if (operator.equalsIgnoreCase(BoosterSlots.MYTHIC)) {
            toAdd = IPaperCard.Predicates.Presets.IS_MYTHIC_RARE;
        } else if (operator.equalsIgnoreCase(BoosterSlots.RARE)) {
            toAdd = IPaperCard.Predicates.Presets.IS_RARE;
        } else if (operator.equalsIgnoreCase(BoosterSlots.UNCOMMON)) {
            toAdd = IPaperCard.Predicates.Presets.IS_UNCOMMON;
        } else if (operator.equalsIgnoreCase(BoosterSlots.COMMON)) {
            toAdd = IPaperCard.Predicates.Presets.IS_COMMON;
        } else if (operator.startsWith("name(")) {
            operator = StringUtils.strip(operator.substring(4), "() ");
            String[] cardNames = TextUtil.splitWithParenthesis(operator, ',', '"', '"');
            toAdd = IPaperCard.Predicates.names(Lists.newArrayList(cardNames));
        } else if (operator.startsWith("color(")) {
            operator = StringUtils.strip(operator.substring("color(".length() + 1), "()\" ");
            switch (operator.toLowerCase()) {
            case "black":
                toAdd = Presets.IS_BLACK;
                break;
            case "blue":
                toAdd = Presets.IS_BLUE;
                break;
            case "green":
                toAdd = Presets.IS_GREEN;
                break;
            case "red":
                toAdd = Presets.IS_RED;
                break;
            case "white":
                toAdd = Presets.IS_WHITE;
                break;
            case "colorless":
                toAdd = Presets.IS_COLORLESS;
                break;
            }
        } else if (operator.startsWith("fromSets(")) {
            operator = StringUtils.strip(operator.substring("fromSets(".length() + 1), "()\" ");
            String[] sets = operator.split(",");
            toAdd = IPaperCard.Predicates.printedInSets(sets);
        } else if (operator.startsWith("fromSheet(") && invert) {
            String sheetName = StringUtils.strip(operator.substring(9), "()\" ");
            Iterable<PaperCard> src = StaticData.instance().getPrintSheets().get(sheetName).toFlatList();
            List<String> cardNames = Lists.newArrayList();
            for (PaperCard card : src) {
                cardNames.add(card.getName());
            }
            toAdd = IPaperCard.Predicates.names(Lists.newArrayList(cardNames));
        }

        if (toAdd == null) {
            continue;
        } else {
            itOp.remove();
        }

        if (invert) {
            toAdd = Predicates.not(toAdd);
        }
        conditions.add(toAdd);

    }

    if (conditions.isEmpty()) {
        return Predicates.alwaysTrue();
    }

    return Predicates.and(conditions);

}